Skip to content

Commit

Permalink
exclude false position OK peer test if comes from recently connected …
Browse files Browse the repository at this point in the history
…endpoint
  • Loading branch information
orignal committed Sep 18, 2024
1 parent db19c32 commit 7ef1fdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libi2pd/SSU2Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2365,10 +2365,11 @@ namespace transport
if (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
SetRouterStatus (eRouterStatusOK);
SetRouterStatus (state == eSSU2SessionStatePeerTestReceived ? eRouterStatusOK : eRouterStatusUnknown);
it->second.first->m_State = eSSU2SessionStatePeerTest;
it->second.first->SendPeerTest (6, buf + offset, len - offset, addr->i);
}
Expand Down Expand Up @@ -2426,14 +2427,15 @@ namespace transport
case 5: // Alice from Charlie 1
if (htobe64 (((uint64_t)nonce << 32) | nonce) == m_SourceConnID)
{
bool isConnectedRecently = m_Server.IsConnectedRecently (m_RemoteEndpoint);
if (m_Address)
{
SetRouterStatus (eRouterStatusOK);
SetRouterStatus (isConnectedRecently ? eRouterStatusUnknown : eRouterStatusOK);
SendPeerTest (6, buf + offset, len - offset, m_Address->i);
}
else
// we received msg 5 before msg 4
m_State = eSSU2SessionStatePeerTestReceived;
m_State = isConnectedRecently ? eSSU2SessionStateVoidPeerTestReceived : eSSU2SessionStatePeerTestReceived;
}
else
LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", m_SourceConnID);
Expand Down
1 change: 1 addition & 0 deletions libi2pd/SSU2Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace transport
eSSU2SessionStateIntroduced,
eSSU2SessionStatePeerTest,
eSSU2SessionStatePeerTestReceived, // 5 before 4
eSSU2SessionStateVoidPeerTestReceived, // 5 before 4, but from connected recently
eSSU2SessionStateTokenRequestReceived
};

Expand Down

0 comments on commit 7ef1fdf

Please sign in to comment.