Browse Source

don't limit num attempts in routing path. Increased routing path expiration to 2 minutes

pull/2094/head
orignal 4 months ago
parent
commit
f232c8f2df
  1. 7
      libi2pd/Garlic.cpp
  2. 4
      libi2pd/Garlic.h
  3. 2
      libi2pd/Streaming.cpp
  4. 4
      libi2pd_client/I2CP.cpp

7
libi2pd/Garlic.cpp

@ -45,22 +45,17 @@ namespace garlic
{ {
if (!m_SharedRoutingPath) return nullptr; if (!m_SharedRoutingPath) return nullptr;
uint32_t ts = i2p::util::GetSecondsSinceEpoch (); uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
if (m_SharedRoutingPath->numTimesUsed >= ROUTING_PATH_MAX_NUM_TIMES_USED || if (!m_SharedRoutingPath->outboundTunnel->IsEstablished () ||
!m_SharedRoutingPath->outboundTunnel->IsEstablished () ||
ts*1000LL > m_SharedRoutingPath->remoteLease->endDate || ts*1000LL > m_SharedRoutingPath->remoteLease->endDate ||
ts > m_SharedRoutingPath->updateTime + ROUTING_PATH_EXPIRATION_TIMEOUT) ts > m_SharedRoutingPath->updateTime + ROUTING_PATH_EXPIRATION_TIMEOUT)
m_SharedRoutingPath = nullptr; m_SharedRoutingPath = nullptr;
if (m_SharedRoutingPath) m_SharedRoutingPath->numTimesUsed++;
return m_SharedRoutingPath; return m_SharedRoutingPath;
} }
void GarlicRoutingSession::SetSharedRoutingPath (std::shared_ptr<GarlicRoutingPath> path) void GarlicRoutingSession::SetSharedRoutingPath (std::shared_ptr<GarlicRoutingPath> path)
{ {
if (path && path->outboundTunnel && path->remoteLease) if (path && path->outboundTunnel && path->remoteLease)
{
path->updateTime = i2p::util::GetSecondsSinceEpoch (); path->updateTime = i2p::util::GetSecondsSinceEpoch ();
path->numTimesUsed = 0;
}
else else
path = nullptr; path = nullptr;
m_SharedRoutingPath = path; m_SharedRoutingPath = path;

4
libi2pd/Garlic.h

@ -51,8 +51,7 @@ namespace garlic
const int OUTGOING_TAGS_EXPIRATION_TIMEOUT = 720; // 12 minutes const int OUTGOING_TAGS_EXPIRATION_TIMEOUT = 720; // 12 minutes
const int OUTGOING_TAGS_CONFIRMATION_TIMEOUT = 10; // 10 seconds const int OUTGOING_TAGS_CONFIRMATION_TIMEOUT = 10; // 10 seconds
const int LEASESET_CONFIRMATION_TIMEOUT = 4000; // in milliseconds const int LEASESET_CONFIRMATION_TIMEOUT = 4000; // in milliseconds
const int ROUTING_PATH_EXPIRATION_TIMEOUT = 30; // 30 seconds const int ROUTING_PATH_EXPIRATION_TIMEOUT = 120; // in seconds
const int ROUTING_PATH_MAX_NUM_TIMES_USED = 100; // how many times might be used
struct SessionTag: public i2p::data::Tag<32> struct SessionTag: public i2p::data::Tag<32>
{ {
@ -89,7 +88,6 @@ namespace garlic
std::shared_ptr<const i2p::data::Lease> remoteLease; std::shared_ptr<const i2p::data::Lease> remoteLease;
int rtt; // RTT int rtt; // RTT
uint32_t updateTime; // seconds since epoch uint32_t updateTime; // seconds since epoch
int numTimesUsed;
}; };
class GarlicDestination; class GarlicDestination;

2
libi2pd/Streaming.cpp

@ -520,7 +520,7 @@ namespace stream
if (firstRttSample && m_RoutingSession) if (firstRttSample && m_RoutingSession)
m_RoutingSession->SetSharedRoutingPath ( m_RoutingSession->SetSharedRoutingPath (
std::make_shared<i2p::garlic::GarlicRoutingPath> ( std::make_shared<i2p::garlic::GarlicRoutingPath> (
i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, (int)m_RTT, 0, 0})); i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, (int)m_RTT, 0}));
if (m_SentPackets.empty () && m_SendBuffer.IsEmpty ()) if (m_SentPackets.empty () && m_SendBuffer.IsEmpty ())
{ {
m_ResendTimer.cancel (); m_ResendTimer.cancel ();

4
libi2pd_client/I2CP.cpp

@ -202,7 +202,7 @@ namespace client
else else
remoteSession->SetSharedRoutingPath (nullptr); remoteSession->SetSharedRoutingPath (nullptr);
} }
else if (!outboundTunnel || !remoteLease)
{ {
auto leases = remote->GetNonExpiredLeases (false); // without threshold auto leases = remote->GetNonExpiredLeases (false); // without threshold
if (leases.empty ()) if (leases.empty ())
@ -216,7 +216,7 @@ namespace client
} }
if (remoteLease && outboundTunnel) if (remoteLease && outboundTunnel)
remoteSession->SetSharedRoutingPath (std::make_shared<i2p::garlic::GarlicRoutingPath> ( remoteSession->SetSharedRoutingPath (std::make_shared<i2p::garlic::GarlicRoutingPath> (
i2p::garlic::GarlicRoutingPath{outboundTunnel, remoteLease, 10000, 0, 0})); // 10 secs RTT i2p::garlic::GarlicRoutingPath{outboundTunnel, remoteLease, 10000, 0})); // 10 secs RTT
else else
remoteSession->SetSharedRoutingPath (nullptr); remoteSession->SetSharedRoutingPath (nullptr);
} }

Loading…
Cancel
Save