mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
Respond to path challenge. Correct termination reason for duplicated session
This commit is contained in:
parent
9d9d5e3e5d
commit
98d2ce5845
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user