|
|
@ -661,33 +661,25 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
void Stream::SendUpdatedLeaseSet () |
|
|
|
void Stream::SendUpdatedLeaseSet () |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_RoutingSession && m_RemoteLeaseSet && |
|
|
|
if (m_RoutingSession) |
|
|
|
(m_RoutingSession->IsLeaseSetUpdated () || m_RoutingSession->IsLeaseSetNonConfirmed ())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto leases = m_RemoteLeaseSet->GetNonExpiredLeases (true); // with threshold
|
|
|
|
|
|
|
|
if (!leases.empty ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto outboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (); |
|
|
|
|
|
|
|
if (outboundTunnel) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
auto lease = leases[rand () % leases.size ()]; |
|
|
|
if (m_RoutingSession->IsLeaseSetNonConfirmed ()) |
|
|
|
auto msg = m_RoutingSession->WrapSingleMessage (nullptr); |
|
|
|
|
|
|
|
outboundTunnel->SendTunnelDataMsg ( |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::tunnel::TunnelMessageBlock |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
|
|
|
|
if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASET_CONFIRMATION_TIMEOUT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::tunnel::eDeliveryTypeTunnel, |
|
|
|
// LeaseSet was not confirmed, should try other tunnels
|
|
|
|
lease->tunnelGateway, lease->tunnelID, |
|
|
|
LogPrint (eLogWarning, "Streaming: LeaseSet was not confrimed in ", i2p::garlic::LEASET_CONFIRMATION_TIMEOUT, " milliseconds. Trying to resubmit"); |
|
|
|
msg |
|
|
|
m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
} |
|
|
|
m_CurrentOutboundTunnel = nullptr; |
|
|
|
}); |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
LogPrint (eLogDebug, "Streaming: Updated LeaseSet sent. sSID=", m_SendStreamID); |
|
|
|
SendQuickAck (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else if (m_RoutingSession->IsLeaseSetUpdated ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Streaming: Can't sent updated LeaseSet. Remote LeaseSet expired. sSID=", m_SendStreamID); |
|
|
|
LogPrint (eLogDebug, "Streaming: sending updated LeaseSet"); |
|
|
|
m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); |
|
|
|
SendQuickAck (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|