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
TODO: MAKE THIS SECTION NOT LOOK LIKE SHIT
### 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:
MasterIntra(IntraClient client);
bool Process();
bool Close();
bool Close(const Packet& message);
private:
enum kSlaveToMasterId {
InitAttempt = 1,

View file

@ -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();
}