From daec714f80d79cbad55a4b8ef50dcad11669e110 Mon Sep 17 00:00:00 2001 From: malloc Date: Fri, 28 Sep 2018 16:33:48 -0500 Subject: [PATCH] brb joining tsuki --- protocol.md | 185 ++++++------------------------ resources/server/_mem_schema.db | Bin 12288 -> 20480 bytes src/server/db/_init_sql.hpp | 8 +- src/server/hosts/master.hpp | 8 +- src/server/hosts/master_intra.cpp | 6 - 5 files changed, 46 insertions(+), 161 deletions(-) diff --git a/protocol.md b/protocol.md index e20ea1e..e4cf543 100644 --- a/protocol.md +++ b/protocol.md @@ -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 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 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. @@ -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. -#### Server to Client - -TODO: populate - -#### Client to Server - -TODO: populate - ## 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. -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 to Slave +#### Master to Slave [Encrypted] @@ -71,54 +65,6 @@ Communication between the master server and clients will be done over a WebSocke - - - - - - - - - - - - - - - -
- ID 1: Key Exchange
+ ID 0: Positive ACK
Responder
Region Type
1GeneratorBig Int
2ModulusBig Int
3Server KeyBig Int
- - - - - - - - - - - - - - - -
- ID 2: Encryption Error
- Responder -
#RegionType
1Error CodePacked Unsigned Short
- - - - - - - - - - @@ -129,8 +75,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 3: Positive ACK
- [Encrypted] Responder -
#RegionType
1 Request Packet ID
@@ -150,12 +96,12 @@ Communication between the master server and clients will be done over a WebSocke
- ID 4: Negative ACK
- [Encrypted] Responder + ID 1: Negative ACK
+ Responder
-#### Slave to Master +#### Slave to Master [Encrypted] @@ -164,25 +110,6 @@ Communication between the master server and clients will be done over a WebSocke - - - - - -
- ID 1: Initiation Attempt
+ ID 0: Authentication
Requester
Region Type
1SecretString
- - - - - - - - - - @@ -208,8 +135,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 2: Authentication
- [Encrypted] Requester -
#RegionType
1 Server Name
@@ -231,42 +158,13 @@ Communication between the master server and clients will be done over a WebSocke ### Master/Client Packet IDs -#### Master to Client +#### Master to Client [Encrypted]
- ID 3: Status Update
- [Encrypted] Blind Requester + ID 1: Status Update
+ Blind Requester
- - - - - - - - - - - - - - - - - - - - - -
- ID 1: Key Exchange
- Requester -
#RegionType
1GeneratorBig Int
2ModulusBig Int
3Server KeyBig Int
- - - - @@ -310,8 +208,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 2: Login Attempt
- [Encrypted] Responder + ID 0: Login Attempt
+ Responder
@@ -334,8 +232,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 3: Registration Attempt
- [Encrypted] Responder + ID 1: Registration Attempt
+ Responder
@@ -364,32 +262,13 @@ Communication between the master server and clients will be done over a WebSocke
- ID 4: Server List Request
- [Encrypted] Responder + ID 2: Server List Request
+ Responder
-#### Client to Master +#### Client to Master [Encrypted] - - - - - - - - - - - -
- ID 1: Key Exchange
- Responder -
#RegionType
1SecretString
- - - - @@ -417,8 +296,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 2: Login Attempt
- [Encrypted] Requester + ID 0: Login Attempt
+ Requester
@@ -446,8 +325,8 @@ Communication between the master server and clients will be done over a WebSocke
- ID 3: Registration Attempt
- [Encrypted] Requester + ID 1: Registration Attempt
+ Requester
- ID 4: Server List Request
- [Encrypted] Requester
+ ID 2: Server List Request
+ Requester
@@ -457,6 +336,16 @@ Communication between the master server and clients will be done over a WebSocke
+### Slave/Client Packet IDs + +#### Slave to Client + +TODO: populate + +#### Client to Slave + +TODO: populate + ## 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. diff --git a/resources/server/_mem_schema.db b/resources/server/_mem_schema.db index 767e46fa6d16bc9f5169f6e3c90d41d33054f22b..58faeed7594a131e3bb4447fa07a856fb6a0c660 100644 GIT binary patch delta 253 zcmZojXjs5FL0XWBfq{V)h+%+fqK>gB6N4UO6ffUZ1{OYL27Z0MyL`%gi#8Un=dG`0 zW*3*2XKeH=NleN~4Gne;iuZPn42CmUoP%5)LtGU?9G!ez6%yd$2?`oqoC%&T37npO zA+GMOK{`Nguq#k?NCKymkH3?GpMQvgU#O3dLa3i-V5lolJ|M``*D)wk0ce2+NUJ87 zrnw;to4BhyBSU6hN@_)MVNPaAYJ6g8Nj{h#54SGf5Y7a7j$`vpK6S-K3IdE=n;8ZE G^8)~hpg@%X delta 56 zcmZozz}S#5L0XWJfq{V;h+%+nqK+|8P>(T+7bwKUcb9=*pYQHwL4jPp&3E~f6#?!* B38DZ1 diff --git a/src/server/db/_init_sql.hpp b/src/server/db/_init_sql.hpp index bf01e89..aaa64d0 100644 --- a/src/server/db/_init_sql.hpp +++ b/src/server/db/_init_sql.hpp @@ -16,7 +16,13 @@ const char* _mem_db_sql = "CREATE UNIQUE INDEX `UIX_SERVER_LICENSES` ON `SERVER_LICENSES` (" "`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 = "CREATE TABLE `MIGRATIONS` (" diff --git a/src/server/hosts/master.hpp b/src/server/hosts/master.hpp index 1ccfba0..a1b66d8 100644 --- a/src/server/hosts/master.hpp +++ b/src/server/hosts/master.hpp @@ -44,7 +44,6 @@ public: bool Close(); bool Close(const Packet& message); private: - bool InitAttempt(Packet& pck); bool Authentication(Packet& pck); bool StatusUpdate(Packet& pck); @@ -54,15 +53,12 @@ private: bool NotAuthorized(const std::string& packetId); enum SlaveToMasterId { - kInitAttempt = 1, - kAuthentication, + kAuthentication = 0, kStatusUpdate }; enum MasterToSlaveId { - kKeyExchange = 1, - kEncryptionError, - kPositiveAck, + kPositiveAck = 0, kNegativeAck }; diff --git a/src/server/hosts/master_intra.cpp b/src/server/hosts/master_intra.cpp index c4310eb..ffe51a4 100644 --- a/src/server/hosts/master_intra.cpp +++ b/src/server/hosts/master_intra.cpp @@ -93,8 +93,6 @@ bool sosc::MasterIntra::Process(const Queries* queries) { this->queries = queries; switch(pck.GetId()) { - case kInitAttempt: - return this->InitAttempt(pck); case kAuthentication: return this->Authentication(pck); 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) { if(this->authed) return true;