Browse Source

override SSU port if specified

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

10
Daemon.cpp

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

17
RouterContext.cpp

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

4
RouterContext.h

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

Loading…
Cancel
Save