diff --git a/SSU.cpp b/SSU.cpp index 20c86a81..39197293 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -461,6 +461,16 @@ namespace transport m_Introducers = newList; ScheduleIntroducersUpdateTimer (); } + } + + void SSUServer::NewPeerTest (uint32_t nonce) + { + m_PeerTests[nonce] = i2p::util::GetMillisecondsSinceEpoch (); + } + + void SSUServer::PeerTestComplete (uint32_t nonce) + { + m_PeerTests.erase (nonce); } } } diff --git a/SSU.h b/SSU.h index 70cea541..12cbb775 100644 --- a/SSU.h +++ b/SSU.h @@ -53,6 +53,9 @@ namespace transport void AddRelay (uint32_t tag, const boost::asio::ip::udp::endpoint& relay); std::shared_ptr FindRelaySession (uint32_t tag); + void NewPeerTest (uint32_t nonce); + void PeerTestComplete (uint32_t nonce); + private: void Run (); @@ -70,7 +73,7 @@ namespace transport std::set FindIntroducers (int maxNumIntroducers); void ScheduleIntroducersUpdateTimer (); void HandleIntroducersUpdateTimer (const boost::system::error_code& ecode); - + private: bool m_IsRunning; @@ -84,6 +87,7 @@ namespace transport std::mutex m_SessionsMutex; std::map > m_Sessions; std::map m_Relays; // we are introducer + std::map m_PeerTests; // nonce -> creation time in milliseconds public: // for HTTP only diff --git a/SSUSession.cpp b/SSUSession.cpp index 4835abeb..72ede036 100644 --- a/SSUSession.cpp +++ b/SSUSession.cpp @@ -942,7 +942,10 @@ namespace transport } } else + { LogPrint (eLogDebug, "SSU peer test from Charlie. We are Alice"); + m_Server.PeerTestComplete (nonce); + } } } @@ -989,6 +992,7 @@ namespace transport void SSUSession::SendPeerTest () { + // we are Alice LogPrint (eLogDebug, "SSU sending peer test"); auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); if (!address) @@ -999,6 +1003,7 @@ namespace transport uint32_t nonce = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); if (!nonce) nonce = 1; m_PeerTestNonces.insert (nonce); + m_Server.NewPeerTest (nonce); SendPeerTest (nonce, 0, 0, address->key, false); // address and port always zero for Alice }