Skip to content

Commit

Permalink
set router status to uknown if peer test msg 5 came from recently con…
Browse files Browse the repository at this point in the history
…nected peer
  • Loading branch information
orignal committed Sep 24, 2024
1 parent 816771d commit 5cd0248
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libi2pd/SSU2Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,7 @@ namespace transport
if (GetRouterStatus () != eRouterStatusFirewalled && addr->IsPeerTesting ())
{
SetRouterStatus (eRouterStatusFirewalled);
session->SetStatusChanged ();
if (m_Address->IsV4 ())
m_Server.RescheduleIntroducersUpdateTimer ();
else
Expand Down Expand Up @@ -3093,7 +3094,7 @@ namespace transport

SSU2PeerTestSession::SSU2PeerTestSession (SSU2Server& server, uint64_t sourceConnID, uint64_t destConnID):
SSU2Session (server, nullptr, nullptr, false),
m_MsgNumReceived (0), m_IsConnectedRecently (false)
m_MsgNumReceived (0), m_IsConnectedRecently (false), m_IsStatusChanged (false)
{
if (!sourceConnID) sourceConnID = ~destConnID;
if (!destConnID) destConnID = ~sourceConnID;
Expand Down Expand Up @@ -3162,6 +3163,8 @@ namespace transport
{
if (!m_IsConnectedRecently)
SetRouterStatus (eRouterStatusOK);
else if (m_IsStatusChanged && GetRouterStatus () == eRouterStatusFirewalled)
SetRouterStatus (eRouterStatusUnknown);
SendPeerTest (6, buf + offset, len - offset, addr->i);
}
}
Expand Down
3 changes: 2 additions & 1 deletion libi2pd/SSU2Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ namespace transport

uint8_t GetMsgNumReceived () const { return m_MsgNumReceived; }
bool IsConnectedRecently () const { return m_IsConnectedRecently; }
void SetStatusChanged () { m_IsStatusChanged = true; }
bool ProcessPeerTest (uint8_t * buf, size_t len) override;

private:
Expand All @@ -406,7 +407,7 @@ namespace transport
private:

uint8_t m_MsgNumReceived;
bool m_IsConnectedRecently;
bool m_IsConnectedRecently, m_IsStatusChanged;
};

inline uint64_t CreateHeaderMask (const uint8_t * kh, const uint8_t * nonce)
Expand Down

0 comments on commit 5cd0248

Please sign in to comment.