diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index f8f6e69d..551dd148 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -292,7 +292,7 @@ namespace transport // session already exists LogPrint (eLogWarning, "SSU2: Session to ", ident->GetIdentHash ().ToBase64 (), " already exists"); // terminate existing - GetService ().post (std::bind (&SSU2Session::RequestTermination, ret.first->second, eSSU2TerminationReasonTerminationReceived)); + GetService ().post (std::bind (&SSU2Session::RequestTermination, ret.first->second, eSSU2TerminationReasonReplacedByNewSession)); // update session ret.first->second = session; } diff --git a/libi2pd/SSU2Session.cpp b/libi2pd/SSU2Session.cpp index 761fdf8e..475d7cef 100644 --- a/libi2pd/SSU2Session.cpp +++ b/libi2pd/SSU2Session.cpp @@ -1403,8 +1403,11 @@ namespace transport break; } case eSSU2BlkPathChallenge: + LogPrint (eLogDebug, "SSU2: Path challenge"); + SendPathResponse (buf + offset, size); break; case eSSU2BlkPathResponse: + LogPrint (eLogDebug, "SSU2: Path response"); break; case eSSU2BlkFirstPacketNumber: break; @@ -2440,6 +2443,19 @@ namespace transport payloadSize += CreatePaddingBlock (payload + payloadSize, 32 - payloadSize); SendData (payload, payloadSize); } + + void SSU2Session::SendPathResponse (const uint8_t * data, size_t len) + { + if (len < 8 || len > m_MaxPayloadSize - 3) + { + LogPrint (eLogWarning, "SSU2: Incorrect data size for path response ", len); + return; + } + uint8_t payload[SSU2_MAX_PACKET_SIZE]; + payload[0] = eSSU2BlkPathResponse; + htobe16buf (payload + 1, len); + SendData (payload, len + 3); + } void SSU2Session::CleanUp (uint64_t ts) { diff --git a/libi2pd/SSU2Session.h b/libi2pd/SSU2Session.h index 0ca4933a..3971358c 100644 --- a/libi2pd/SSU2Session.h +++ b/libi2pd/SSU2Session.h @@ -150,7 +150,8 @@ namespace transport eSSU2TerminationReasonBadToken = 18, eSSU2TerminationReasonConnectionLimits = 19, eSSU2TerminationReasonIncompatibleVersion = 20, - eSSU2TerminationReasonWrongNetID = 21 + eSSU2TerminationReasonWrongNetID = 21, + eSSU2TerminationReasonReplacedByNewSession = 22 }; struct SSU2IncompleteMessage @@ -272,6 +273,7 @@ namespace transport void SendTermination (); void SendHolePunch (uint32_t nonce, const boost::asio::ip::udp::endpoint& ep, const uint8_t * introKey, uint64_t token); void SendPeerTest (uint8_t msg, const uint8_t * signedData, size_t signedDataLen, const uint8_t * introKey); // PeerTest message + void SendPathResponse (const uint8_t * data, size_t len); void HandlePayload (const uint8_t * buf, size_t len); void HandleAck (const uint8_t * buf, size_t len);