Browse Source

unreachable mode

pull/97/head
orignal 10 years ago
parent
commit
fc50b24809
  1. 3
      Daemon.cpp
  2. 3
      README.md
  3. 21
      RouterContext.cpp
  4. 3
      RouterContext.h
  5. 2
      SSU.cpp

3
Daemon.cpp

@ -65,6 +65,9 @@ namespace i2p
i2p::context.OverrideNTCPAddress(i2p::util::config::GetCharArg("-host", "127.0.0.1"), i2p::context.OverrideNTCPAddress(i2p::util::config::GetCharArg("-host", "127.0.0.1"),
i2p::util::config::GetArg("-port", 17007)); i2p::util::config::GetArg("-port", 17007));
if (i2p::util::config::GetArg("-unreachable", 0))
i2p::context.SetUnreachable ();
LogPrint("CMD parameters:"); LogPrint("CMD parameters:");
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
LogPrint(i, " ", argv[i]); LogPrint(i, " ", argv[i]);

3
README.md

@ -48,7 +48,8 @@ Options
* --port= - The port to listen on * --port= - The port to listen on
* --httpport= - The http port to listen on * --httpport= - The http port to listen on
* --log= - Enable or disable logging to file. 1 for yes, 0 for no. * --log= - Enable or disable logging to file. 1 for yes, 0 for no.
* --daemon= - Eanble or disable daemon mode. 1 for yes, 0 for no. * --daemon= - Enable or disable daemon mode. 1 for yes, 0 for no.
* --unreachable= - 1 if router is declared as unreachable and works through introducers.
* --httpproxyport= - The port to listen on (HTTP Proxy) * --httpproxyport= - The port to listen on (HTTP Proxy)
* --socksproxyport= - The port to listen on (SOCKS Proxy) * --socksproxyport= - The port to listen on (SOCKS Proxy)
* --ircport= - The local port of IRC tunnel to listen on. 6668 by default * --ircport= - The local port of IRC tunnel to listen on. 6668 by default

21
RouterContext.cpp

@ -12,7 +12,7 @@ namespace i2p
RouterContext context; RouterContext context;
RouterContext::RouterContext (): RouterContext::RouterContext ():
m_LastUpdateTime (0) m_LastUpdateTime (0), m_IsUnreachable (false)
{ {
} }
@ -101,6 +101,25 @@ namespace i2p
UpdateRouterInfo (); UpdateRouterInfo ();
} }
void RouterContext::SetUnreachable ()
{
m_IsUnreachable = true;
// set caps
m_RouterInfo.SetCaps (i2p::data::RouterInfo::eUnreachable | i2p::data::RouterInfo::eSSUTesting); // LU, B
// remove NTCP address
auto& addresses = m_RouterInfo.GetAddresses ();
for (size_t i = 0; i < addresses.size (); i++)
{
if (addresses[i].transportStyle == i2p::data::RouterInfo::eTransportNTCP)
{
addresses.erase (addresses.begin () + i);
break;
}
}
// update
UpdateRouterInfo ();
}
bool RouterContext::Load () bool RouterContext::Load ()
{ {
std::ifstream fk (i2p::util::filesystem::GetFullPath (ROUTER_KEYS).c_str (), std::ifstream::binary | std::ofstream::in); std::ifstream fk (i2p::util::filesystem::GetFullPath (ROUTER_KEYS).c_str (), std::ifstream::binary | std::ofstream::in);

3
RouterContext.h

@ -30,6 +30,8 @@ namespace i2p
void UpdateAddress (const char * host); // called from SSU void UpdateAddress (const char * host); // called from SSU
void AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag); void 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; };
void SetUnreachable ();
// implements LocalDestination // implements LocalDestination
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; }; const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
@ -51,6 +53,7 @@ namespace i2p
i2p::data::PrivateKeys m_Keys; i2p::data::PrivateKeys m_Keys;
CryptoPP::AutoSeededRandomPool m_Rnd; CryptoPP::AutoSeededRandomPool m_Rnd;
uint64_t m_LastUpdateTime; uint64_t m_LastUpdateTime;
bool m_IsUnreachable;
}; };
extern RouterContext context; extern RouterContext context;

2
SSU.cpp

@ -905,6 +905,8 @@ namespace ssu
m_IsRunning = true; m_IsRunning = true;
m_Thread = new std::thread (std::bind (&SSUServer::Run, this)); m_Thread = new std::thread (std::bind (&SSUServer::Run, this));
m_Service.post (boost::bind (&SSUServer::Receive, this)); m_Service.post (boost::bind (&SSUServer::Receive, this));
if (i2p::context.IsUnreachable ())
ScheduleIntroducersUpdateTimer ();
} }
void SSUServer::Stop () void SSUServer::Stop ()

Loading…
Cancel
Save