Browse Source

check crypto type and congestion of connected peer for tunnel

pull/2095/head
orignal 3 months ago
parent
commit
32ab95478e
  1. 2
      libi2pd/Transports.cpp
  2. 10
      libi2pd/Transports.h

2
libi2pd/Transports.cpp

@ -1055,7 +1055,7 @@ namespace transport
[isHighBandwidth](std::shared_ptr<const Peer> peer)->bool [isHighBandwidth](std::shared_ptr<const Peer> peer)->bool
{ {
// connected, not overloaded and not slow // connected, not overloaded and not slow
return !peer->router && peer->IsConnected () && peer->isReachable && return !peer->router && peer->IsConnected () && peer->isEligible &&
peer->sessions.front ()->GetSendQueueSize () <= PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE && peer->sessions.front ()->GetSendQueueSize () <= PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE &&
!peer->sessions.front ()->IsSlow () && !peer->sessions.front ()->IsBandwidthExceeded (peer->isHighBandwidth) && !peer->sessions.front ()->IsSlow () && !peer->sessions.front ()->IsBandwidthExceeded (peer->isHighBandwidth) &&
(!isHighBandwidth || peer->isHighBandwidth); (!isHighBandwidth || peer->isHighBandwidth);

10
libi2pd/Transports.h

@ -72,17 +72,18 @@ namespace transport
uint64_t creationTime, nextRouterInfoUpdateTime; uint64_t creationTime, nextRouterInfoUpdateTime;
std::vector<std::shared_ptr<i2p::I2NPMessage> > delayedMessages; std::vector<std::shared_ptr<i2p::I2NPMessage> > delayedMessages;
std::vector<i2p::data::RouterInfo::SupportedTransports> priority; std::vector<i2p::data::RouterInfo::SupportedTransports> priority;
bool isHighBandwidth, isReachable; bool isHighBandwidth, isEligible;
Peer (std::shared_ptr<const i2p::data::RouterInfo> r, uint64_t ts): Peer (std::shared_ptr<const i2p::data::RouterInfo> r, uint64_t ts):
numAttempts (0), router (r), creationTime (ts), numAttempts (0), router (r), creationTime (ts),
nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL), nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL),
isHighBandwidth (false), isReachable (false) isHighBandwidth (false), isEligible (false)
{ {
if (router) if (router)
{ {
isHighBandwidth = router->IsHighBandwidth (); isHighBandwidth = router->IsHighBandwidth ();
isReachable = (bool)router->GetCompatibleTransports (true); isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable
router->GetCongestion () != i2p::data::RouterInfo::eRejectAll;
} }
} }
@ -101,7 +102,8 @@ namespace transport
if (router) if (router)
{ {
isHighBandwidth = router->IsHighBandwidth (); isHighBandwidth = router->IsHighBandwidth ();
isReachable = (bool)router->GetCompatibleTransports (true); isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable
router->GetCongestion () != i2p::data::RouterInfo::eRejectAll;
} }
} }

Loading…
Cancel
Save