mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
initial commit for reload config command
This commit is contained in:
parent
7c835bae20
commit
c49fdf1233
@ -171,6 +171,11 @@ namespace client
|
|||||||
m_Destinations.clear ();
|
m_Destinations.clear ();
|
||||||
m_SharedLocalDestination = nullptr;
|
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)
|
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);
|
auto clientTunnel = new I2PClientTunnel (name, dest, address, port, localDestination, destinationPort);
|
||||||
if (m_ClientTunnels.insert (std::make_pair (clientTunnel->GetAcceptor ().local_endpoint (),
|
if (m_ClientTunnels.insert (std::make_pair (clientTunnel->GetAcceptor ().local_endpoint (),
|
||||||
std::unique_ptr<I2PClientTunnel>(clientTunnel))).second)
|
std::unique_ptr<I2PClientTunnel>(clientTunnel))).second)
|
||||||
|
{
|
||||||
clientTunnel->Start ();
|
clientTunnel->Start ();
|
||||||
|
numClientTunnels++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Clients: I2P client tunnel with port ", port, " already exists");
|
LogPrint (eLogError, "Clients: I2P client tunnel for endpoint ", clientTunnel->GetAcceptor ().local_endpoint (), " already exists");
|
||||||
numClientTunnels++;
|
|
||||||
}
|
}
|
||||||
else if (type == I2P_TUNNELS_SECTION_TYPE_SERVER || type == I2P_TUNNELS_SECTION_TYPE_HTTP || type == I2P_TUNNELS_SECTION_TYPE_IRC)
|
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 (
|
if (m_ServerTunnels.insert (std::make_pair (
|
||||||
std::make_pair (localDestination->GetIdentHash (), inPort),
|
std::make_pair (localDestination->GetIdentHash (), inPort),
|
||||||
std::unique_ptr<I2PServerTunnel>(serverTunnel))).second)
|
std::unique_ptr<I2PServerTunnel>(serverTunnel))).second)
|
||||||
|
{
|
||||||
serverTunnel->Start ();
|
serverTunnel->Start ();
|
||||||
|
numServerTunnels++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Clients: I2P server tunnel for destination ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), " already exists");
|
LogPrint (eLogError, "Clients: I2P server tunnel for destination/port ", m_AddressBook.ToAddress(localDestination->GetIdentHash ()), "/", inPort, " already exists");
|
||||||
numServerTunnels++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf);
|
LogPrint (eLogWarning, "Clients: Unknown section type=", type, " of ", name, " in ", tunConf);
|
||||||
|
@ -48,6 +48,8 @@ namespace client
|
|||||||
void Start ();
|
void Start ();
|
||||||
void Stop ();
|
void Stop ();
|
||||||
|
|
||||||
|
void ReloadConfig ();
|
||||||
|
|
||||||
std::shared_ptr<ClientDestination> GetSharedLocalDestination () const { return m_SharedLocalDestination; };
|
std::shared_ptr<ClientDestination> GetSharedLocalDestination () const { return m_SharedLocalDestination; };
|
||||||
std::shared_ptr<ClientDestination> CreateNewLocalDestination (bool isPublic = false, i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1,
|
std::shared_ptr<ClientDestination> CreateNewLocalDestination (bool isPublic = false, i2p::data::SigningKeyType sigType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1,
|
||||||
const std::map<std::string, std::string> * params = nullptr); // transient
|
const std::map<std::string, std::string> * params = nullptr); // transient
|
||||||
|
@ -225,7 +225,8 @@ namespace http {
|
|||||||
const char HTTP_COMMAND_SHUTDOWN_START[] = "shutdown_start";
|
const char HTTP_COMMAND_SHUTDOWN_START[] = "shutdown_start";
|
||||||
const char HTTP_COMMAND_SHUTDOWN_CANCEL[] = "shutdown_cancel";
|
const char HTTP_COMMAND_SHUTDOWN_CANCEL[] = "shutdown_cancel";
|
||||||
const char HTTP_COMMAND_SHUTDOWN_NOW[] = "terminate";
|
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_BASE32_ADDRESS[] = "b32";
|
||||||
const char HTTP_PARAM_SAM_SESSION_ID[] = "id";
|
const char HTTP_PARAM_SAM_SESSION_ID[] = "id";
|
||||||
const char HTTP_PARAM_ADDRESS[] = "address";
|
const char HTTP_PARAM_ADDRESS[] = "address";
|
||||||
@ -509,6 +510,7 @@ namespace http {
|
|||||||
/* commands */
|
/* commands */
|
||||||
s << "<b>Router Commands</b><br>\r\n";
|
s << "<b>Router Commands</b><br>\r\n";
|
||||||
s << " <a href=/?cmd=" << HTTP_COMMAND_RUN_PEER_TEST << ">Run peer test</a><br>\r\n";
|
s << " <a href=/?cmd=" << HTTP_COMMAND_RUN_PEER_TEST << ">Run peer test</a><br>\r\n";
|
||||||
|
s << " <a href=/?cmd=" << HTTP_COMMAND_RELOAD_CONFIG << ">Reload config</a><br>\r\n";
|
||||||
if (i2p::context.AcceptsTunnels ())
|
if (i2p::context.AcceptsTunnels ())
|
||||||
s << " <a href=/?cmd=" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << ">Stop accepting tunnels</a><br>\r\n";
|
s << " <a href=/?cmd=" << HTTP_COMMAND_STOP_ACCEPTING_TUNNELS << ">Stop accepting tunnels</a><br>\r\n";
|
||||||
else
|
else
|
||||||
@ -814,6 +816,8 @@ namespace http {
|
|||||||
|
|
||||||
if (cmd == HTTP_COMMAND_RUN_PEER_TEST)
|
if (cmd == HTTP_COMMAND_RUN_PEER_TEST)
|
||||||
i2p::transport::transports.PeerTest ();
|
i2p::transport::transports.PeerTest ();
|
||||||
|
else if (cmd == HTTP_COMMAND_RELOAD_CONFIG)
|
||||||
|
i2p::client::context.ReloadConfig ();
|
||||||
else if (cmd == HTTP_COMMAND_START_ACCEPTING_TUNNELS)
|
else if (cmd == HTTP_COMMAND_START_ACCEPTING_TUNNELS)
|
||||||
i2p::context.SetAcceptsTunnels (true);
|
i2p::context.SetAcceptsTunnels (true);
|
||||||
else if (cmd == HTTP_COMMAND_STOP_ACCEPTING_TUNNELS)
|
else if (cmd == HTTP_COMMAND_STOP_ACCEPTING_TUNNELS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user