|
|
|
@ -21,7 +21,8 @@ namespace stream
@@ -21,7 +21,8 @@ namespace stream
|
|
|
|
|
const i2p::data::LeaseSet& remote): m_Service (service), m_SendStreamID (0), |
|
|
|
|
m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), m_IsOpen (false), |
|
|
|
|
m_LeaseSetUpdated (true), m_LocalDestination (local), |
|
|
|
|
m_RemoteLeaseSet (&remote), m_ReceiveTimer (m_Service), m_ResendTimer (m_Service) |
|
|
|
|
m_RemoteLeaseSet (&remote), m_CurrentOutboundTunnel (nullptr), |
|
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service) |
|
|
|
|
{ |
|
|
|
|
m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); |
|
|
|
|
UpdateCurrentRemoteLease (); |
|
|
|
@ -30,7 +31,8 @@ namespace stream
@@ -30,7 +31,8 @@ namespace stream
|
|
|
|
|
Stream::Stream (boost::asio::io_service& service, StreamingDestination * local): |
|
|
|
|
m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), |
|
|
|
|
m_IsOpen (false), m_LeaseSetUpdated (true), m_LocalDestination (local), |
|
|
|
|
m_RemoteLeaseSet (nullptr), m_ReceiveTimer (m_Service), m_ResendTimer (m_Service) |
|
|
|
|
m_RemoteLeaseSet (nullptr), m_CurrentOutboundTunnel (nullptr), |
|
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service) |
|
|
|
|
{ |
|
|
|
|
m_RecvStreamID = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); |
|
|
|
|
} |
|
|
|
@ -102,6 +104,7 @@ namespace stream
@@ -102,6 +104,7 @@ namespace stream
|
|
|
|
|
{ |
|
|
|
|
// we have received duplicate. Most likely our outbound tunnel is dead
|
|
|
|
|
LogPrint ("Duplicate message ", receivedSeqn, " received"); |
|
|
|
|
m_CurrentOutboundTunnel = nullptr; // pick another outbound tunnel
|
|
|
|
|
UpdateCurrentRemoteLease (); // pick another lease
|
|
|
|
|
SendQuickAck (); // resend ack for previous message again
|
|
|
|
|
delete packet; // packet dropped
|
|
|
|
@ -401,8 +404,8 @@ namespace stream
@@ -401,8 +404,8 @@ namespace stream
|
|
|
|
|
m_LeaseSetUpdated = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto outboundTunnel = m_LocalDestination->GetTunnelPool ()->GetNextOutboundTunnel (); |
|
|
|
|
if (outboundTunnel) |
|
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination->GetTunnelPool ()->GetNextOutboundTunnel (m_CurrentOutboundTunnel); |
|
|
|
|
if (m_CurrentOutboundTunnel) |
|
|
|
|
{ |
|
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
|
if (ts >= m_CurrentRemoteLease.endDate) |
|
|
|
@ -422,7 +425,7 @@ namespace stream
@@ -422,7 +425,7 @@ namespace stream
|
|
|
|
|
}); |
|
|
|
|
leaseSet = nullptr; // send leaseSet only one time
|
|
|
|
|
} |
|
|
|
|
outboundTunnel->SendTunnelDataMsg (msgs); |
|
|
|
|
m_CurrentOutboundTunnel->SendTunnelDataMsg (msgs); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
LogPrint ("All leases are expired"); |
|
|
|
@ -458,6 +461,7 @@ namespace stream
@@ -458,6 +461,7 @@ namespace stream
|
|
|
|
|
} |
|
|
|
|
if (packets.size () > 0) |
|
|
|
|
{ |
|
|
|
|
m_CurrentOutboundTunnel = nullptr; // pick another outbound tunnel
|
|
|
|
|
UpdateCurrentRemoteLease (); // pick another lease
|
|
|
|
|
SendPackets (packets); |
|
|
|
|
} |
|
|
|
|