diff --git a/Streaming.cpp b/Streaming.cpp index 78465b87..31787087 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -661,25 +661,34 @@ namespace stream void Stream::SendUpdatedLeaseSet () { - if (m_RoutingSession && m_RoutingSession->IsLeaseSetUpdated ()) + if (m_RoutingSession && m_RemoteLeaseSet && + (m_RoutingSession->IsLeaseSetUpdated () || m_RoutingSession->IsLeaseSetNonConfirmed ())) { - if (!m_CurrentRemoteLease) - UpdateCurrentRemoteLease (true); - if (m_CurrentRemoteLease) + auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (true); // with threshold + if (leases.empty ()) { - auto msg = m_RoutingSession->WrapSingleMessage (nullptr); auto outboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (); if (outboundTunnel) - m_CurrentOutboundTunnel->SendTunnelDataMsg ( + { + auto lease = leases[rand () % leases.size ()]; + auto msg = m_RoutingSession->WrapSingleMessage (nullptr); + outboundTunnel->SendTunnelDataMsg ( { i2p::tunnel::TunnelMessageBlock { i2p::tunnel::eDeliveryTypeTunnel, - m_CurrentRemoteLease->tunnelGateway, m_CurrentRemoteLease->tunnelID, + lease->tunnelGateway, lease->tunnelID, msg } }); + LogPrint (eLogDebug, "Streaming: Updated LeaseSet sent. sSID=", m_SendStreamID); + } } + else + { + LogPrint (eLogWarning, "Streaming: Can't sent updated LeaseSet. Remote LeaseSet expired. sSID=", m_SendStreamID); + m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); + } } } diff --git a/Streaming.h b/Streaming.h index 75ce4c56..2be724ed 100644 --- a/Streaming.h +++ b/Streaming.h @@ -51,7 +51,7 @@ namespace stream const int INITIAL_RTO = 9000; // in milliseconds const size_t MAX_PENDING_INCOMING_BACKLOG = 128; const int PENDING_INCOMING_TIMEOUT = 10; // in seconds - const int MAX_RECEIVE_TIMEOUT = 60; // in seconds + const int MAX_RECEIVE_TIMEOUT = 30; // in seconds /** i2cp option for limiting inbound stremaing connections */ const char I2CP_PARAM_STREAMING_MAX_CONNS_PER_MIN[] = "maxconns";