brb joining tsuki

This commit is contained in:
malloc 2018-09-28 16:33:48 -05:00
parent 13df494cc1
commit daec714f80
5 changed files with 46 additions and 161 deletions

View file

@ -12,7 +12,7 @@ Because the body of the packet is a sequence of many different regions of byte d
* The first two bytes will always be 0xB0 and 0x0B. If this is not set properly, the endpoint must close the connection. * The first two bytes will always be 0xB0 and 0x0B. If this is not set properly, the endpoint must close the connection.
* The next four bytes are the total length of the entire packet, including the whole header. * The next four bytes are the total length of the entire packet, including the whole header.
* The seventh byte is the packet id, the meanings of which are defined in the [_Packet IDs_](#packet-ids) section. * The seventh byte is the packet id, the meanings of which are defined in the packet ID list section.
* The eighth byte is the number of byte regions in the packet. * The eighth byte is the number of byte regions in the packet.
* The bytes following the eighth byte are a list of binary length segments, each of which correspond to the number of bytes in its respective region. They each follow this format: * The bytes following the eighth byte are a list of binary length segments, each of which correspond to the number of bytes in its respective region. They each follow this format:
* If length is less than 254, the length of the region is stored in a single byte. * If length is less than 254, the length of the region is stored in a single byte.
@ -39,30 +39,24 @@ A packet ID may have a specific "direction" of communication, in that an endpoin
A _blind requester_ is an endpoint that sends out a packet of a certain ID and either does not expect a response or expects a response on a different packet ID. A _blind requester_ is an endpoint that sends out a packet of a certain ID and either does not expect a response or expects a response on a different packet ID.
#### Server to Client
TODO: populate
#### Client to Server
TODO: populate
## Master/Slave Servers ## Master/Slave Servers
To keep track of the status of multiple servers from a centralized point that the client may query, each server must be able to communicate with a "master" server that will record and dispense information regarding all servers to clients. All servers that report to the master server will hereby be refered to as "slave" servers. To keep track of the status of multiple servers from a centralized point that the client may query, each server must be able to communicate with a "master" server that will record and dispense information regarding all servers to clients. All servers that report to the master server will hereby be refered to as "slave" servers.
Communication between master and slave servers will be done over a TCP connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently. Communication between master and slave servers will be done over a TCP connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the Packet IDs are defined differently.
Communication between the master server and clients will be done over a WebSocket connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the [_Packet IDs_](#TODO) are defined differently. Communication between the master server and clients will be done over a WebSocket connection on a port that is defined by the master server's configuration. The protocol used for this communication is identical to the protocol defined for standard client/server communication; however, the Packet IDs are defined differently.
## Packet ID List
### Master/Slave Packet IDs ### Master/Slave Packet IDs
#### Master to Slave #### Master to Slave [Encrypted]
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 1: Key Exchange<br /> ID 0: Positive ACK<br />
Responder Responder
</th> </th>
</thead> </thead>
@ -71,54 +65,6 @@ Communication between the master server and clients will be done over a WebSocke
<th>Region</th> <th>Region</th>
<th>Type</th> <th>Type</th>
</thead> </thead>
<tr>
<td>1</td>
<td>Generator</td>
<td>Big Int</td>
</tr>
<tr>
<td>2</td>
<td>Modulus</td>
<td>Big Int</td>
</tr>
<tr>
<td>3</td>
<td>Server Key</td>
<td>Big Int</td>
</tr>
</table>
<table style="margin-right: 8px; margin-bottom: 8px;">
<thead>
<th colspan="100" class="center">
ID 2: Encryption Error<br />
Responder
</th>
</thead>
<thead>
<th>#</th>
<th>Region</th>
<th>Type</th>
</thead>
<tr>
<td>1</td>
<td>Error Code</td>
<td>Packed Unsigned Short</td>
</tr>
</table>
<table style="margin-right: 8px; margin-bottom: 8px;">
<thead>
<th colspan="100" class="center">
ID 3: Positive ACK<br />
[Encrypted] Responder
</th>
</thead>
<thead>
<th>#</th>
<th>Region</th>
<th>Type</th>
</thead>
<tr> <tr>
<td>1</td> <td>1</td>
<td>Request Packet ID</td> <td>Request Packet ID</td>
@ -129,8 +75,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 4: Negative ACK<br /> ID 1: Negative ACK<br />
[Encrypted] Responder Responder
</th> </th>
</thead> </thead>
<thead> <thead>
@ -150,12 +96,12 @@ Communication between the master server and clients will be done over a WebSocke
</tr> </tr>
</table> </table>
#### Slave to Master #### Slave to Master [Encrypted]
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 1: Initiation Attempt<br /> ID 0: Authentication<br />
Requester Requester
</th> </th>
</thead> </thead>
@ -164,25 +110,6 @@ Communication between the master server and clients will be done over a WebSocke
<th>Region</th> <th>Region</th>
<th>Type</th> <th>Type</th>
</thead> </thead>
<tr>
<td class="center">1</td>
<td>Secret</td>
<td>String</td>
</tr>
</table>
<table style="margin-right: 8px; margin-bottom: 8px;">
<thead>
<th colspan="100" class="center">
ID 2: Authentication<br />
[Encrypted] Requester
</th>
</thead>
<thead>
<th>#</th>
<th>Region</th>
<th>Type</th>
</thead>
<tr> <tr>
<td class="center">1</td> <td class="center">1</td>
<td>Server Name</td> <td>Server Name</td>
@ -208,8 +135,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 3: Status Update<br /> ID 1: Status Update<br />
[Encrypted] Blind Requester Blind Requester
</th> </th>
</thead> </thead>
<thead> <thead>
@ -231,42 +158,13 @@ Communication between the master server and clients will be done over a WebSocke
### Master/Client Packet IDs ### Master/Client Packet IDs
#### Master to Client #### Master to Client [Encrypted]
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 1: Key Exchange<br /> ID 0: Login Attempt<br />
Requester Responder
</th>
</thead>
<thead>
<th>#</th>
<th>Region</th>
<th>Type</th>
</thead>
<tr>
<td>1</td>
<td>Generator</td>
<td>Big Int</td>
</tr>
<tr>
<td>2</td>
<td>Modulus</td>
<td>Big Int</td>
</tr>
<tr>
<td>3</td>
<td>Server Key</td>
<td>Big Int</td>
</tr>
</table>
<table style="margin-right: 8px; margin-bottom: 8px;">
<thead>
<th colspan="100" class="center">
ID 2: Login Attempt<br />
[Encrypted] Responder
</th> </th>
</thead> </thead>
<thead> <thead>
@ -310,8 +208,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 3: Registration Attempt<br /> ID 1: Registration Attempt<br />
[Encrypted] Responder Responder
</th> </th>
</thead> </thead>
<thead> <thead>
@ -334,8 +232,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 4: Server List Request<br /> ID 2: Server List Request<br />
[Encrypted] Responder Responder
</th> </th>
</thead> </thead>
<thead> <thead>
@ -364,32 +262,13 @@ Communication between the master server and clients will be done over a WebSocke
</tr> </tr>
</table> </table>
#### Client to Master #### Client to Master [Encrypted]
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 1: Key Exchange<br /> ID 0: Login Attempt<br />
Responder Requester
</th>
</thead>
<thead>
<th>#</th>
<th>Region</th>
<th>Type</th>
</thead>
<tr>
<td class="center">1</td>
<td>Secret</td>
<td>String</td>
</tr>
</table>
<table style="margin-right: 8px; margin-bottom: 8px;">
<thead>
<th colspan="100" class="center">
ID 2: Login Attempt<br />
[Encrypted] Requester
</th> </th>
</thead> </thead>
<thead> <thead>
@ -417,8 +296,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 3: Registration Attempt<br /> ID 1: Registration Attempt<br />
[Encrypted] Requester Requester
</th> </th>
</thead> </thead>
<thead> <thead>
@ -446,8 +325,8 @@ Communication between the master server and clients will be done over a WebSocke
<table style="margin-right: 8px; margin-bottom: 8px;"> <table style="margin-right: 8px; margin-bottom: 8px;">
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
ID 4: Server List Request<br /> ID 2: Server List Request<br />
[Encrypted] Requester<br /> Requester<br />
</th> </th>
<thead> <thead>
<th colspan="100" class="center"> <th colspan="100" class="center">
@ -457,6 +336,16 @@ Communication between the master server and clients will be done over a WebSocke
</thead> </thead>
</table> </table>
### Slave/Client Packet IDs
#### Slave to Client
TODO: populate
#### Client to Slave
TODO: populate
## Sockstamps ## Sockstamps
Because epoch time is not standardized across systems, an intermediate layer of date/time transmission must be used between the client and server so as to handle time dependent interactions. Therefore, a "sockstamp" will be used in place of the context-dependent implementations of epoch time. Because epoch time is not standardized across systems, an intermediate layer of date/time transmission must be used between the client and server so as to handle time dependent interactions. Therefore, a "sockstamp" will be used in place of the context-dependent implementations of epoch time.

Binary file not shown.

View file

@ -16,7 +16,13 @@ const char* _mem_db_sql =
"CREATE UNIQUE INDEX `UIX_SERVER_LICENSES` ON `SERVER_LICENSES` (" "CREATE UNIQUE INDEX `UIX_SERVER_LICENSES` ON `SERVER_LICENSES` ("
"`KEY_ID`, `SECRET`" "`KEY_ID`, `SECRET`"
");\n"; ");\n"
"CREATE TABLE `USER_KEYS` ("
"`ID` INTEGER,"
"`SECRET` BLOB NOT NULL UNIQUE,"
"PRIMARY KEY(`ID`)"
");";
const char* _hard_db_init_migration_sql = const char* _hard_db_init_migration_sql =
"CREATE TABLE `MIGRATIONS` (" "CREATE TABLE `MIGRATIONS` ("

View file

@ -44,7 +44,6 @@ public:
bool Close(); bool Close();
bool Close(const Packet& message); bool Close(const Packet& message);
private: private:
bool InitAttempt(Packet& pck);
bool Authentication(Packet& pck); bool Authentication(Packet& pck);
bool StatusUpdate(Packet& pck); bool StatusUpdate(Packet& pck);
@ -54,15 +53,12 @@ private:
bool NotAuthorized(const std::string& packetId); bool NotAuthorized(const std::string& packetId);
enum SlaveToMasterId { enum SlaveToMasterId {
kInitAttempt = 1, kAuthentication = 0,
kAuthentication,
kStatusUpdate kStatusUpdate
}; };
enum MasterToSlaveId { enum MasterToSlaveId {
kKeyExchange = 1, kPositiveAck = 0,
kEncryptionError,
kPositiveAck,
kNegativeAck kNegativeAck
}; };

View file

@ -93,8 +93,6 @@ bool sosc::MasterIntra::Process(const Queries* queries) {
this->queries = queries; this->queries = queries;
switch(pck.GetId()) { switch(pck.GetId()) {
case kInitAttempt:
return this->InitAttempt(pck);
case kAuthentication: case kAuthentication:
return this->Authentication(pck); return this->Authentication(pck);
case kStatusUpdate: case kStatusUpdate:
@ -104,10 +102,6 @@ bool sosc::MasterIntra::Process(const Queries* queries) {
} }
} }
bool sosc::MasterIntra::InitAttempt(sosc::Packet& pck) {
}
bool sosc::MasterIntra::Authentication(sosc::Packet& pck) { bool sosc::MasterIntra::Authentication(sosc::Packet& pck) {
if(this->authed) if(this->authed)
return true; return true;