Browse Source

set router status to uknown if peer test msg 5 came from recently connected peer

pull/2101/head
orignal 2 months ago
parent
commit
5cd0248494
  1. 5
      libi2pd/SSU2Session.cpp
  2. 3
      libi2pd/SSU2Session.h

5
libi2pd/SSU2Session.cpp

@ -2362,6 +2362,7 @@ namespace transport
if (GetRouterStatus () != eRouterStatusFirewalled && addr->IsPeerTesting ()) if (GetRouterStatus () != eRouterStatusFirewalled && addr->IsPeerTesting ())
{ {
SetRouterStatus (eRouterStatusFirewalled); SetRouterStatus (eRouterStatusFirewalled);
session->SetStatusChanged ();
if (m_Address->IsV4 ()) if (m_Address->IsV4 ())
m_Server.RescheduleIntroducersUpdateTimer (); m_Server.RescheduleIntroducersUpdateTimer ();
else else
@ -3093,7 +3094,7 @@ 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), 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 (!sourceConnID) sourceConnID = ~destConnID;
if (!destConnID) destConnID = ~sourceConnID; if (!destConnID) destConnID = ~sourceConnID;
@ -3162,6 +3163,8 @@ namespace transport
{ {
if (!m_IsConnectedRecently) if (!m_IsConnectedRecently)
SetRouterStatus (eRouterStatusOK); SetRouterStatus (eRouterStatusOK);
else if (m_IsStatusChanged && GetRouterStatus () == eRouterStatusFirewalled)
SetRouterStatus (eRouterStatusUnknown);
SendPeerTest (6, buf + offset, len - offset, addr->i); SendPeerTest (6, buf + offset, len - offset, addr->i);
} }
} }

3
libi2pd/SSU2Session.h

@ -397,6 +397,7 @@ namespace transport
uint8_t GetMsgNumReceived () const { return m_MsgNumReceived; } uint8_t GetMsgNumReceived () const { return m_MsgNumReceived; }
bool IsConnectedRecently () const { return m_IsConnectedRecently; } bool IsConnectedRecently () const { return m_IsConnectedRecently; }
void SetStatusChanged () { m_IsStatusChanged = true; }
bool ProcessPeerTest (uint8_t * buf, size_t len) override; bool ProcessPeerTest (uint8_t * buf, size_t len) override;
private: private:
@ -406,7 +407,7 @@ namespace transport
private: private:
uint8_t m_MsgNumReceived; uint8_t m_MsgNumReceived;
bool m_IsConnectedRecently; bool m_IsConnectedRecently, m_IsStatusChanged;
}; };
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…
Cancel
Save