Browse Source

NTCP2Mesh added

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

2
libi2pd/NTCP2.cpp

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

23
libi2pd/RouterInfo.cpp

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
#include <boost/atomic.hpp>
#endif
#include "version.h"
#include "util.h"
#include "Crypto.h"
#include "Base.h"
#include "Timestamp.h"
@ -298,8 +299,18 @@ namespace data @@ -298,8 +299,18 @@ namespace data
}
if (address->transportStyle == eTransportNTCP)
{
if (isStaticKey && isHost)
supportedTransports |= address->host.is_v4 () ? eNTCP2V4 : eNTCP2V6;
if (isStaticKey)
{
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)
{
@ -920,12 +931,12 @@ namespace data @@ -920,12 +931,12 @@ namespace data
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 (
[publishedOnly, v4only](std::shared_ptr<const RouterInfo::Address> address)->bool
{
return address->IsNTCP2 () && (!publishedOnly || address->IsPublishedNTCP2 ()) && (!v4only || address->host.is_v4 ());
[publishedOnly](std::shared_ptr<const RouterInfo::Address> address)->bool
{
return address->IsNTCP2 () && (!publishedOnly || address->IsPublishedNTCP2 ());
});
}

5
libi2pd/RouterInfo.h

@ -57,7 +57,8 @@ namespace data @@ -57,7 +57,8 @@ namespace data
eNTCP2V4 = 0x01,
eNTCP2V6 = 0x02,
eSSUV4 = 0x04,
eSSUV6 = 0x08
eSSUV6 = 0x08,
eNTCP2V6Mesh = 0x10
};
enum Caps
@ -149,7 +150,7 @@ namespace data @@ -149,7 +150,7 @@ namespace data
uint64_t GetTimestamp () const { return m_Timestamp; };
int GetVersion () const { return m_Version; };
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> GetPublishedNTCP2V6Address () const;
std::shared_ptr<const Address> GetSSUAddress (bool v4only = true) const;

Loading…
Cancel
Save