squiddable
This commit is contained in:
parent
2e43dfaab8
commit
867d8a3fcc
6 changed files with 36 additions and 28 deletions
|
@ -12,7 +12,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -static")
|
||||
endif()
|
||||
|
||||
add_executable(server ${server_src} src/db/_init_sql.cpp)
|
||||
add_executable(server ${server_src} src/db/_init_sql.hpp)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(server wsock32 ws2_32)
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef SOSC_INIT_SQL_DEF
|
||||
#define SOSC_INIT_SQL_DEF
|
||||
|
||||
#include <vector>
|
||||
|
||||
const char* _mem_db_sql =
|
||||
|
@ -41,4 +44,6 @@ const std::vector<const char*> _hard_db_sql = {
|
|||
"PRIMARY KEY(`USER_ID`)"
|
||||
") WITHOUT ROWID;\n",
|
||||
/** END MIGRATION 0 **/
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#include "database.hpp"
|
||||
#include "_init_sql.cpp"
|
||||
#include "_init_sql.hpp"
|
||||
|
||||
static struct {
|
||||
bool ready = false;
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define DB_COL_TEXT 1
|
||||
#define DB_COL_BLOB 2
|
||||
|
||||
#define DB_USE_HARD 1
|
||||
#define DB_USE_MEMORY 2
|
||||
|
||||
|
|
|
@ -33,25 +33,27 @@ protected:
|
|||
|
||||
class MasterIntra {
|
||||
public:
|
||||
MasterIntra(const IntraClient& client);
|
||||
explicit MasterIntra(const IntraClient& client);
|
||||
bool Process();
|
||||
|
||||
bool Close();
|
||||
bool Close(const Packet& message);
|
||||
private:
|
||||
bool InitAttempt(Packet& pck);
|
||||
bool Authentication(Packet& pck);
|
||||
bool StatusUpdate(Packet& pck);
|
||||
|
||||
enum kSlaveToMasterId {
|
||||
InitAttempt = 1,
|
||||
Authentication,
|
||||
StatusUpdate
|
||||
enum SlaveToMasterId {
|
||||
kInitAttempt = 1,
|
||||
kAuthentication,
|
||||
kStatusUpdate
|
||||
};
|
||||
|
||||
enum kMasterToSlaveId {
|
||||
KeyExchange = 1,
|
||||
EncryptionError,
|
||||
PositiveAck,
|
||||
NegativeAck
|
||||
enum MasterToSlaveId {
|
||||
kKeyExchange = 1,
|
||||
kEncryptionError,
|
||||
kPositiveAck,
|
||||
kNegativeAck
|
||||
};
|
||||
|
||||
IntraClient sock;
|
||||
|
|
|
@ -13,32 +13,36 @@ bool sosc::MasterIntra::Process() {
|
|||
return true;
|
||||
|
||||
switch(pck.GetId()) {
|
||||
case InitAttempt:
|
||||
case kInitAttempt:
|
||||
return this->InitAttempt(pck);
|
||||
case Authentication:
|
||||
|
||||
break;
|
||||
case StatusUpdate:
|
||||
|
||||
break;
|
||||
case kAuthentication:
|
||||
return this->Authentication(pck);
|
||||
case kStatusUpdate:
|
||||
return this->StatusUpdate(pck);
|
||||
default:
|
||||
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" }));
|
||||
return this->Close(Packet(kEncryptionError, { "\x01" }));
|
||||
|
||||
Packet response;
|
||||
if(!this->key.ParseRequest(pck, &response, KeyExchange))
|
||||
return this->Close(Packet(EncryptionError, { "\x02" }));
|
||||
if(!this->key.ParseRequest(pck, &response, kKeyExchange))
|
||||
return this->Close(Packet(kEncryptionError, { "\x02" }));
|
||||
|
||||
this->sock.Send(response);
|
||||
}
|
||||
|
||||
bool sosc::MasterIntra::Authentication(sosc::Packet &pck) {
|
||||
|
||||
}
|
||||
|
||||
bool sosc::MasterIntra::StatusUpdate(sosc::Packet &pck) {
|
||||
|
||||
}
|
||||
|
||||
bool sosc::MasterIntra::Close() {
|
||||
this->sock.Close();
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue