mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
check if msg 5 was received instead state
This commit is contained in:
parent
2dfc9003a7
commit
189d7179c0
|
@ -2341,14 +2341,18 @@ namespace transport
|
||||||
if (addr)
|
if (addr)
|
||||||
{
|
{
|
||||||
session->m_Address = addr;
|
session->m_Address = addr;
|
||||||
auto& state = session->m_State;
|
if (session->GetMsgNumReceived () >= 5)
|
||||||
if (state == eSSU2SessionStatePeerTestReceived || state == eSSU2SessionStateVoidPeerTestReceived)
|
|
||||||
{
|
{
|
||||||
// msg 5 already received. send msg 6
|
// msg 5 already received
|
||||||
if (state == eSSU2SessionStatePeerTestReceived)
|
if (session->GetMsgNumReceived () == 5)
|
||||||
SetRouterStatus (eRouterStatusOK);
|
{
|
||||||
state = eSSU2SessionStatePeerTest;
|
if (!session->IsConnectedRecently ())
|
||||||
session->SendPeerTest (6, buf + offset, len - offset, addr->i);
|
SetRouterStatus (eRouterStatusOK);
|
||||||
|
// send msg 6
|
||||||
|
session->SendPeerTest (6, buf + offset, len - offset, addr->i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LogPrint (eLogWarning, "SSU2: PeerTest 4 received, but msg ", session->GetMsgNumReceived (), " already received");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3088,7 +3092,8 @@ namespace transport
|
||||||
}
|
}
|
||||||
|
|
||||||
SSU2PeerTestSession::SSU2PeerTestSession (SSU2Server& server, uint64_t sourceConnID, uint64_t destConnID):
|
SSU2PeerTestSession::SSU2PeerTestSession (SSU2Server& server, uint64_t sourceConnID, uint64_t destConnID):
|
||||||
SSU2Session (server, nullptr, nullptr, false), m_MsgNumReceived (0)
|
SSU2Session (server, nullptr, nullptr, false),
|
||||||
|
m_MsgNumReceived (0), m_IsConnectedRecently (false)
|
||||||
{
|
{
|
||||||
if (!sourceConnID) sourceConnID = ~destConnID;
|
if (!sourceConnID) sourceConnID = ~destConnID;
|
||||||
if (!destConnID) destConnID = ~sourceConnID;
|
if (!destConnID) destConnID = ~sourceConnID;
|
||||||
|
@ -3151,17 +3156,14 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (htobe64 (((uint64_t)nonce << 32) | nonce) == GetSourceConnID ())
|
if (htobe64 (((uint64_t)nonce << 32) | nonce) == GetSourceConnID ())
|
||||||
{
|
{
|
||||||
bool isConnectedRecently = GetServer ().IsConnectedRecently (GetRemoteEndpoint ());
|
m_IsConnectedRecently = GetServer ().IsConnectedRecently (GetRemoteEndpoint ());
|
||||||
auto addr = GetAddress ();
|
auto addr = GetAddress ();
|
||||||
if (addr)
|
if (addr)
|
||||||
{
|
{
|
||||||
if (!isConnectedRecently)
|
if (!m_IsConnectedRecently)
|
||||||
SetRouterStatus (eRouterStatusOK);
|
SetRouterStatus (eRouterStatusOK);
|
||||||
SendPeerTest (6, buf + offset, len - offset, addr->i);
|
SendPeerTest (6, buf + offset, len - offset, addr->i);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
// we received msg 5 before msg 4
|
|
||||||
SetState (isConnectedRecently ? eSSU2SessionStateVoidPeerTestReceived : eSSU2SessionStatePeerTestReceived);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", GetSourceConnID ());
|
LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", GetSourceConnID ());
|
||||||
|
|
|
@ -113,8 +113,6 @@ namespace transport
|
||||||
eSSU2SessionStateFailed,
|
eSSU2SessionStateFailed,
|
||||||
eSSU2SessionStateIntroduced,
|
eSSU2SessionStateIntroduced,
|
||||||
eSSU2SessionStatePeerTest,
|
eSSU2SessionStatePeerTest,
|
||||||
eSSU2SessionStatePeerTestReceived, // 5 before 4
|
|
||||||
eSSU2SessionStateVoidPeerTestReceived, // 5 before 4, but from connected recently
|
|
||||||
eSSU2SessionStateTokenRequestReceived
|
eSSU2SessionStateTokenRequestReceived
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -397,7 +395,8 @@ namespace transport
|
||||||
|
|
||||||
SSU2PeerTestSession (SSU2Server& server, uint64_t sourceConnID, uint64_t destConnID);
|
SSU2PeerTestSession (SSU2Server& server, uint64_t sourceConnID, uint64_t destConnID);
|
||||||
|
|
||||||
uint8_t GetMsgNumReceived () const { return m_MsgNumReceived; }
|
uint8_t GetMsgNumReceived () const { return m_MsgNumReceived; }
|
||||||
|
bool IsConnectedRecently () const { return m_IsConnectedRecently; }
|
||||||
bool ProcessPeerTest (uint8_t * buf, size_t len) override;
|
bool ProcessPeerTest (uint8_t * buf, size_t len) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -407,6 +406,7 @@ namespace transport
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint8_t m_MsgNumReceived;
|
uint8_t m_MsgNumReceived;
|
||||||
|
bool m_IsConnectedRecently;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
|
||||||
|
|
Loading…
Reference in a new issue