mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
set status OK after peer test msg 5
This commit is contained in:
parent
a2f4e08b00
commit
aa21748e9a
|
@ -9,7 +9,6 @@
|
|||
#include <string.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "Log.h"
|
||||
#include "RouterContext.h"
|
||||
#include "Transports.h"
|
||||
#include "Gzip.h"
|
||||
#include "NetDb.hpp"
|
||||
|
@ -1693,10 +1692,8 @@ namespace transport
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_Address->IsV4 () && i2p::context.GetStatus () == eRouterStatusTesting)
|
||||
i2p::context.SetStatusSSU2 (eRouterStatusFirewalled);
|
||||
if (m_Address->IsV6 () && i2p::context.GetStatusV6 () == eRouterStatusTesting)
|
||||
i2p::context.SetStatusV6SSU2 (eRouterStatusFirewalled);
|
||||
if (GetRouterStatus () == eRouterStatusTesting)
|
||||
SetRouterStatus (eRouterStatusFirewalled);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1715,6 +1712,7 @@ namespace transport
|
|||
else
|
||||
{
|
||||
LogPrint (eLogInfo, "SSU2: Peer test 4 error code ", (int)buf[1]);
|
||||
SetRouterStatus (eRouterStatusUnknown);
|
||||
it->second.first->Terminate ();
|
||||
}
|
||||
m_PeerTests.erase (it);
|
||||
|
@ -1731,6 +1729,7 @@ namespace transport
|
|||
else
|
||||
// we received msg 5 before msg 4
|
||||
m_State = eSSU2SessionStatePeerTestReceived;
|
||||
SetRouterStatus (eRouterStatusOK);
|
||||
}
|
||||
else
|
||||
LogPrint (eLogWarning, "SSU2: Peer test 5 nonce mismatch ", nonce, " connID=", m_SourceConnID);
|
||||
|
@ -1746,8 +1745,6 @@ namespace transport
|
|||
m_Server.RemoveSession (htobe64 (((uint64_t)nonce << 32) | nonce));
|
||||
if (m_Address->IsV6 ())
|
||||
i2p::context.SetStatusV6 (eRouterStatusOK); // set status OK for ipv6 even if from SSU2
|
||||
else
|
||||
i2p::context.SetStatusSSU2 (eRouterStatusOK);
|
||||
break;
|
||||
default:
|
||||
LogPrint (eLogWarning, "SSU2: PeerTest unexpected msg num ", buf[0]);
|
||||
|
@ -1808,6 +1805,29 @@ namespace transport
|
|||
return i2p::context.GetRouterInfo ().GetSSU2Address (m_Address->IsV4 ());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RouterStatus SSU2Session::GetRouterStatus () const
|
||||
{
|
||||
if (m_Address)
|
||||
{
|
||||
if (m_Address->IsV4 ())
|
||||
return i2p::context.GetStatus ();
|
||||
if (m_Address->IsV6 ())
|
||||
return i2p::context.GetStatusV6 ();
|
||||
}
|
||||
return eRouterStatusUnknown;
|
||||
}
|
||||
|
||||
void SSU2Session::SetRouterStatus (RouterStatus status) const
|
||||
{
|
||||
if (m_Address)
|
||||
{
|
||||
if (m_Address->IsV4 ())
|
||||
i2p::context.SetStatusSSU2 (status);
|
||||
else if (m_Address->IsV6 ())
|
||||
i2p::context.SetStatusV6SSU2 (status);
|
||||
}
|
||||
}
|
||||
|
||||
size_t SSU2Session::CreateAddressBlock (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& ep)
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <boost/asio.hpp>
|
||||
#include "Crypto.h"
|
||||
#include "RouterInfo.h"
|
||||
#include "RouterContext.h"
|
||||
#include "TransportSession.h"
|
||||
|
||||
namespace i2p
|
||||
|
@ -238,6 +239,8 @@ namespace transport
|
|||
bool ExtractEndpoint (const uint8_t * buf, size_t size, boost::asio::ip::udp::endpoint& ep);
|
||||
size_t CreateEndpoint (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& ep);
|
||||
std::shared_ptr<const i2p::data::RouterInfo::Address> FindLocalAddress () const;
|
||||
RouterStatus GetRouterStatus () const;
|
||||
void SetRouterStatus (RouterStatus status) const;
|
||||
std::shared_ptr<const i2p::data::RouterInfo> ExtractRouterInfo (const uint8_t * buf, size_t size);
|
||||
void CreateNonce (uint64_t seqn, uint8_t * nonce);
|
||||
bool UpdateReceivePacketNum (uint32_t packetNum); // for Ack, returns false if duplicate
|
||||
|
|
Loading…
Reference in a new issue