Browse Source

override SSU port if specified

pull/97/head
orignal 10 years ago
parent
commit
c8cdeead44
  1. 10
      Daemon.cpp
  2. 21
      RouterContext.cpp
  3. 4
      RouterContext.h

10
Daemon.cpp

@ -60,10 +60,12 @@ namespace i2p
isDaemon = i2p::util::config::GetArg("-daemon", 0); isDaemon = i2p::util::config::GetArg("-daemon", 0);
isLogging = i2p::util::config::GetArg("-log", 1); isLogging = i2p::util::config::GetArg("-log", 1);
//TODO: This is an ugly workaround. fix it. int port = i2p::util::config::GetArg("-port", 0);
//TODO: Autodetect public IP. if (port)
i2p::context.OverrideNTCPAddress(i2p::util::config::GetCharArg("-host", "127.0.0.1"), i2p::context.UpdatePort (port);
i2p::util::config::GetArg("-port", 17007)); const char * host = i2p::util::config::GetCharArg("-host", "");
if (host && host[0])
i2p::context.UpdateAddress (host);
if (i2p::util::config::GetArg("-unreachable", 0)) if (i2p::util::config::GetArg("-unreachable", 0))
i2p::context.SetUnreachable (); i2p::context.SetUnreachable ();

21
RouterContext.cpp

@ -55,17 +55,20 @@ namespace i2p
m_RouterInfo.SaveToFile (i2p::util::filesystem::GetFullPath (ROUTER_INFO)); m_RouterInfo.SaveToFile (i2p::util::filesystem::GetFullPath (ROUTER_INFO));
m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch (); m_LastUpdateTime = i2p::util::GetSecondsSinceEpoch ();
} }
void RouterContext::OverrideNTCPAddress (const char * host, int port) void RouterContext::UpdatePort (int port)
{ {
m_RouterInfo.CreateBuffer (m_Keys); bool updated = false;
auto address = const_cast<i2p::data::RouterInfo::Address *>(m_RouterInfo.GetNTCPAddress ()); for (auto& address : m_RouterInfo.GetAddresses ())
if (address)
{ {
address->host = boost::asio::ip::address::from_string (host); if (address.port != port)
address->port = port; {
} address.port = port;
UpdateRouterInfo (); updated = true;
}
}
if (updated)
UpdateRouterInfo ();
} }
void RouterContext::UpdateAddress (const char * host) void RouterContext::UpdateAddress (const char * host)

4
RouterContext.h

@ -26,8 +26,8 @@ namespace i2p
const i2p::data::IdentHash& GetRouterIdentHash () const { return m_RouterInfo.GetIdentHash (); }; const i2p::data::IdentHash& GetRouterIdentHash () const { return m_RouterInfo.GetIdentHash (); };
CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; }; CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; };
void OverrideNTCPAddress (const char * host, int port); // temporary void UpdatePort (int port); // called from Daemon
void UpdateAddress (const char * host); // called from SSU void UpdateAddress (const char * host); // called from SSU or Daemon
bool AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag); bool AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag);
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e); void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
bool IsUnreachable () const { return m_IsUnreachable; }; bool IsUnreachable () const { return m_IsUnreachable; };

Loading…
Cancel
Save