mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
check minimal router version for connected peer selection
This commit is contained in:
parent
32ab95478e
commit
0df895b6a7
@ -131,6 +131,17 @@ namespace transport
|
|||||||
LogPrint(eLogError, "Transports: Return null DHKeys");
|
LogPrint(eLogError, "Transports: Return null DHKeys");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Peer::UpdateParams (std::shared_ptr<const i2p::data::RouterInfo> router)
|
||||||
|
{
|
||||||
|
if (router)
|
||||||
|
{
|
||||||
|
isHighBandwidth = router->IsHighBandwidth ();
|
||||||
|
isEligible =(bool)router->GetCompatibleTransports (true) && // reachable
|
||||||
|
router->GetCongestion () != i2p::data::RouterInfo::eRejectAll && // accepts tunnel
|
||||||
|
router->IsECIES () && router->GetVersion () >= NETDB_MIN_HIGHBANDWIDTH_VERSION; // not too old
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Transports transports;
|
Transports transports;
|
||||||
|
|
||||||
Transports::Transports ():
|
Transports::Transports ():
|
||||||
|
@ -79,12 +79,7 @@ namespace transport
|
|||||||
nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL),
|
nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL),
|
||||||
isHighBandwidth (false), isEligible (false)
|
isHighBandwidth (false), isEligible (false)
|
||||||
{
|
{
|
||||||
if (router)
|
UpdateParams (router);
|
||||||
{
|
|
||||||
isHighBandwidth = router->IsHighBandwidth ();
|
|
||||||
isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable
|
|
||||||
router->GetCongestion () != i2p::data::RouterInfo::eRejectAll;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Done ()
|
void Done ()
|
||||||
@ -99,15 +94,11 @@ namespace transport
|
|||||||
void SetRouter (std::shared_ptr<const i2p::data::RouterInfo> r)
|
void SetRouter (std::shared_ptr<const i2p::data::RouterInfo> r)
|
||||||
{
|
{
|
||||||
router = r;
|
router = r;
|
||||||
if (router)
|
UpdateParams (router);
|
||||||
{
|
|
||||||
isHighBandwidth = router->IsHighBandwidth ();
|
|
||||||
isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable
|
|
||||||
router->GetCongestion () != i2p::data::RouterInfo::eRejectAll;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsConnected () const { return !sessions.empty (); }
|
bool IsConnected () const { return !sessions.empty (); }
|
||||||
|
void UpdateParams (std::shared_ptr<const i2p::data::RouterInfo> router);
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint64_t SESSION_CREATION_TIMEOUT = 15; // in seconds
|
const uint64_t SESSION_CREATION_TIMEOUT = 15; // in seconds
|
||||||
|
Loading…
Reference in New Issue
Block a user