oingo boingo
This commit is contained in:
parent
9f2821b84f
commit
2e43dfaab8
4 changed files with 17 additions and 13 deletions
|
@ -39,6 +39,8 @@ public:
|
|||
bool Close();
|
||||
bool Close(const Packet& message);
|
||||
private:
|
||||
bool InitAttempt(Packet& pck);
|
||||
|
||||
enum kSlaveToMasterId {
|
||||
InitAttempt = 1,
|
||||
Authentication,
|
||||
|
|
|
@ -14,15 +14,7 @@ bool sosc::MasterIntra::Process() {
|
|||
|
||||
switch(pck.GetId()) {
|
||||
case InitAttempt:
|
||||
if(!pck.Check(1, key.key_size_bytes))
|
||||
return this->Close(Packet(EncryptionError, { "\x01" }));
|
||||
|
||||
Packet response;
|
||||
if(!this->key.ParseRequest(pck, &response, KeyExchange))
|
||||
return this->Close(Packet(EncryptionError, { "\x02" }));
|
||||
|
||||
this->sock.Send(response);
|
||||
break;
|
||||
return this->InitAttempt(pck);
|
||||
case Authentication:
|
||||
|
||||
break;
|
||||
|
@ -30,13 +22,23 @@ bool sosc::MasterIntra::Process() {
|
|||
|
||||
break;
|
||||
default:
|
||||
this->Close();
|
||||
return false;
|
||||
return this->Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sosc::MasterIntra::InitAttempt(sosc::Packet &pck) {
|
||||
if(!pck.Check(1, key.key_size_bytes))
|
||||
return this->Close(Packet(EncryptionError, { "\x01" }));
|
||||
|
||||
Packet response;
|
||||
if(!this->key.ParseRequest(pck, &response, KeyExchange))
|
||||
return this->Close(Packet(EncryptionError, { "\x02" }));
|
||||
|
||||
this->sock.Send(response);
|
||||
}
|
||||
|
||||
bool sosc::MasterIntra::Close() {
|
||||
this->sock.Close();
|
||||
return false;
|
||||
|
|
|
@ -127,7 +127,7 @@ int sosc::Packet::Parse(const std::string& data, std::string* extra) {
|
|||
return PCK_OK;
|
||||
}
|
||||
|
||||
bool sosc::Packet::Check(int region_count, ...) {
|
||||
bool sosc::Packet::Check(int region_count, ...) const {
|
||||
if(region_count > 0xFF)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
}
|
||||
|
||||
int Parse(const std::string& data, std::string* extra = nullptr);
|
||||
bool Check(int region_count, ...);
|
||||
bool Check(int region_count, ...) const;
|
||||
|
||||
inline void SetId(uint8_t id) {
|
||||
this->id = id;
|
||||
|
|
Loading…
Reference in a new issue