Browse Source

[daemon] WIP: rework accessing from webconsole and App

Signed-off-by: R4SAS <r4sas@i2pmail.org>
webconsole-inja
R4SAS 2 years ago
parent
commit
fbe2e734c2
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 2
      Makefile
  2. 2
      Makefile.mingw
  3. 18
      Win32/Win32App.cpp
  4. 11
      Win32/Win32App.h
  5. 15
      Win32/Win32Service.cpp
  6. 19
      Win32/Win32Service.h
  7. 2
      daemon/Daemon.cpp
  8. 17
      daemon/Daemon.h
  9. 0
      daemon/DaemonUnix.cpp
  10. 8
      daemon/DaemonWin32.cpp
  11. 36
      libi2pd_webconsole/HTTPServer.cpp
  12. 13
      libi2pd_webconsole/HTTPServer.h

2
Makefile

@ -64,7 +64,7 @@ else ifneq (, $(findstring freebsd, $(SYS))$(findstring openbsd, $(SYS)))
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
include Makefile.bsd include Makefile.bsd
else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS))) else ifneq (, $(findstring mingw, $(SYS))$(findstring windows-gnu, $(SYS))$(findstring cygwin, $(SYS)))
DAEMON_SRC += Win32/DaemonWin32.cpp Win32/Win32App.cpp Win32/Win32Service.cpp Win32/Win32NetState.cpp DAEMON_SRC += Win32/Win32App.cpp Win32/Win32Service.cpp Win32/Win32NetState.cpp
include Makefile.mingw include Makefile.mingw
else # not supported else # not supported
$(error Not supported platform) $(error Not supported platform)

2
Makefile.mingw

@ -4,7 +4,7 @@ USE_WIN32_APP := yes
WINDRES = windres WINDRES = windres
CXXFLAGS := $(CXX_DEBUG) -fPIC -msse CXXFLAGS := $(CXX_DEBUG) -fPIC -msse
INCFLAGS = -I$(DAEMON_SRC_DIR) -IWin32 INCFLAGS = -IWin32
LDFLAGS := ${LD_DEBUG} -static LDFLAGS := ${LD_DEBUG} -static
NEEDED_CXXFLAGS += -std=c++17 -DWIN32_LEAN_AND_MEAN NEEDED_CXXFLAGS += -std=c++17 -DWIN32_LEAN_AND_MEAN

18
Win32/Win32App.cpp

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2022, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -18,7 +18,7 @@
#include "Tunnel.h" #include "Tunnel.h"
#include "version.h" #include "version.h"
#include "resource.h" #include "resource.h"
#include "Daemon.h"
#include "Win32App.h" #include "Win32App.h"
#include "Win32NetState.h" #include "Win32NetState.h"
@ -55,13 +55,15 @@ namespace win32
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_ABOUT, "&About..."); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_ABOUT, "&About...");
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
if(!i2p::context.AcceptsTunnels()) if(!i2p::context.AcceptsTunnels())
InsertMenu (hPopup, -1, if(m_getIsGraceful)
i2p::util::DaemonWin32::Instance ().isGraceful ? MF_BYPOSITION | MF_STRING | MF_GRAYED : MF_BYPOSITION | MF_STRING, if(m_getIsGraceful())
ID_ACCEPT_TRANSIT, "Accept &transit"); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING | MF_GRAYED, ID_ACCEPT_TRANSIT, "Accept &transit");
else
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_ACCEPT_TRANSIT, "Accept &transit");
else else
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_DECLINE_TRANSIT, "Decline &transit"); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_DECLINE_TRANSIT, "Decline &transit");
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_RELOAD, "&Reload tunnels config"); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_RELOAD, "&Reload tunnels config");
if (!i2p::util::DaemonWin32::Instance ().isGraceful) if (!m_getIsGraceful)
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_GRACEFUL_SHUTDOWN, "&Graceful shutdown"); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_GRACEFUL_SHUTDOWN, "&Graceful shutdown");
else else
InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_STOP_GRACEFUL_SHUTDOWN, "Stop &graceful shutdown"); InsertMenu (hPopup, -1, MF_BYPOSITION | MF_STRING, ID_STOP_GRACEFUL_SHUTDOWN, "Stop &graceful shutdown");
@ -270,7 +272,7 @@ namespace win32
SetTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER, 10*60*1000, nullptr); // 10 minutes SetTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER, 10*60*1000, nullptr); // 10 minutes
SetTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER, 1000, nullptr); // check tunnels every second SetTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER, 1000, nullptr); // check tunnels every second
g_GracefulShutdownEndtime = GetTickCount() + 10*60*1000; g_GracefulShutdownEndtime = GetTickCount() + 10*60*1000;
i2p::util::DaemonWin32::Instance ().isGraceful = true; if (m_setIsGraceful) m_setIsGraceful(true);
return 0; return 0;
} }
case ID_STOP_GRACEFUL_SHUTDOWN: case ID_STOP_GRACEFUL_SHUTDOWN:
@ -279,7 +281,7 @@ namespace win32
KillTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER); KillTimer (hWnd, IDT_GRACEFUL_SHUTDOWN_TIMER);
KillTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER); KillTimer (hWnd, IDT_GRACEFUL_TUNNELCHECK_TIMER);
g_GracefulShutdownEndtime = 0; g_GracefulShutdownEndtime = 0;
i2p::util::DaemonWin32::Instance ().isGraceful = false; if (m_setIsGraceful) m_setIsGraceful(false);
return 0; return 0;
} }
case ID_RELOAD: case ID_RELOAD:

11
Win32/Win32App.h

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2020, The PurpleI2P Project * Copyright (c) 2013-2022, The PurpleI2P Project
* *
* This file is part of Purple i2pd project and licensed under BSD3 * This file is part of Purple i2pd project and licensed under BSD3
* *
@ -22,6 +22,15 @@ namespace win32
int RunWin32App (); int RunWin32App ();
bool GracefulShutdown (); bool GracefulShutdown ();
bool StopGracefulShutdown (); bool StopGracefulShutdown ();
inline typedef std::function<void (bool)> DaemonSetIsGraceful;
inline DaemonSetIsGraceful m_setIsGraceful;
inline void SetIsGraceful (const DaemonSetIsGraceful& f) { m_setIsGraceful = f; };
inline typedef std::function<bool ()> DaemonGetIsGraceful;
inline DaemonGetIsGraceful m_getIsGraceful;
inline void GetIsGraceful (const DaemonGetIsGraceful& f) { m_getIsGraceful = f; };
} }
} }
#endif // WIN32APP_H__ #endif // WIN32APP_H__

15
Win32/Win32Service.cpp

@ -10,7 +10,6 @@
#include <assert.h> #include <assert.h>
#include <windows.h> #include <windows.h>
#include "Daemon.h"
#include "Log.h" #include "Log.h"
I2PService *I2PService::s_service = NULL; I2PService *I2PService::s_service = NULL;
@ -132,7 +131,13 @@ void I2PService::Start(DWORD dwArgc, PSTR *pszArgv)
void I2PService::OnStart(DWORD dwArgc, PSTR *pszArgv) void I2PService::OnStart(DWORD dwArgc, PSTR *pszArgv)
{ {
LogPrint(eLogInfo, "Win32Service: in OnStart (", EVENTLOG_INFORMATION_TYPE, ")"); LogPrint(eLogInfo, "Win32Service: in OnStart (", EVENTLOG_INFORMATION_TYPE, ")");
Daemon.start(); if(m_daemonStart)
m_daemonStart();
else
{
LogPrint(eLogError, "Win32Service: failed to start: Unable to call callback");
SetServiceStatus(SERVICE_STOPPED);
}
_worker = new std::thread(std::bind(&I2PService::WorkerThread, this)); _worker = new std::thread(std::bind(&I2PService::WorkerThread, this));
} }
@ -171,7 +176,11 @@ void I2PService::OnStop()
{ {
// Log a service stop message to the Application log. // Log a service stop message to the Application log.
LogPrint(eLogInfo, "Win32Service: in OnStop (", EVENTLOG_INFORMATION_TYPE, ")"); LogPrint(eLogInfo, "Win32Service: in OnStop (", EVENTLOG_INFORMATION_TYPE, ")");
Daemon.stop(); if(m_daemonStop)
m_daemonStop();
else
LogPrint(eLogError, "Win32Service: failed to stop: Unable to call callback");
m_fStopping = TRUE; m_fStopping = TRUE;
if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0) if (WaitForSingleObject(m_hStoppedEvent, INFINITE) != WAIT_OBJECT_0)
{ {

19
Win32/Win32Service.h

@ -6,9 +6,10 @@
* See full license text in LICENSE file at top of project tree * See full license text in LICENSE file at top of project tree
*/ */
#ifndef WIN_32_SERVICE_H__ #ifndef WIN32SERVICE_H__
#define WIN_32_SERVICE_H__ #define WIN32SERVICE_H__
#include <functional>
#include <thread> #include <thread>
#include <windows.h> #include <windows.h>
@ -29,6 +30,13 @@ class I2PService
static BOOL Run(I2PService &service); static BOOL Run(I2PService &service);
void Stop(); void Stop();
typedef std::function<bool ()> DaemonStart;
void SetDaemonStart (const DaemonStart& f) { m_daemonStart = f; };
typedef std::function<bool ()> DaemonStop;
void SetDaemonStop (const DaemonStop& f) { m_daemonStop = f; };
protected: protected:
virtual void OnStart(DWORD dwArgc, PSTR *pszArgv); virtual void OnStart(DWORD dwArgc, PSTR *pszArgv);
@ -58,6 +66,11 @@ class I2PService
HANDLE m_hStoppedEvent; HANDLE m_hStoppedEvent;
std::thread* _worker; std::thread* _worker;
private:
DaemonStart m_daemonStart;
DaemonStop m_daemonStop;
}; };
#endif // WIN_32_SERVICE_H__ #endif // WIN32SERVICE_H__

2
daemon/Daemon.cpp

@ -425,7 +425,7 @@ namespace util
d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort)); d.httpServer = std::unique_ptr<i2p::http::HTTPServer>(new i2p::http::HTTPServer(httpAddr, httpPort));
d.httpServer->SetDaemonStop (std::bind (Daemon_Singleton::stop, this)); d.httpServer->SetDaemonStop (std::bind (Daemon_Singleton::stop, this));
#if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY)) #if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY))
d.httpServer->SetDaemonGracefulTimer (std::bind (Daemon_Singleton::stop, this)); d.httpServer->SetDaemonGracefulTimer (std::bind (gracefulShutdownInterval, this));
#endif #endif
d.httpServer->Start(); d.httpServer->Start();
} }

17
daemon/Daemon.h

@ -75,14 +75,17 @@ namespace util
return instance; return instance;
} }
bool init(int argc, char* argv[]); bool init (int argc, char* argv[]);
bool start(); bool start ();
bool stop(); bool stop ();
void run (); void run ();
bool isGraceful; void SetIsGraceful (bool state) { m_isGraceful = state; };
const bool GetIsGraceful () { return m_isGraceful; };
DaemonWin32 ():isGraceful(false) {} private:
bool m_isGraceful;
}; };
#elif (defined(ANDROID) && !defined(ANDROID_BINARY)) #elif (defined(ANDROID) && !defined(ANDROID_BINARY))
#define Daemon i2p::util::DaemonAndroid::Instance() #define Daemon i2p::util::DaemonAndroid::Instance()
@ -109,8 +112,8 @@ namespace util
return instance; return instance;
} }
bool start(); bool start ();
bool stop(); bool stop ();
void run (); void run ();
private: private:

0
daemon/UnixDaemon.cpp → daemon/DaemonUnix.cpp

8
Win32/DaemonWin32.cpp → daemon/DaemonWin32.cpp

@ -6,6 +6,8 @@
* See full license text in LICENSE file at top of project tree * See full license text in LICENSE file at top of project tree
*/ */
#ifdef _WIN32
#include <thread> #include <thread>
#include <clocale> #include <clocale>
#include "Config.h" #include "Config.h"
@ -13,7 +15,6 @@
#include "util.h" #include "util.h"
#include "Log.h" #include "Log.h"
#ifdef _WIN32
#include "Win32Service.h" #include "Win32Service.h"
#ifdef WIN32_APP #ifdef WIN32_APP
#include <windows.h> #include <windows.h>
@ -38,6 +39,9 @@ namespace util
} }
); );
i2p::win32::SetIsGraceful (std::bind (&DaemonWin32::SetIsGraceful, this, std::placeholders::_1));
i2p::win32::GetIsGraceful (std::bind (&DaemonWin32::GetIsGraceful, this));
if (!Daemon_Singleton::init(argc, argv)) if (!Daemon_Singleton::init(argc, argv))
return false; return false;
@ -45,6 +49,8 @@ namespace util
{ {
LogPrint(eLogDebug, "Daemon: running as service"); LogPrint(eLogDebug, "Daemon: running as service");
I2PService service((PSTR)SERVICE_NAME); I2PService service((PSTR)SERVICE_NAME);
service.SetDaemonStart (std::bind (&DaemonWin32::start, this));
service.SetDaemonStop (std::bind (&DaemonWin32::stop, this));
if (!I2PService::Run(service)) if (!I2PService::Run(service))
{ {
LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError()); LogPrint(eLogError, "Daemon: Service failed to run w/err 0x%08lx\n", GetLastError());

36
libi2pd_webconsole/HTTPServer.cpp

@ -31,10 +31,9 @@
#include "ECIESX25519AEADRatchetSession.h" #include "ECIESX25519AEADRatchetSession.h"
#include "I18N.h" #include "I18N.h"
#ifdef WIN32_APP //#ifdef WIN32_APP
#include "Daemon.h" //#include "Win32App.h"
#include "Win32App.h" //#endif
#endif
// Inja template engine // Inja template engine
#include "inja/inja.hpp" #include "inja/inja.hpp"
@ -281,13 +280,13 @@ namespace http {
ShowUptime(s, remains); ShowUptime(s, remains);
s << "<br>\r\n"; s << "<br>\r\n";
} }
#elif defined(WIN32_APP) /*#elif defined(WIN32_APP)
if (i2p::win32::g_GracefulShutdownEndtime != 0) { if (i2p::win32::g_GracefulShutdownEndtime != 0) {
uint16_t remains = (i2p::win32::g_GracefulShutdownEndtime - GetTickCount()) / 1000; uint16_t remains = (i2p::win32::g_GracefulShutdownEndtime - GetTickCount()) / 1000;
s << "<b>" << tr("Stopping in") << ":</b> "; s << "<b>" << tr("Stopping in") << ":</b> ";
ShowUptime(s, remains); ShowUptime(s, remains);
s << "<br>\r\n"; s << "<br>\r\n";
} }*/
#endif #endif
s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n"; s << "<b>" << tr("Tunnel creation success rate") << ":</b> " << i2p::tunnel::tunnels.GetTunnelCreationSuccessRate () << "%<br>\r\n";
s << "<b>" << tr("Received") << ":</b> "; s << "<b>" << tr("Received") << ":</b> ";
@ -714,11 +713,12 @@ namespace http {
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "&token=" << token << "\">" << tr("Cancel graceful shutdown") << "</a><br>\r\n"; s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "&token=" << token << "\">" << tr("Cancel graceful shutdown") << "</a><br>\r\n";
else else
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "&token=" << token << "\">" << tr("Start graceful shutdown") << "</a><br>\r\n"; s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "&token=" << token << "\">" << tr("Start graceful shutdown") << "</a><br>\r\n";
#elif defined(WIN32_APP) /*#elif defined(WIN32_APP)
if (i2p::util::DaemonWin32::Instance().isGraceful) if (i2p::util::DaemonWin32::Instance().isGraceful)
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "&token=" << token << "\">" << tr("Cancel graceful shutdown") << "</a><br>\r\n"; s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_CANCEL << "&token=" << token << "\">" << tr("Cancel graceful shutdown") << "</a><br>\r\n";
else else
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "&token=" << token << "\">" << tr("Start graceful shutdown") << "</a><br>\r\n"; s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_START << "&token=" << token << "\">" << tr("Start graceful shutdown") << "</a><br>\r\n";
*/
#endif #endif
s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_NOW << "&token=" << token << "\">" << tr("Force shutdown") << "</a><br><br>\r\n"; s << " <a href=\"" << webroot << "?cmd=" << HTTP_COMMAND_SHUTDOWN_NOW << "&token=" << token << "\">" << tr("Force shutdown") << "</a><br><br>\r\n";
@ -1023,8 +1023,8 @@ namespace http {
} }
} }
HTTPConnection::HTTPConnection (std::string hostname, std::shared_ptr<boost::asio::ip::tcp::socket> socket): HTTPConnection::HTTPConnection (std::string hostname, std::shared_ptr<boost::asio::ip::tcp::socket> socket, HTTPServer& server):
m_Socket (socket), m_BufferLen (0), expected_host(hostname) m_Socket (socket), m_Server (server), m_BufferLen (0), expected_host(hostname)
{ {
/* cache options */ /* cache options */
i2p::config::GetOption("http.auth", needAuth); i2p::config::GetOption("http.auth", needAuth);
@ -1248,8 +1248,9 @@ namespace http {
// TODO: rewrite timer access // TODO: rewrite timer access
#if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY)) #if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY))
if (m_DaemonGracefulTimer) m_DaemonGracefulTimer = 10 * 60; if (m_DaemonGracefulTimer) m_DaemonGracefulTimer = 10 * 60;
#elif defined(WIN32_APP) /*#elif defined(WIN32_APP)
i2p::win32::GracefulShutdown (); i2p::win32::GracefulShutdown ();
*/
#endif #endif
} }
else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL) else if (cmd == HTTP_COMMAND_SHUTDOWN_CANCEL)
@ -1258,18 +1259,19 @@ namespace http {
// TODO: rewrite timer access // TODO: rewrite timer access
#if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY)) #if ((!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID)) || defined(ANDROID_BINARY))
if (m_DaemonGracefulTimer) m_DaemonGracefulTimer = 0; if (m_DaemonGracefulTimer) m_DaemonGracefulTimer = 0;
#elif defined(WIN32_APP) /*#elif defined(WIN32_APP)
i2p::win32::StopGracefulShutdown (); i2p::win32::StopGracefulShutdown ();
*/
#endif #endif
} }
else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW) else if (cmd == HTTP_COMMAND_SHUTDOWN_NOW)
{ {
// TODO: rewrite stop command access // TODO: rewrite stop command access
#ifndef WIN32_APP //#ifndef WIN32_APP
if (m_DaemonStop) m_DaemonStop(); m_Server.GetDaemonStop();
#else //#else
i2p::win32::StopWin32App (); // i2p::win32::StopWin32App ();
#endif //#endif
} }
else if (cmd == HTTP_COMMAND_LOGLEVEL) else if (cmd == HTTP_COMMAND_LOGLEVEL)
{ {
@ -1503,7 +1505,7 @@ namespace http {
void HTTPServer::CreateConnection(std::shared_ptr<boost::asio::ip::tcp::socket> newSocket) void HTTPServer::CreateConnection(std::shared_ptr<boost::asio::ip::tcp::socket> newSocket)
{ {
auto conn = std::make_shared<HTTPConnection> (m_Hostname, newSocket); auto conn = std::make_shared<HTTPConnection> (m_Hostname, newSocket, *this);
conn->Receive (); conn->Receive ();
} }
} // http } // http

13
libi2pd_webconsole/HTTPServer.h

@ -25,11 +25,13 @@ namespace http
const size_t HTTP_CONNECTION_BUFFER_SIZE = 8192; const size_t HTTP_CONNECTION_BUFFER_SIZE = 8192;
const int TOKEN_EXPIRATION_TIMEOUT = 30; // in seconds const int TOKEN_EXPIRATION_TIMEOUT = 30; // in seconds
class HTTPServer;
class HTTPConnection: public std::enable_shared_from_this<HTTPConnection> class HTTPConnection: public std::enable_shared_from_this<HTTPConnection>
{ {
public: public:
HTTPConnection (std::string serverhost, std::shared_ptr<boost::asio::ip::tcp::socket> socket); HTTPConnection (std::string serverhost, std::shared_ptr<boost::asio::ip::tcp::socket> socket, HTTPServer& server);
void Receive (); void Receive ();
private: private:
@ -48,6 +50,7 @@ namespace http
private: private:
std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket; std::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
HTTPServer& m_Server;
char m_Buffer[HTTP_CONNECTION_BUFFER_SIZE + 1]; char m_Buffer[HTTP_CONNECTION_BUFFER_SIZE + 1];
size_t m_BufferLen; size_t m_BufferLen;
std::string m_SendBuffer; std::string m_SendBuffer;
@ -70,9 +73,11 @@ namespace http
void Stop (); void Stop ();
typedef std::function<void ()> DaemonStop; typedef std::function<void ()> DaemonStop;
typedef int DaemonGracefulTimer;
void SetDaemonStop (const DaemonStop& f) { m_DaemonStop = f; }; void SetDaemonStop (const DaemonStop& f) { m_DaemonStop = f; };
void SetDaemonGracefulTimer (const DaemonGracefulTimer& f) { m_DaemonGracefulTimer = f; }; DaemonStop GetDaemonStop () { return m_DaemonStop; };
void SetDaemonGracefulTimer (const int& f) { m_DaemonGracefulTimer = f; };
int GetDaemonGracefulTimer () { return m_DaemonGracefulTimer; };
private: private:
@ -94,7 +99,7 @@ namespace http
private: private:
DaemonStop m_DaemonStop; DaemonStop m_DaemonStop;
DaemonGracefulTimer m_DaemonGracefulTimer; int m_DaemonGracefulTimer;
}; };
//all the below functions are also used by Qt GUI, see mainwindow.cpp -> getStatusPageHtml //all the below functions are also used by Qt GUI, see mainwindow.cpp -> getStatusPageHtml

Loading…
Cancel
Save