|
|
@ -81,7 +81,7 @@ namespace transport |
|
|
|
SSU2Session::SSU2Session (SSU2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter, |
|
|
|
SSU2Session::SSU2Session (SSU2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter, |
|
|
|
std::shared_ptr<const i2p::data::RouterInfo::Address> addr): |
|
|
|
std::shared_ptr<const i2p::data::RouterInfo::Address> addr): |
|
|
|
TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT), |
|
|
|
TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT), |
|
|
|
m_Server (server), m_Address (addr), m_RemoteTransports (0), |
|
|
|
m_Server (server), m_Address (addr), m_RemoteTransports (0), m_RemotePeerTestTransports (0), |
|
|
|
m_DestConnID (0), m_SourceConnID (0), m_State (eSSU2SessionStateUnknown), |
|
|
|
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_WindowSize (SSU2_MIN_WINDOW_SIZE), |
|
|
|
m_IsDataReceived (false), m_WindowSize (SSU2_MIN_WINDOW_SIZE), |
|
|
@ -96,6 +96,8 @@ 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); |
|
|
|
|
|
|
|
if (in_RemoteRouter->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4; |
|
|
|
|
|
|
|
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); |
|
|
|
RAND_bytes ((uint8_t *)&m_SourceConnID, 8); |
|
|
|
RAND_bytes ((uint8_t *)&m_SourceConnID, 8); |
|
|
|
} |
|
|
|
} |
|
|
@ -1110,6 +1112,10 @@ namespace transport |
|
|
|
AdjustMaxPayloadSize (); |
|
|
|
AdjustMaxPayloadSize (); |
|
|
|
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
|
|
|
m_Server.AddSessionByRouterHash (shared_from_this ()); // we know remote router now
|
|
|
|
m_RemoteTransports = ri->GetCompatibleTransports (false); |
|
|
|
m_RemoteTransports = ri->GetCompatibleTransports (false); |
|
|
|
|
|
|
|
m_RemotePeerTestTransports = 0; |
|
|
|
|
|
|
|
if (ri->IsSSU2PeerTesting (true)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V4; |
|
|
|
|
|
|
|
if (ri->IsSSU2PeerTesting (false)) m_RemotePeerTestTransports |= i2p::data::RouterInfo::eSSU2V6; |
|
|
|
|
|
|
|
|
|
|
|
// 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 (); |
|
|
@ -2109,7 +2115,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
case 1: // Bob from Alice
|
|
|
|
case 1: // Bob from Alice
|
|
|
|
{ |
|
|
|
{ |
|
|
|
auto session = m_Server.GetRandomSession ((buf[12] == 6) ? i2p::data::RouterInfo::eSSU2V4 : i2p::data::RouterInfo::eSSU2V6, |
|
|
|
auto session = m_Server.GetRandomPeerTestSession ((buf[12] == 6) ? i2p::data::RouterInfo::eSSU2V4 : i2p::data::RouterInfo::eSSU2V6, |
|
|
|
GetRemoteIdentity ()->GetIdentHash ()); |
|
|
|
GetRemoteIdentity ()->GetIdentHash ()); |
|
|
|
if (session) // session with Charlie
|
|
|
|
if (session) // session with Charlie
|
|
|
|
{ |
|
|
|
{ |
|
|
|