mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-12 17:10:20 +03:00
resend relay reponnse if remote router >= 0.9.64
This commit is contained in:
parent
87ae9c4b74
commit
f611136ea7
@ -83,7 +83,7 @@ namespace transport
|
|||||||
std::shared_ptr<const i2p::data::RouterInfo::Address> addr, bool noise):
|
std::shared_ptr<const i2p::data::RouterInfo::Address> addr, bool noise):
|
||||||
TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT),
|
TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT),
|
||||||
m_Server (server), m_Address (addr), m_RemoteTransports (0), m_RemotePeerTestTransports (0),
|
m_Server (server), m_Address (addr), m_RemoteTransports (0), m_RemotePeerTestTransports (0),
|
||||||
m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown),
|
m_RemoteVersion (0), m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown),
|
||||||
m_SendPacketNum (0), m_ReceivePacketNum (0), m_LastDatetimeSentPacketNum (0),
|
m_SendPacketNum (0), m_ReceivePacketNum (0), m_LastDatetimeSentPacketNum (0),
|
||||||
m_IsDataReceived (false), m_RTT (SSU2_UNKNOWN_RTT),
|
m_IsDataReceived (false), m_RTT (SSU2_UNKNOWN_RTT),
|
||||||
m_MsgLocalExpirationTimeout (I2NP_MESSAGE_LOCAL_EXPIRATION_TIMEOUT_MAX),
|
m_MsgLocalExpirationTimeout (I2NP_MESSAGE_LOCAL_EXPIRATION_TIMEOUT_MAX),
|
||||||
@ -103,6 +103,7 @@ namespace transport
|
|||||||
InitNoiseXKState1 (*m_NoiseState, m_Address->s);
|
InitNoiseXKState1 (*m_NoiseState, m_Address->s);
|
||||||
m_RemoteEndpoint = boost::asio::ip::udp::endpoint (m_Address->host, m_Address->port);
|
m_RemoteEndpoint = boost::asio::ip::udp::endpoint (m_Address->host, m_Address->port);
|
||||||
m_RemoteTransports = in_RemoteRouter->GetCompatibleTransports (false);
|
m_RemoteTransports = in_RemoteRouter->GetCompatibleTransports (false);
|
||||||
|
m_RemoteVersion = in_RemoteRouter->GetVersion ();
|
||||||
if (in_RemoteRouter->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4;
|
if (in_RemoteRouter->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4;
|
||||||
if (in_RemoteRouter->IsSSU2PeerTesting (false)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V6;
|
if (in_RemoteRouter->IsSSU2PeerTesting (false)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V6;
|
||||||
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
|
RAND_bytes ((uint8_t *)&m_DestConnID, 8);
|
||||||
@ -1185,7 +1186,8 @@ namespace transport
|
|||||||
m_RemotePeerTestTransports = 0;
|
m_RemotePeerTestTransports = 0;
|
||||||
if (ri->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4;
|
if (ri->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4;
|
||||||
if (ri->IsSSU2PeerTesting (false)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V6;
|
if (ri->IsSSU2PeerTesting (false)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V6;
|
||||||
|
m_RemoteVersion = ri->GetVersion ();
|
||||||
|
|
||||||
// handle other blocks
|
// handle other blocks
|
||||||
HandlePayload (decryptedPayload.data () + riSize + 3, decryptedPayload.size () - riSize - 3);
|
HandlePayload (decryptedPayload.data () + riSize + 3, decryptedPayload.size () - riSize - 3);
|
||||||
Established ();
|
Established ();
|
||||||
@ -2037,11 +2039,13 @@ namespace transport
|
|||||||
holePunchSession->SendHolePunch (packet->payload, packet->payloadSize); // relay response block
|
holePunchSession->SendHolePunch (packet->payload, packet->payloadSize); // relay response block
|
||||||
}
|
}
|
||||||
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
packet->payloadSize += CreatePaddingBlock (packet->payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
||||||
/*uint32_t packetNum = */SendData (packet->payload, packet->payloadSize);
|
uint32_t packetNum = SendData (packet->payload, packet->payloadSize);
|
||||||
// sometimes Bob doesn't ack this RelayResponse
|
if (m_RemoteVersion >= SSU2_MIN_RELAY_RESPONSE_RESEND_VERSION)
|
||||||
// TODO: uncomment line below once the problem is resolved
|
{
|
||||||
//packet->sendTime = mts;
|
// sometimes Bob doesn't ack this RelayResponse in older versions
|
||||||
//m_SentPackets.emplace (packetNum, packet);
|
packet->sendTime = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
|
m_SentPackets.emplace (packetNum, packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSU2Session::HandleRelayResponse (const uint8_t * buf, size_t len)
|
void SSU2Session::HandleRelayResponse (const uint8_t * buf, size_t len)
|
||||||
@ -2076,11 +2080,13 @@ namespace transport
|
|||||||
memcpy (payload + 3, buf, len); // forward to Alice as is
|
memcpy (payload + 3, buf, len); // forward to Alice as is
|
||||||
packet->payloadSize = len + 3;
|
packet->payloadSize = len + 3;
|
||||||
packet->payloadSize += CreatePaddingBlock (payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
packet->payloadSize += CreatePaddingBlock (payload + packet->payloadSize, m_MaxPayloadSize - packet->payloadSize);
|
||||||
/*uint32_t packetNum = */it->second.first->SendData (packet->payload, packet->payloadSize);
|
uint32_t packetNum = it->second.first->SendData (packet->payload, packet->payloadSize);
|
||||||
// sometimes Alice doesn't ack this RelayResponse
|
if (m_RemoteVersion >= SSU2_MIN_RELAY_RESPONSE_RESEND_VERSION)
|
||||||
// TODO: uncomment line below once the problem is resolved
|
{
|
||||||
//packet->sendTime = i2p::util::GetMillisecondsSinceEpoch ();
|
// sometimes Alice doesn't ack this RelayResponse in older versions
|
||||||
//it->second.first->m_SentPackets.emplace (packetNum, packet);
|
packet->sendTime = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
|
it->second.first->m_SentPackets.emplace (packetNum, packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
#include "version.h"
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
#include "RouterContext.h"
|
#include "RouterContext.h"
|
||||||
@ -55,6 +56,7 @@ namespace transport
|
|||||||
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
const int SSU2_MAX_NUM_ACK_RANGES = 32; // to send
|
||||||
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
|
const uint8_t SSU2_MAX_NUM_FRAGMENTS = 64;
|
||||||
const int SSU2_SEND_DATETIME_NUM_PACKETS = 256;
|
const int SSU2_SEND_DATETIME_NUM_PACKETS = 256;
|
||||||
|
const int SSU2_MIN_RELAY_RESPONSE_RESEND_VERSION = MAKE_VERSION_NUMBER(0, 9, 64); // 0.9.64
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
const uint8_t SSU2_FLAG_IMMEDIATE_ACK_REQUESTED = 0x01;
|
const uint8_t SSU2_FLAG_IMMEDIATE_ACK_REQUESTED = 0x01;
|
||||||
@ -368,6 +370,7 @@ namespace transport
|
|||||||
std::shared_ptr<const i2p::data::RouterInfo::Address> m_Address;
|
std::shared_ptr<const i2p::data::RouterInfo::Address> m_Address;
|
||||||
boost::asio::ip::udp::endpoint m_RemoteEndpoint;
|
boost::asio::ip::udp::endpoint m_RemoteEndpoint;
|
||||||
i2p::data::RouterInfo::CompatibleTransports m_RemoteTransports, m_RemotePeerTestTransports;
|
i2p::data::RouterInfo::CompatibleTransports m_RemoteTransports, m_RemotePeerTestTransports;
|
||||||
|
int m_RemoteVersion;
|
||||||
uint64_t m_DestConnID, m_SourceConnID;
|
uint64_t m_DestConnID, m_SourceConnID;
|
||||||
SSU2SessionState m_State;
|
SSU2SessionState m_State;
|
||||||
uint8_t m_KeyDataSend[64], m_KeyDataReceive[64];
|
uint8_t m_KeyDataSend[64], m_KeyDataReceive[64];
|
||||||
|
Loading…
Reference in New Issue
Block a user