Browse Source

random remote lease selection for LeaseSet update

pull/690/head
orignal 8 years ago
parent
commit
c5e2ec5e00
  1. 23
      Streaming.cpp
  2. 2
      Streaming.h

23
Streaming.cpp

@ -661,24 +661,33 @@ namespace stream @@ -661,24 +661,33 @@ 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 ());
}
}
}

2
Streaming.h

@ -51,7 +51,7 @@ namespace stream @@ -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";

Loading…
Cancel
Save