Browse Source

unreachable mode

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

3
Daemon.cpp

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

3
README.md

@ -48,7 +48,8 @@ Options @@ -48,7 +48,8 @@ Options
* --port= - The port to listen on
* --httpport= - The http port to listen on
* --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)
* --socksproxyport= - The port to listen on (SOCKS Proxy)
* --ircport= - The local port of IRC tunnel to listen on. 6668 by default

23
RouterContext.cpp

@ -12,7 +12,7 @@ namespace i2p @@ -12,7 +12,7 @@ namespace i2p
RouterContext context;
RouterContext::RouterContext ():
m_LastUpdateTime (0)
m_LastUpdateTime (0), m_IsUnreachable (false)
{
}
@ -100,7 +100,26 @@ namespace i2p @@ -100,7 +100,26 @@ namespace i2p
if (m_RouterInfo.RemoveIntroducer (e))
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 ()
{
std::ifstream fk (i2p::util::filesystem::GetFullPath (ROUTER_KEYS).c_str (), std::ifstream::binary | std::ofstream::in);

5
RouterContext.h

@ -30,7 +30,9 @@ namespace i2p @@ -30,7 +30,9 @@ namespace i2p
void UpdateAddress (const char * host); // called from SSU
void AddIntroducer (const i2p::data::RouterInfo& routerInfo, uint32_t tag);
void RemoveIntroducer (const boost::asio::ip::udp::endpoint& e);
bool IsUnreachable () const { return m_IsUnreachable; };
void SetUnreachable ();
// implements LocalDestination
const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; };
const uint8_t * GetEncryptionPrivateKey () const { return m_Keys.GetPrivateKey (); };
@ -51,6 +53,7 @@ namespace i2p @@ -51,6 +53,7 @@ namespace i2p
i2p::data::PrivateKeys m_Keys;
CryptoPP::AutoSeededRandomPool m_Rnd;
uint64_t m_LastUpdateTime;
bool m_IsUnreachable;
};
extern RouterContext context;

2
SSU.cpp

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

Loading…
Cancel
Save