]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/configuration/sgconfig/conn.h
Various fixes of issues reported by static analyzers.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / conn.h
index e3cb3f0c6e72a26274929c5dd9b49b598315e50a..ed2e64d1ba780862c161840de87003fe400f4673 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "parser.h"
 
+#include "dumphelpers.h"
+
 #include "stg/os_int.h"
 #include "stg/const.h"
 
@@ -51,7 +53,7 @@ class Conn
     public:
         struct Error : public std::runtime_error
         {
-            Error(const std::string& message) : runtime_error(message.c_str()) {}
+            explicit Error(const std::string& message) : runtime_error(message.c_str()) {}
         };
 
         Conn(const BASE_PARSER::REGISTRY & registry,
@@ -63,12 +65,16 @@ class Conn
         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];
@@ -125,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);