Browse Source

exclude false position OK peer test if comes from recently connected endpoint

pull/2101/head
orignal 2 months ago
parent
commit
7ef1fdf634
  1. 10
      libi2pd/SSU2Session.cpp
  2. 1
      libi2pd/SSU2Session.h

10
libi2pd/SSU2Session.cpp

@ -2365,10 +2365,11 @@ namespace transport
if (addr) if (addr)
{ {
it->second.first->m_Address = addr; it->second.first->m_Address = addr;
if (it->second.first->m_State == eSSU2SessionStatePeerTestReceived) auto state = it->second.first->m_State;
if (state == eSSU2SessionStatePeerTestReceived || state == eSSU2SessionStateVoidPeerTestReceived)
{ {
// msg 5 already received. send msg 6 // msg 5 already received. send msg 6
SetRouterStatus (eRouterStatusOK); SetRouterStatus (state == eSSU2SessionStatePeerTestReceived ? eRouterStatusOK : eRouterStatusUnknown);
it->second.first->m_State = eSSU2SessionStatePeerTest; it->second.first->m_State = eSSU2SessionStatePeerTest;
it->second.first->SendPeerTest (6, buf + offset, len - offset, addr->i); it->second.first->SendPeerTest (6, buf + offset, len - offset, addr->i);
} }
@ -2426,14 +2427,15 @@ namespace transport
case 5: // Alice from Charlie 1 case 5: // Alice from Charlie 1
if (htobe64 (((uint64_t)nonce << 32) | nonce) == m_SourceConnID) if (htobe64 (((uint64_t)nonce << 32) | nonce) == m_SourceConnID)
{ {
bool isConnectedRecently = m_Server.IsConnectedRecently (m_RemoteEndpoint);
if (m_Address) if (m_Address)
{ {
SetRouterStatus (eRouterStatusOK); SetRouterStatus (isConnectedRecently ? eRouterStatusUnknown : eRouterStatusOK);
SendPeerTest (6, buf + offset, len - offset, m_Address->i); SendPeerTest (6, buf + offset, len - offset, m_Address->i);
} }
else else
// we received msg 5 before msg 4 // we received msg 5 before msg 4
m_State = eSSU2SessionStatePeerTestReceived; m_State = isConnectedRecently ? eSSU2SessionStateVoidPeerTestReceived : eSSU2SessionStatePeerTestReceived;
} }
else else
LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", m_SourceConnID); LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", m_SourceConnID);

1
libi2pd/SSU2Session.h

@ -114,6 +114,7 @@ namespace transport
eSSU2SessionStateIntroduced, eSSU2SessionStateIntroduced,
eSSU2SessionStatePeerTest, eSSU2SessionStatePeerTest,
eSSU2SessionStatePeerTestReceived, // 5 before 4 eSSU2SessionStatePeerTestReceived, // 5 before 4
eSSU2SessionStateVoidPeerTestReceived, // 5 before 4, but from connected recently
eSSU2SessionStateTokenRequestReceived eSSU2SessionStateTokenRequestReceived
}; };

Loading…
Cancel
Save