Browse Source

NetworkSetting method

pull/150/head
orignal 10 years ago
parent
commit
1eef996701
  1. 17
      I2PControl.cpp
  2. 11
      I2PControl.h

17
I2PControl.cpp

@ -24,6 +24,7 @@ namespace client
m_MethodHandlers[I2P_CONTROL_METHOD_ECHO] = &I2PControlService::EchoHandler; m_MethodHandlers[I2P_CONTROL_METHOD_ECHO] = &I2PControlService::EchoHandler;
m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_INFO] = &I2PControlService::RouterInfoHandler; m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_INFO] = &I2PControlService::RouterInfoHandler;
m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_MANAGER] = &I2PControlService::RouterManagerHandler; m_MethodHandlers[I2P_CONTROL_METHOD_ROUTER_MANAGER] = &I2PControlService::RouterManagerHandler;
m_MethodHandlers[I2P_CONTROL_METHOD_NETWORK_SETTING] = &I2PControlService::NetworkSettingHandler;
// RouterInfo // RouterInfo
m_RouterInfoHandlers[I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS] = &I2PControlService::NetDbKnownPeersHandler; m_RouterInfoHandlers[I2P_CONTROL_ROUTER_INFO_NETDB_KNOWNPEERS] = &I2PControlService::NetDbKnownPeersHandler;
@ -272,5 +273,21 @@ namespace client
Daemon.running = 0; Daemon.running = 0;
}); });
} }
// network setting
void I2PControlService::NetworkSettingHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& 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);
}
}
} }
} }

11
I2PControl.h

@ -26,7 +26,8 @@ namespace client
const char I2P_CONTROL_METHOD_ECHO[] = "Echo"; const char I2P_CONTROL_METHOD_ECHO[] = "Echo";
const char I2P_CONTROL_METHOD_ROUTER_INFO[] = "RouterInfo"; const char I2P_CONTROL_METHOD_ROUTER_INFO[] = "RouterInfo";
const char I2P_CONTROL_METHOD_ROUTER_MANAGER[] = "RouterManager"; const char I2P_CONTROL_METHOD_ROUTER_MANAGER[] = "RouterManager";
const char I2P_CONTROL_METHOD_NETWORK_SETTING[] = "NetworkSetting";
// params // params
const char I2P_CONTROL_PARAM_API[] = "API"; const char I2P_CONTROL_PARAM_API[] = "API";
const char I2P_CONTROL_PARAM_PASSWORD[] = "Password"; const char I2P_CONTROL_PARAM_PASSWORD[] = "Password";
@ -75,7 +76,8 @@ namespace client
void EchoHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results); void EchoHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results);
void RouterInfoHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results); void RouterInfoHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results);
void RouterManagerHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results); void RouterManagerHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results);
void NetworkSettingHandler (const std::map<std::string, std::string>& params, std::map<std::string, std::string>& results);
// RouterInfo // RouterInfo
typedef void (I2PControlService::*RouterInfoRequestHandler)(std::map<std::string, std::string>& results); typedef void (I2PControlService::*RouterInfoRequestHandler)(std::map<std::string, std::string>& results);
void NetDbKnownPeersHandler (std::map<std::string, std::string>& results); void NetDbKnownPeersHandler (std::map<std::string, std::string>& results);
@ -86,6 +88,9 @@ namespace client
void ShutdownHandler (std::map<std::string, std::string>& results); void ShutdownHandler (std::map<std::string, std::string>& results);
void ShutdownGracefulHandler (std::map<std::string, std::string>& results); void ShutdownGracefulHandler (std::map<std::string, std::string>& results);
// NetworkSetting
typedef void (I2PControlService::*NetworkSettingRequestHandler)(const std::string& value, std::map<std::string, std::string>& results);
private: private:
bool m_IsRunning; bool m_IsRunning;
@ -94,11 +99,11 @@ namespace client
boost::asio::io_service m_Service; boost::asio::io_service m_Service;
boost::asio::ip::tcp::acceptor m_Acceptor; boost::asio::ip::tcp::acceptor m_Acceptor;
boost::asio::deadline_timer m_ShutdownTimer; boost::asio::deadline_timer m_ShutdownTimer;
std::map<std::string, MethodHandler> m_MethodHandlers; std::map<std::string, MethodHandler> m_MethodHandlers;
std::map<std::string, RouterInfoRequestHandler> m_RouterInfoHandlers; std::map<std::string, RouterInfoRequestHandler> m_RouterInfoHandlers;
std::map<std::string, RouterManagerRequestHandler> m_RouterManagerHandlers; std::map<std::string, RouterManagerRequestHandler> m_RouterManagerHandlers;
std::map<std::string, NetworkSettingRequestHandler> m_NetworkSettingHandlers;
}; };
} }
} }

Loading…
Cancel
Save