diff --git a/ClientContext.cpp b/ClientContext.cpp index 2eb81af2..aad41ab2 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -171,6 +171,11 @@ namespace client m_Destinations.clear (); m_SharedLocalDestination = nullptr; } + + void ClientContext::ReloadConfig () + { + ReadTunnels (); // TODO: it reads new tunnels only, should be implemented better + } void ClientContext::LoadPrivateKeys (i2p::data::PrivateKeys& keys, const std::string& filename, i2p::data::SigningKeyType sigType) { @@ -330,10 +335,12 @@ namespace client auto clientTunnel = new I2PClientTunnel (name, dest, address, port, localDestination, destinationPort); if (m_ClientTunnels.insert (std::make_pair (clientTunnel->GetAcceptor ().local_endpoint (), std::unique_ptr(clientTunnel))).second) + { clientTunnel->Start (); + numClientTunnels++; + } else - LogPrint (eLogError, "Clients: I2P client tunnel with port ", port, " already exists"); - numClientTunnels++; + LogPrint (eLogError, "Clients: I2P client tunnel for endpoint ", clientTunnel->GetAcceptor ().local_endpoint (), " already exists"); } else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER || type == I2P_TUNNELS_SECTION_TYPE_HTTP || type == I2P_TUNNELS_SECTION_TYPE_IRC) { @@ -385,10 +392,13 @@ namespace client if (m_ServerTunnels.insert (std::make_pair ( std::make_pair (localDestination->GetIdentHash (), inPort), std::unique_ptr(serverTunnel))).second) + { serverTunnel->Start (); + numServerTunnels++; + } else - LogPrint (eLogError, "Clients: I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists"); - numServerTunnels++; + LogPrint (eLogError, "Clients: I2P server tunnel for destination/port ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), "/", inPort, " already exists"); + } else LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf); diff --git a/ClientContext.h b/ClientContext.h index 3381228b..15ae73c2 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -48,6 +48,8 @@ namespace client void Start (); void Stop (); + void ReloadConfig (); + std::shared_ptr GetSharedLocalDestination () const { return m_SharedLocalDestination; }; std::shared_ptr CreateNewLocalDestination (bool isPublic = false, i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1, const std::map * params = nullptr); // transient diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 63975722..19ccecb5 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -225,7 +225,8 @@ namespace http { const char HTTP_COMMAND_SHUTDOWN_START[] = "shutdown_start"; const char HTTP_COMMAND_SHUTDOWN_CANCEL[] = "shutdown_cancel"; const char HTTP_COMMAND_SHUTDOWN_NOW[] = "terminate"; - const char HTTP_COMMAND_RUN_PEER_TEST[] = "run_peer_test"; + const char HTTP_COMMAND_RUN_PEER_TEST[] = "run_peer_test"; + const char HTTP_COMMAND_RELOAD_CONFIG[] = "reload_config"; const char HTTP_PARAM_BASE32_ADDRESS[] = "b32"; const char HTTP_PARAM_SAM_SESSION_ID[] = "id"; const char HTTP_PARAM_ADDRESS[] = "address"; @@ -509,6 +510,7 @@ namespace http { /* commands */ s << "Router Commands
\r\n"; s << " Run peer test
\r\n"; + s << " Reload config
\r\n"; if (i2p::context.AcceptsTunnels ()) s << " Stop accepting tunnels
\r\n"; else @@ -814,6 +816,8 @@ namespace http { if (cmd == HTTP_COMMAND_RUN_PEER_TEST) i2p::transport::transports.PeerTest (); + else if (cmd == HTTP_COMMAND_RELOAD_CONFIG) + i2p::client::context.ReloadConfig (); else if (cmd == HTTP_COMMAND_START_ACCEPTING_TUNNELS) i2p::context.SetAcceptsTunnels (true); else if (cmd == HTTP_COMMAND_STOP_ACCEPTING_TUNNELS)