From f448d18e9ee6451e599631a8f9eab3316ac0985e Mon Sep 17 00:00:00 2001 From: malloc Date: Tue, 24 Apr 2018 09:39:52 -0500 Subject: [PATCH] I DO THE SOCK AROUND --- protocol.md | 11 ++++++++++- server/src/hosts/master.hpp | 2 ++ server/src/hosts/master_intra.cpp | 18 ++++++++---------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/protocol.md b/protocol.md index 912d35f..0c51e1c 100644 --- a/protocol.md +++ b/protocol.md @@ -462,6 +462,15 @@ In the event that an endpoint cannot evaluate a date required by the protocol as ## Status Code Index +TODO: MAKE THIS SECTION NOT LOOK LIKE SHIT + ### Master / Slave -#### M -> S ID 3 \ No newline at end of file +#### S -> M (ID 1) +0x01: KEY SIZE WAS INCORRECT + +0x02: COULD NOT PARSE KEY + +### Master / Client + +### Slave / Client \ No newline at end of file diff --git a/server/src/hosts/master.hpp b/server/src/hosts/master.hpp index 74a7cae..3197461 100644 --- a/server/src/hosts/master.hpp +++ b/server/src/hosts/master.hpp @@ -35,7 +35,9 @@ class MasterIntra { public: MasterIntra(IntraClient client); bool Process(); + bool Close(); + bool Close(const Packet& message); private: enum kSlaveToMasterId { InitAttempt = 1, diff --git a/server/src/hosts/master_intra.cpp b/server/src/hosts/master_intra.cpp index 3ed92a1..f0b5001 100644 --- a/server/src/hosts/master_intra.cpp +++ b/server/src/hosts/master_intra.cpp @@ -15,18 +15,11 @@ bool sosc::MasterIntra::Process() { switch(pck.GetId()) { case InitAttempt: if(!pck.Check(1, key.key_size_bytes)) - return this->Close(); + return this->Close(Packet(EncryptionError, { "\x01" })); Packet response; - if(!this->key.ParseRequest(pck, &response)) { - this->sock.Send( - Packet(EncryptionError, { - "" - }) - ); - - this->Close(); - } + if(!this->key.ParseRequest(pck, &response)) + return this->Close(Packet(EncryptionError, { "\x02" })); this->sock.Send(response); break; @@ -45,3 +38,8 @@ bool sosc::MasterIntra::Close() { this->sock.Close(); return false; } + +bool sosc::MasterIntra::Close(const Packet &message) { + this->sock.Send(message); + this->Close(); +}