Browse Source

add primordial goo tier "hidden mode" (aka toy feature needs more work doesn't do it correctly all the way)

pull/557/head
Jeff Becker 9 years ago
parent
commit
93deb37c94
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 5
      Config.cpp
  2. 6
      Daemon.cpp
  3. 13
      NetDb.cpp
  4. 6
      NetDb.h
  5. 1
      TunnelPool.cpp

5
Config.cpp

@ -211,8 +211,9 @@ namespace config {
options_description trust("Trust options"); options_description trust("Trust options");
trust.add_options() trust.add_options()
("trust.enabled", value<bool>()->default_value(false), "enable explicit trust options") ("trust.enabled", value<bool>()->default_value(false), "enable explicit trust options")
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops"); ("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
("trust.hidden", value<bool>()->default_value(false), "should we hide our router from other routers?");
m_OptionsDesc m_OptionsDesc
.add(general) .add(general)
.add(limits) .add(limits)

6
Daemon.cpp

@ -204,6 +204,12 @@ namespace i2p
i2p::transport::transports.RestrictRoutes({fam}); i2p::transport::transports.RestrictRoutes({fam});
} else } else
LogPrint(eLogError, "Daemon: no family specified for restricted routes"); LogPrint(eLogError, "Daemon: no family specified for restricted routes");
}
bool hidden; i2p::config::GetOption("trust.hidden", hidden);
if (hidden)
{
LogPrint(eLogInfo, "Daemon: using hidden mode");
i2p::data::netdb.SetHidden(true);
} }
return true; return true;
} }

13
NetDb.cpp

@ -24,7 +24,7 @@ namespace data
{ {
NetDb netdb; NetDb netdb;
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr), m_Storage("netDb", "r", "routerInfo-", "dat") NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr), m_Storage("netDb", "r", "routerInfo-", "dat"), m_HiddenMode(false)
{ {
} }
@ -121,7 +121,11 @@ namespace data
ManageLookupResponses (); ManageLookupResponses ();
} }
lastSave = ts; lastSave = ts;
} }
// if we're in hidden mode don't publish or explore
if (m_HiddenMode) continue;
if (ts - lastPublish >= 2400) // publish every 40 minutes if (ts - lastPublish >= 2400) // publish every 40 minutes
{ {
Publish (); Publish ();
@ -161,6 +165,11 @@ namespace data
return false; return false;
} }
void NetDb::SetHidden(bool hide) {
// TODO: remove reachable addresses from router info
m_HiddenMode = hide;
}
bool NetDb::AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len) bool NetDb::AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len)
{ {
bool updated = true; bool updated = true;

6
NetDb.h

@ -67,6 +67,9 @@ namespace data
void PostI2NPMsg (std::shared_ptr<const I2NPMessage> msg); void PostI2NPMsg (std::shared_ptr<const I2NPMessage> msg);
/** set hidden mode, aka don't publish our RI to netdb and don't explore */
void SetHidden(bool hide);
void Reseed (); void Reseed ();
Families& GetFamilies () { return m_Families; }; Families& GetFamilies () { return m_Families; };
@ -112,6 +115,9 @@ namespace data
NetDbRequests m_Requests; NetDbRequests m_Requests;
std::map<IdentHash, std::pair<std::vector<IdentHash>, uint64_t> > m_LookupResponses; // ident->(closest FFs, timestamp) std::map<IdentHash, std::pair<std::vector<IdentHash>, uint64_t> > m_LookupResponses; // ident->(closest FFs, timestamp)
/** true if in hidden mode */
bool m_HiddenMode;
}; };
extern NetDb netdb; extern NetDb netdb;

1
TunnelPool.cpp

@ -333,6 +333,7 @@ namespace tunnel
int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops; int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
if(i2p::transport::transports.RoutesRestricted()) if(i2p::transport::transports.RoutesRestricted())
{ {
/** if routes are restricted prepend trusted first hop */
auto hop = i2p::transport::transports.GetRestrictedPeer(); auto hop = i2p::transport::transports.GetRestrictedPeer();
if(!hop) return false; if(!hop) return false;
peers.push_back(hop->GetRouterIdentity()); peers.push_back(hop->GetRouterIdentity());

Loading…
Cancel
Save