Browse Source

exploratory if tunnels are not created yet

pull/73/head
orignal 11 years ago
parent
commit
d6b97670c4
  1. 5
      HTTPServer.cpp
  2. 32
      NetDb.cpp
  3. 6
      NetDb.h

5
HTTPServer.cpp

@ -238,7 +238,7 @@ namespace util
void HTTPConnection::FillContent (std::stringstream& s) void HTTPConnection::FillContent (std::stringstream& s)
{ {
s << "Data path: " << i2p::util::filesystem::GetDataDir().string() << "<BR>" << "<BR>"; s << "Data path: " << i2p::util::filesystem::GetDataDir().string() << "<BR>" << "<BR>";
s << "Our external address:" << "<BR>" << "<BR>"; s << "Our external address:" << "<BR>";
for (auto& address : i2p::context.GetRouterInfo().GetAddresses()) for (auto& address : i2p::context.GetRouterInfo().GetAddresses())
{ {
switch (address.transportStyle) switch (address.transportStyle)
@ -254,6 +254,9 @@ namespace util
} }
s << address.host.to_string() << ":" << address.port << "<BR>"; s << address.host.to_string() << ":" << address.port << "<BR>";
} }
s << "<BR>Routers: " << i2p::data::netdb.GetNumRouters () << " ";
s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " ";
s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "<BR>";
s << "<P>Tunnels</P>"; s << "<P>Tunnels</P>";
for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ()) for (auto it: i2p::tunnel::tunnels.GetOutboundTunnels ())

32
NetDb.cpp

@ -534,20 +534,20 @@ namespace data
void NetDb::Explore () void NetDb::Explore ()
{ {
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool (); CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr; uint8_t randomHash[32];
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr; rnd.GenerateBlock (randomHash, 32);
if (outbound && inbound) RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true);
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
if (floodfill)
{ {
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); LogPrint ("Exploring new routers ...");
uint8_t randomHash[32]; auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
rnd.GenerateBlock (randomHash, 32); auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true); auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
dest->SetLastOutboundTunnel (outbound); if (outbound && inbound)
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
if (floodfill)
{ {
LogPrint ("Exploring new routers ..."); dest->SetLastOutboundTunnel (outbound);
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
msgs.push_back (i2p::tunnel::TunnelMessageBlock msgs.push_back (i2p::tunnel::TunnelMessageBlock
{ {
@ -564,8 +564,14 @@ namespace data
outbound->SendTunnelDataMsg (msgs); outbound->SendTunnelDataMsg (msgs);
} }
else else
DeleteRequestedDestination (dest); {
dest->SetLastOutboundTunnel (nullptr);
dest->SetLastReplyTunnel (nullptr);
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
}
} }
else
DeleteRequestedDestination (dest);
} }
void NetDb::Publish () void NetDb::Publish ()

6
NetDb.h

@ -33,6 +33,7 @@ namespace data
void ClearExcludedPeers (); void ClearExcludedPeers ();
const RouterInfo * GetLastRouter () const { return m_LastRouter; }; const RouterInfo * GetLastRouter () const { return m_LastRouter; };
const i2p::tunnel::InboundTunnel * GetLastReplyTunnel () const { return m_LastReplyTunnel; }; const i2p::tunnel::InboundTunnel * GetLastReplyTunnel () const { return m_LastReplyTunnel; };
void SetLastReplyTunnel (i2p::tunnel::InboundTunnel * tunnel) { m_LastReplyTunnel = tunnel; };
bool IsExploratory () const { return m_IsExploratory; }; bool IsExploratory () const { return m_IsExploratory; };
bool IsLeaseSet () const { return m_IsLeaseSet; }; bool IsLeaseSet () const { return m_IsLeaseSet; };
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); }; bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
@ -79,6 +80,11 @@ namespace data
void PostI2NPMsg (I2NPMessage * msg); void PostI2NPMsg (I2NPMessage * msg);
// for web interface
int GetNumRouters () const { return m_RouterInfos.size (); };
int GetNumFloodfills () const { return m_Floodfills.size (); };
int GetNumLeaseSets () const { return m_LeaseSets.size (); };
private: private:
bool CreateNetDb(boost::filesystem::path directory); bool CreateNetDb(boost::filesystem::path directory);

Loading…
Cancel
Save