Browse Source

NTCP2Mesh added

pull/1634/head
orignal 4 years ago
parent
commit
9e5935aea5
  1. 2
      libi2pd/NTCP2.cpp
  2. 21
      libi2pd/RouterInfo.cpp
  3. 5
      libi2pd/RouterInfo.h

2
libi2pd/NTCP2.cpp

@ -655,7 +655,7 @@ namespace transport
SendTerminationAndTerminate (eNTCP2Message3Error); SendTerminationAndTerminate (eNTCP2Message3Error);
return; return;
} }
auto addr = ri.GetNTCP2Address (false, false); // any NTCP2 address including v6 auto addr = ri.GetNTCP2Address (false); // any NTCP2 address
if (!addr) if (!addr)
{ {
LogPrint (eLogError, "NTCP2: No NTCP2 address found in SessionConfirmed"); LogPrint (eLogError, "NTCP2: No NTCP2 address found in SessionConfirmed");

21
libi2pd/RouterInfo.cpp

@ -16,6 +16,7 @@
#include <boost/atomic.hpp> #include <boost/atomic.hpp>
#endif #endif
#include "version.h" #include "version.h"
#include "util.h"
#include "Crypto.h" #include "Crypto.h"
#include "Base.h" #include "Base.h"
#include "Timestamp.h" #include "Timestamp.h"
@ -298,8 +299,18 @@ namespace data
} }
if (address->transportStyle == eTransportNTCP) if (address->transportStyle == eTransportNTCP)
{ {
if (isStaticKey && isHost) if (isStaticKey)
supportedTransports |= address->host.is_v4 () ? eNTCP2V4 : eNTCP2V6; {
if (isHost)
{
if (address->host.is_v6 ())
supportedTransports |= i2p::util::net::IsYggdrasilAddress (address->host) ? eNTCP2V6Mesh : eNTCP2V6;
else
supportedTransports |= eNTCP2V4;
}
else if (!address->ntcp2->isPublished)
supportedTransports |= eNTCP2V4; // most likely, since we don't have host
}
} }
else if (address->transportStyle == eTransportSSU) else if (address->transportStyle == eTransportSSU)
{ {
@ -920,12 +931,12 @@ namespace data
return nullptr; return nullptr;
} }
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetNTCP2Address (bool publishedOnly, bool v4only) const std::shared_ptr<const RouterInfo::Address> RouterInfo::GetNTCP2Address (bool publishedOnly) const
{ {
return GetAddress ( return GetAddress (
[publishedOnly, v4only](std::shared_ptr<const RouterInfo::Address> address)->bool [publishedOnly](std::shared_ptr<const RouterInfo::Address> address)->bool
{ {
return address->IsNTCP2 () && (!publishedOnly || address->IsPublishedNTCP2 ()) && (!v4only || address->host.is_v4 ()); return address->IsNTCP2 () && (!publishedOnly || address->IsPublishedNTCP2 ());
}); });
} }

5
libi2pd/RouterInfo.h

@ -57,7 +57,8 @@ namespace data
eNTCP2V4 = 0x01, eNTCP2V4 = 0x01,
eNTCP2V6 = 0x02, eNTCP2V6 = 0x02,
eSSUV4 = 0x04, eSSUV4 = 0x04,
eSSUV6 = 0x08 eSSUV6 = 0x08,
eNTCP2V6Mesh = 0x10
}; };
enum Caps enum Caps
@ -149,7 +150,7 @@ namespace data
uint64_t GetTimestamp () const { return m_Timestamp; }; uint64_t GetTimestamp () const { return m_Timestamp; };
int GetVersion () const { return m_Version; }; int GetVersion () const { return m_Version; };
Addresses& GetAddresses () { return *m_Addresses; }; // should be called for local RI only, otherwise must return shared_ptr Addresses& GetAddresses () { return *m_Addresses; }; // should be called for local RI only, otherwise must return shared_ptr
std::shared_ptr<const Address> GetNTCP2Address (bool publishedOnly, bool v4only = true) const; std::shared_ptr<const Address> GetNTCP2Address (bool publishedOnly) const;
std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const; std::shared_ptr<const Address> GetPublishedNTCP2V4Address () const;
std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const; std::shared_ptr<const Address> GetPublishedNTCP2V6Address () const;
std::shared_ptr<const Address> GetSSUAddress (bool v4only = true) const; std::shared_ptr<const Address> GetSSUAddress (bool v4only = true) const;

Loading…
Cancel
Save