diff --git a/I2PControl.cpp b/I2PControl.cpp index a614ff37..aa36817f 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -24,6 +24,7 @@ namespace client m_MethodHandlers[I2P_CONTROL_METHOD_ECHO] = &I2PControlService::EchoHandler; m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_INFO] = &I2PControlService::RouterInfoHandler; m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_MANAGER] = &I2PControlService::RouterManagerHandler; + m_MethodHandlers[I2P_CONTROL_METHOD_NETWORK_SETTING] = &I2PControlService::NetworkSettingHandler; // RouterInfo m_RouterInfoHandlers[I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS] = &I2PControlService::NetDbKnownPeersHandler; @@ -272,5 +273,21 @@ namespace client Daemon.running = 0; }); } + + // network setting + void I2PControlService::NetworkSettingHandler (const std::map& params, std::map& results) + { + LogPrint (eLogDebug, "I2PControl NetworkSetting"); + for (auto& it: params) + { + LogPrint (eLogDebug, it.first); + auto it1 = m_NetworkSettingHandlers.find (it.first); + if (it1 != m_NetworkSettingHandlers.end ()) + (this->*(it1->second))(it.second, results); + else + LogPrint (eLogError, "I2PControl NetworkSetting unknown request ", it.first); + } + } + } } diff --git a/I2PControl.h b/I2PControl.h index a2b976ac..2f51dab0 100644 --- a/I2PControl.h +++ b/I2PControl.h @@ -26,7 +26,8 @@ namespace client const char I2P_CONTROL_METHOD_ECHO[] = "Echo"; const char I2P_CONTROL_METHOD_ROUTER_INFO[] = "RouterInfo"; const char I2P_CONTROL_METHOD_ROUTER_MANAGER[] = "RouterManager"; - + const char I2P_CONTROL_METHOD_NETWORK_SETTING[] = "NetworkSetting"; + // params const char I2P_CONTROL_PARAM_API[] = "API"; const char I2P_CONTROL_PARAM_PASSWORD[] = "Password"; @@ -75,7 +76,8 @@ namespace client void EchoHandler (const std::map& params, std::map& results); void RouterInfoHandler (const std::map& params, std::map& results); void RouterManagerHandler (const std::map& params, std::map& results); - + void NetworkSettingHandler (const std::map& params, std::map& results); + // RouterInfo typedef void (I2PControlService::*RouterInfoRequestHandler)(std::map& results); void NetDbKnownPeersHandler (std::map& results); @@ -86,6 +88,9 @@ namespace client void ShutdownHandler (std::map& results); void ShutdownGracefulHandler (std::map& results); + // NetworkSetting + typedef void (I2PControlService::*NetworkSettingRequestHandler)(const std::string& value, std::map& results); + private: bool m_IsRunning; @@ -94,11 +99,11 @@ namespace client boost::asio::io_service m_Service; boost::asio::ip::tcp::acceptor m_Acceptor; boost::asio::deadline_timer m_ShutdownTimer; - std::map m_MethodHandlers; std::map m_RouterInfoHandlers; std::map m_RouterManagerHandlers; + std::map m_NetworkSettingHandlers; }; } }