squiddable

This commit is contained in:
malloc 2018-05-10 19:49:41 -05:00
parent 2e43dfaab8
commit 867d8a3fcc
6 changed files with 36 additions and 28 deletions

View file

@ -12,7 +12,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -static") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -static")
endif() 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") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_link_libraries(server wsock32 ws2_32) target_link_libraries(server wsock32 ws2_32)

View file

@ -1,3 +1,6 @@
#ifndef SOSC_INIT_SQL_DEF
#define SOSC_INIT_SQL_DEF
#include <vector> #include <vector>
const char* _mem_db_sql = const char* _mem_db_sql =
@ -42,3 +45,5 @@ const std::vector<const char*> _hard_db_sql = {
") WITHOUT ROWID;\n", ") WITHOUT ROWID;\n",
/** END MIGRATION 0 **/ /** END MIGRATION 0 **/
}; };
#endif

View file

@ -1,5 +1,5 @@
#include "database.hpp" #include "database.hpp"
#include "_init_sql.cpp" #include "_init_sql.hpp"
static struct { static struct {
bool ready = false; bool ready = false;

View file

@ -7,9 +7,6 @@
#include <vector> #include <vector>
#include <string> #include <string>
#define DB_COL_TEXT 1
#define DB_COL_BLOB 2
#define DB_USE_HARD 1 #define DB_USE_HARD 1
#define DB_USE_MEMORY 2 #define DB_USE_MEMORY 2

View file

@ -33,25 +33,27 @@ protected:
class MasterIntra { class MasterIntra {
public: public:
MasterIntra(const IntraClient& client); explicit MasterIntra(const IntraClient& client);
bool Process(); bool Process();
bool Close(); bool Close();
bool Close(const Packet& message); bool Close(const Packet& message);
private: private:
bool InitAttempt(Packet& pck); bool InitAttempt(Packet& pck);
bool Authentication(Packet& pck);
bool StatusUpdate(Packet& pck);
enum kSlaveToMasterId { enum SlaveToMasterId {
InitAttempt = 1, kInitAttempt = 1,
Authentication, kAuthentication,
StatusUpdate kStatusUpdate
}; };
enum kMasterToSlaveId { enum MasterToSlaveId {
KeyExchange = 1, kKeyExchange = 1,
EncryptionError, kEncryptionError,
PositiveAck, kPositiveAck,
NegativeAck kNegativeAck
}; };
IntraClient sock; IntraClient sock;

View file

@ -13,32 +13,36 @@ bool sosc::MasterIntra::Process() {
return true; return true;
switch(pck.GetId()) { switch(pck.GetId()) {
case InitAttempt: case kInitAttempt:
return this->InitAttempt(pck); return this->InitAttempt(pck);
case Authentication: case kAuthentication:
return this->Authentication(pck);
break; case kStatusUpdate:
case StatusUpdate: return this->StatusUpdate(pck);
break;
default: default:
return this->Close(); return this->Close();
} }
return true;
} }
bool sosc::MasterIntra::InitAttempt(sosc::Packet &pck) { bool sosc::MasterIntra::InitAttempt(sosc::Packet &pck) {
if(!pck.Check(1, key.key_size_bytes)) if(!pck.Check(1, key.key_size_bytes))
return this->Close(Packet(EncryptionError, { "\x01" })); return this->Close(Packet(kEncryptionError, { "\x01" }));
Packet response; Packet response;
if(!this->key.ParseRequest(pck, &response, KeyExchange)) if(!this->key.ParseRequest(pck, &response, kKeyExchange))
return this->Close(Packet(EncryptionError, { "\x02" })); return this->Close(Packet(kEncryptionError, { "\x02" }));
this->sock.Send(response); this->sock.Send(response);
} }
bool sosc::MasterIntra::Authentication(sosc::Packet &pck) {
}
bool sosc::MasterIntra::StatusUpdate(sosc::Packet &pck) {
}
bool sosc::MasterIntra::Close() { bool sosc::MasterIntra::Close() {
this->sock.Close(); this->sock.Close();
return false; return false;