Browse Source

pass address to NTCP2 session

pull/1622/head
orignal 4 years ago
parent
commit
1235d18d67
  1. 8
      libi2pd/NTCP2.cpp
  2. 3
      libi2pd/NTCP2.h
  3. 2
      libi2pd/Transports.cpp

8
libi2pd/NTCP2.cpp

@ -317,7 +317,8 @@ namespace transport @@ -317,7 +317,8 @@ namespace transport
return true;
}
NTCP2Session::NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter):
NTCP2Session::NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter,
std::shared_ptr<const i2p::data::RouterInfo::Address> addr):
TransportSession (in_RemoteRouter, NTCP2_ESTABLISH_TIMEOUT),
m_Server (server), m_Socket (m_Server.GetService ()),
m_IsEstablished (false), m_IsTerminated (false),
@ -332,7 +333,8 @@ namespace transport @@ -332,7 +333,8 @@ namespace transport
if (in_RemoteRouter) // Alice
{
m_Establisher->m_RemoteIdentHash = GetRemoteIdentity ()->GetIdentHash ();
auto addr = in_RemoteRouter->GetNTCP2Address (true); // we need a published address
if (!addr)
addr = in_RemoteRouter->GetNTCP2Address (true); // we need a published address
if (addr)
{
memcpy (m_Establisher->m_RemoteStaticKey, addr->ntcp2->staticKey, 32);
@ -653,7 +655,7 @@ namespace transport @@ -653,7 +655,7 @@ namespace transport
SendTerminationAndTerminate (eNTCP2Message3Error);
return;
}
auto addr = ri.GetNTCP2Address (false); // any NTCP2 address
auto addr = ri.GetNTCP2Address (false, false); // any NTCP2 address including v6
if (!addr)
{
LogPrint (eLogError, "NTCP2: No NTCP2 address found in SessionConfirmed");

3
libi2pd/NTCP2.h

@ -123,7 +123,8 @@ namespace transport @@ -123,7 +123,8 @@ namespace transport
{
public:
NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr);
NTCP2Session (NTCP2Server& server, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr,
std::shared_ptr<const i2p::data::RouterInfo::Address> addr = nullptr);
~NTCP2Session ();
void Terminate ();
void TerminateByTimeout ();

2
libi2pd/Transports.cpp

@ -398,7 +398,7 @@ namespace transport @@ -398,7 +398,7 @@ namespace transport
auto address = peer.router->GetNTCP2Address (true, !context.SupportsV6 ()); // published only
if (address && !peer.router->IsUnreachable () && (!m_CheckReserved || !i2p::util::net::IsInReservedRange(address->host)))
{
auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router);
auto s = std::make_shared<NTCP2Session> (*m_NTCP2Server, peer.router, address);
if(m_NTCP2Server->UsingProxy())
{

Loading…
Cancel
Save