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

This commit is contained in:
Jeff Becker 2016-06-18 11:10:58 -04:00
parent 004a93a841
commit 93deb37c94
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
5 changed files with 27 additions and 4 deletions

View File

@ -211,8 +211,9 @@ 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)
.add(limits)

View File

@ -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;
}

View File

@ -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)
{
}
@ -121,7 +121,11 @@ namespace data
ManageLookupResponses ();
}
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
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;

View File

@ -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
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;

View File

@ -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());