diff --git a/Garlic.cpp b/Garlic.cpp index c3c0e045..3521ffcf 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -247,7 +247,7 @@ namespace garlic size_t GarlicRoutingSession::CreateGarlicPayload (uint8_t * payload, std::shared_ptr msg, UnconfirmedTags * newTags) { - uint64_t ts = i2p::util::GetMillisecondsSinceEpoch () + 8000; // 8 sec + uint64_t ts = i2p::util::GetMillisecondsSinceEpoch (); uint32_t msgID; RAND_bytes ((uint8_t *)&msgID, 4); size_t size = 0; @@ -258,9 +258,11 @@ namespace garlic if (m_Owner) { // resubmit non-confirmed LeaseSet - if (m_LeaseSetUpdateStatus == eLeaseSetSubmitted && - i2p::util::GetMillisecondsSinceEpoch () > m_LeaseSetSubmissionTime + LEASET_CONFIRMATION_TIMEOUT) - m_LeaseSetUpdateStatus = eLeaseSetUpdated; + if (m_LeaseSetUpdateStatus == eLeaseSetSubmitted && ts > m_LeaseSetSubmissionTime + LEASET_CONFIRMATION_TIMEOUT) + { + m_LeaseSetUpdateStatus = eLeaseSetUpdated; + SetSharedRoutingPath (nullptr); // invalidate path since leaseset was not confirmed + } // attach DeviveryStatus if necessary if (newTags || m_LeaseSetUpdateStatus == eLeaseSetUpdated) // new tags created or leaseset updated @@ -286,7 +288,7 @@ namespace garlic { m_LeaseSetUpdateStatus = eLeaseSetSubmitted; m_LeaseSetUpdateMsgID = msgID; - m_LeaseSetSubmissionTime = i2p::util::GetMillisecondsSinceEpoch (); + m_LeaseSetSubmissionTime = ts; // clove if our leaseSet must be attached auto leaseSet = CreateDatabaseStoreMsg (m_Owner->GetLeaseSet ()); size += CreateGarlicClove (payload + size, leaseSet, false); @@ -303,7 +305,7 @@ namespace garlic size += 3; htobe32buf (payload + size, msgID); // MessageID size += 4; - htobe64buf (payload + size, ts); // Expiration of message + htobe64buf (payload + size, ts + 8000); // Expiration of message, 8 sec size += 8; return size; } diff --git a/Garlic.h b/Garlic.h index 6a92b94a..8d2e850a 100644 --- a/Garlic.h +++ b/Garlic.h @@ -104,6 +104,7 @@ namespace garlic { if (m_LeaseSetUpdateStatus != eLeaseSetDoNotSend) m_LeaseSetUpdateStatus = eLeaseSetUpdated; }; + bool IsLeaseSetNonConfirmed () const { return m_LeaseSetUpdateStatus == eLeaseSetSubmitted; }; std::shared_ptr GetSharedRoutingPath (); void SetSharedRoutingPath (std::shared_ptr path); diff --git a/Streaming.cpp b/Streaming.cpp index 1103dba1..e6f5b32f 100644 --- a/Streaming.cpp +++ b/Streaming.cpp @@ -736,7 +736,15 @@ namespace stream return; } if (m_Status == eStreamStatusOpen) + { + if (m_RoutingSession && m_RoutingSession->IsLeaseSetNonConfirmed ()) + { + // seems something went wrong and we should re-select tunnels + m_CurrentOutboundTunnel = nullptr; + m_CurrentRemoteLease = nullptr; + } SendQuickAck (); + } m_IsAckSendScheduled = false; } }