mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-25 23:44:18 +00:00
select different routers for peer test
This commit is contained in:
parent
5edb256990
commit
d5b61ed544
@ -1149,12 +1149,13 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomPeerTestRouter (bool v4) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomPeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
[v4](std::shared_ptr<const RouterInfo> router)->bool
|
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
{
|
{
|
||||||
return !router->IsHidden () && router->IsPeerTesting (v4);
|
return !router->IsHidden () && router->IsPeerTesting (v4) &&
|
||||||
|
!excluded.count (router->GetIdentHash ());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,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, bool reverse) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4) const;
|
std::shared_ptr<const RouterInfo> GetRandomPeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomSSUV6Router () const; // TODO: change to v6 peer test later
|
std::shared_ptr<const RouterInfo> GetRandomSSUV6Router () const; // TODO: change to v6 peer test later
|
||||||
std::shared_ptr<const RouterInfo> GetRandomIntroducer () const;
|
std::shared_ptr<const RouterInfo> GetRandomIntroducer () const;
|
||||||
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
||||||
|
@ -587,10 +587,11 @@ namespace transport
|
|||||||
if (i2p::context.SupportsV4 ())
|
if (i2p::context.SupportsV4 ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Transports: Started peer test ipv4");
|
LogPrint (eLogInfo, "Transports: Started peer test ipv4");
|
||||||
|
std::set<i2p::data::IdentHash> excluded;
|
||||||
bool statusChanged = false;
|
bool statusChanged = false;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
auto router = i2p::data::netdb.GetRandomPeerTestRouter (true); // v4
|
auto router = i2p::data::netdb.GetRandomPeerTestRouter (true, excluded); // v4
|
||||||
if (router)
|
if (router)
|
||||||
{
|
{
|
||||||
auto addr = router->GetSSUAddress (true); // ipv4
|
auto addr = router->GetSSUAddress (true); // ipv4
|
||||||
@ -601,8 +602,9 @@ namespace transport
|
|||||||
statusChanged = true;
|
statusChanged = true;
|
||||||
i2p::context.SetStatus (eRouterStatusTesting); // first time only
|
i2p::context.SetStatus (eRouterStatusTesting); // first time only
|
||||||
}
|
}
|
||||||
m_SSUServer->CreateSession (router, addr, true); // peer test v4
|
m_SSUServer->CreateSession (router, addr, true); // peer test v4
|
||||||
}
|
}
|
||||||
|
excluded.insert (router->GetIdentHash ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!statusChanged)
|
if (!statusChanged)
|
||||||
@ -611,10 +613,11 @@ namespace transport
|
|||||||
if (i2p::context.SupportsV6 ())
|
if (i2p::context.SupportsV6 ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Transports: Started peer test ipv6");
|
LogPrint (eLogInfo, "Transports: Started peer test ipv6");
|
||||||
|
std::set<i2p::data::IdentHash> excluded;
|
||||||
bool statusChanged = false;
|
bool statusChanged = false;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
auto router = i2p::data::netdb.GetRandomPeerTestRouter (false); // v6
|
auto router = i2p::data::netdb.GetRandomPeerTestRouter (false, excluded); // v6
|
||||||
if (router)
|
if (router)
|
||||||
{
|
{
|
||||||
auto addr = router->GetSSUV6Address ();
|
auto addr = router->GetSSUV6Address ();
|
||||||
@ -627,6 +630,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
m_SSUServer->CreateSession (router, addr, true); // peer test v6
|
m_SSUServer->CreateSession (router, addr, true); // peer test v6
|
||||||
}
|
}
|
||||||
|
excluded.insert (router->GetIdentHash ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!statusChanged)
|
if (!statusChanged)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user