From 71168389ab5d0c4584559064d7e7886316ae8e0f Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 22 Sep 2014 19:03:46 -0400 Subject: [PATCH] PeerTest from Charlie to Alice --- SSU.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/SSU.cpp b/SSU.cpp index a11db339..b26b8319 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -791,22 +791,27 @@ namespace ssu } else { - // new test - m_PeerTestNonces.insert (nonce); - if (port) + if (m_State == eSessionStateEstablished) { - LogPrint ("SSU peer test from Bob. We are Charlie"); - Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob - SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice + // new test + m_PeerTestNonces.insert (nonce); + if (port) + { + LogPrint ("SSU peer test from Bob. We are Charlie"); + Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob + SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice + } + else + { + LogPrint ("SSU peer test from Alice. We are Bob"); + auto session = m_Server.GetRandomEstablishedSession (this); // charlie + if (session) + session->SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), + senderEndpoint.port (), introKey, false); + } } else - { - LogPrint ("SSU peer test from Alice. We are Bob"); - auto session = m_Server.GetRandomEstablishedSession (this); // charlie - if (session) - session->SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), - senderEndpoint.port (), introKey, false); - } + LogPrint ("SSU peer test from Charlie. We are Alice"); } }