Browse Source

select peer test capable routers

pull/163/head
orignal 10 years ago
parent
commit
582daffd7f
  1. 9
      NetDb.cpp
  2. 1
      NetDb.h
  3. 24
      Transports.cpp

9
NetDb.cpp

@ -885,6 +885,15 @@ namespace data
}); });
} }
std::shared_ptr<const RouterInfo> NetDb::GetRandomPeerTestRouter () const
{
return GetRandomRouter (
[](std::shared_ptr<const RouterInfo> router)->bool
{
return !router->IsHidden () && router->IsPeerTesting ();
});
}
std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const
{ {
return GetRandomRouter ( return GetRandomRouter (

1
NetDb.h

@ -80,6 +80,7 @@ namespace data
std::shared_ptr<const RouterInfo> GetRandomRouter () const; std::shared_ptr<const RouterInfo> GetRandomRouter () const;
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const; std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const; std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter () const;
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const; std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
std::shared_ptr<const RouterInfo> GetClosestNonFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const; std::shared_ptr<const RouterInfo> GetClosestNonFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
void SetUnreachable (const IdentHash& ident, bool unreachable); void SetUnreachable (const IdentHash& ident, bool unreachable);

24
Transports.cpp

@ -384,13 +384,25 @@ namespace transport
void Transports::DetectExternalIP () void Transports::DetectExternalIP ()
{ {
i2p::context.SetStatus (eRouterStatusTesting); if (m_SSUServer)
for (int i = 0; i < 5; i++)
{ {
auto router = i2p::data::netdb.GetRandomRouter (); i2p::context.SetStatus (eRouterStatusTesting);
if (router && router->IsSSU () && m_SSUServer) for (int i = 0; i < 5; i++)
m_SSUServer->GetSession (router, true); // peer test {
} auto router = i2p::data::netdb.GetRandomPeerTestRouter ();
if (router)
m_SSUServer->GetSession (router, true); // peer test
else
{
// if not peer test capable routers found pick any
router = i2p::data::netdb.GetRandomRouter ();
if (router && router->IsSSU ())
m_SSUServer->GetSession (router); // no peer test
}
}
}
else
LogPrint (eLogError, "Can't detect external IP. SSU is not available");
} }
DHKeysPair * Transports::GetNextDHKeysPair () DHKeysPair * Transports::GetNextDHKeysPair ()

Loading…
Cancel
Save