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. 3
      Config.cpp
  2. 6
      Daemon.cpp
  3. 11
      NetDb.cpp
  4. 6
      NetDb.h
  5. 1
      TunnelPool.cpp

3
Config.cpp

@ -211,7 +211,8 @@ namespace config { @@ -211,7 +211,8 @@ namespace config {
options_description trust("Trust options");
trust.add_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
.add(general)

6
Daemon.cpp

@ -204,6 +204,12 @@ namespace i2p @@ -204,6 +204,12 @@ namespace i2p
i2p::transport::transports.RestrictRoutes({fam});
} else
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;
}

11
NetDb.cpp

@ -24,7 +24,7 @@ namespace data @@ -24,7 +24,7 @@ namespace data
{
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)
{
}
@ -122,6 +122,10 @@ namespace data @@ -122,6 +122,10 @@ namespace data
}
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
{
Publish ();
@ -161,6 +165,11 @@ namespace data @@ -161,6 +165,11 @@ namespace data
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 updated = true;

6
NetDb.h

@ -67,6 +67,9 @@ namespace data @@ -67,6 +67,9 @@ namespace data
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 ();
Families& GetFamilies () { return m_Families; };
@ -112,6 +115,9 @@ namespace data @@ -112,6 +115,9 @@ namespace data
NetDbRequests m_Requests;
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;

1
TunnelPool.cpp

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

Loading…
Cancel
Save