X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/899b65fa18e88f77d584d79f71592a2b51a632c2..50419f0521446b8e698a391e3c2cb3fc711733ce:/projects/stargazer/plugins/configuration/sgconfig/conn.h?ds=inline diff --git a/projects/stargazer/plugins/configuration/sgconfig/conn.h b/projects/stargazer/plugins/configuration/sgconfig/conn.h index 8f76b7e9..c67c972e 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/conn.h +++ b/projects/stargazer/plugins/configuration/sgconfig/conn.h @@ -23,6 +23,8 @@ #include "parser.h" +#include "dumphelpers.h" + #include "stg/os_int.h" #include "stg/const.h" @@ -39,6 +41,7 @@ class USERS; class TARIFFS; class ADMIN; class BASE_PARSER; +class PLUGIN_LOGGER; namespace STG { @@ -54,19 +57,24 @@ class Conn }; Conn(const BASE_PARSER::REGISTRY & registry, - ADMINS & admins, int sock, const sockaddr_in& addr); + ADMINS & admins, int sock, const sockaddr_in& addr, + PLUGIN_LOGGER & logger); ~Conn(); int Sock() const { return m_sock; } uint32_t IP() const { return *(uint32_t *)(&m_addr.sin_addr); } uint16_t Port() const { return ntohs(m_addr.sin_port); } + std::string endpoint() const { return inet_ntostring(IP()) + ":" + x2str(Port()); } + bool Read(); bool IsOk() const { return m_state != ERROR; } bool IsDone() const { return m_state == DONE; } bool IsKeepAlive() const { return m_keepAlive; } + void SetKeepAlive() { m_keepAlive = true; } + private: static const char STG_HEADER[5]; @@ -100,6 +108,7 @@ class Conn char m_cryptoLogin[ADM_LOGIN_LEN]; // Without \0 char m_data[1024]; STG::DECRYPT_STREAM * m_stream; + PLUGIN_LOGGER & m_logger; BASE_PARSER * GetParser(const std::string & tag) const; @@ -113,6 +122,8 @@ class Conn bool WriteAnswer(const void* buffer, size_t size); bool WriteResponse(); + void Log(const char * file, const std::string & message); + struct DataState { DataState(bool f, Conn & c) : final(f), conn(c) {} @@ -120,6 +131,10 @@ class Conn Conn & conn; } m_dataState; +#ifdef DUMPCRYPTO + Dumper m_dumper; +#endif + static bool DataCallback(const void * block, size_t size, void * data); static void ParseXMLStart(void * data, const char * el, const char ** attr); static void ParseXMLEnd(void * data, const char * el);