I DO THE SOCK AROUND

This commit is contained in:
malloc 2018-04-24 09:39:52 -05:00
parent 08989a8c7a
commit f448d18e9e
3 changed files with 20 additions and 11 deletions

View file

@ -462,6 +462,15 @@ In the event that an endpoint cannot evaluate a date required by the protocol as
## Status Code Index ## Status Code Index
TODO: MAKE THIS SECTION NOT LOOK LIKE SHIT
### Master / Slave ### Master / Slave
#### M -> S ID 3 #### S -> M (ID 1)
0x01: KEY SIZE WAS INCORRECT
0x02: COULD NOT PARSE KEY
### Master / Client
### Slave / Client

View file

@ -35,7 +35,9 @@ class MasterIntra {
public: public:
MasterIntra(IntraClient client); MasterIntra(IntraClient client);
bool Process(); bool Process();
bool Close(); bool Close();
bool Close(const Packet& message);
private: private:
enum kSlaveToMasterId { enum kSlaveToMasterId {
InitAttempt = 1, InitAttempt = 1,

View file

@ -15,18 +15,11 @@ bool sosc::MasterIntra::Process() {
switch(pck.GetId()) { switch(pck.GetId()) {
case InitAttempt: case InitAttempt:
if(!pck.Check(1, key.key_size_bytes)) if(!pck.Check(1, key.key_size_bytes))
return this->Close(); return this->Close(Packet(EncryptionError, { "\x01" }));
Packet response; Packet response;
if(!this->key.ParseRequest(pck, &response)) { if(!this->key.ParseRequest(pck, &response))
this->sock.Send( return this->Close(Packet(EncryptionError, { "\x02" }));
Packet(EncryptionError, {
""
})
);
this->Close();
}
this->sock.Send(response); this->sock.Send(response);
break; break;
@ -45,3 +38,8 @@ bool sosc::MasterIntra::Close() {
this->sock.Close(); this->sock.Close();
return false; return false;
} }
bool sosc::MasterIntra::Close(const Packet &message) {
this->sock.Send(message);
this->Close();
}