mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-27 21:34:17 +00:00
select peer test capable routers
This commit is contained in:
parent
30715c2512
commit
582daffd7f
@ -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
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);
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user