|
|
@ -13,19 +13,18 @@ |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "RouterContext.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace i2p |
|
|
|
namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
namespace data |
|
|
|
namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
RouterInfo::RouterInfo (const char * filename): |
|
|
|
RouterInfo::RouterInfo (const char * filename): |
|
|
|
m_IsUpdated (false), m_IsUnreachable (false) |
|
|
|
m_IsUpdated (false), m_IsUnreachable (false), m_SupportedTransports (0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ReadFromFile (filename); |
|
|
|
ReadFromFile (filename); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RouterInfo::RouterInfo (const uint8_t * buf, int len): |
|
|
|
RouterInfo::RouterInfo (const uint8_t * buf, int len): |
|
|
|
m_IsUpdated (true) |
|
|
|
m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
m_BufferLen = len; |
|
|
|
m_BufferLen = len; |
|
|
@ -111,7 +110,15 @@ namespace data |
|
|
|
// TODO: we should try to resolve address here
|
|
|
|
// TODO: we should try to resolve address here
|
|
|
|
LogPrint ("Unexpected address ", value); |
|
|
|
LogPrint ("Unexpected address ", value); |
|
|
|
SetUnreachable (true); |
|
|
|
SetUnreachable (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// add supported protocol
|
|
|
|
|
|
|
|
if (address.host.is_v4 ()) |
|
|
|
|
|
|
|
m_SupportedTransports |= (address.transportStyle == eTransportNTCP) ? eNTCPV4 : eSSUV4; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
m_SupportedTransports |= (address.transportStyle == eTransportNTCP) ? eNTCPV6 : eSSUV6; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!strcmp (key, "port")) |
|
|
|
else if (!strcmp (key, "port")) |
|
|
|
address.port = boost::lexical_cast<int>(value); |
|
|
|
address.port = boost::lexical_cast<int>(value); |
|
|
@ -275,17 +282,12 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
bool RouterInfo::IsNTCP (bool v4only) const |
|
|
|
bool RouterInfo::IsNTCP (bool v4only) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (auto& address : m_Addresses) |
|
|
|
if (v4only) |
|
|
|
{ |
|
|
|
return m_SupportedTransports & eNTCPV4; |
|
|
|
if (address.transportStyle == eTransportNTCP) |
|
|
|
else |
|
|
|
{ |
|
|
|
return m_SupportedTransports & (eNTCPV4 | eNTCPV6); |
|
|
|
if (!v4only || address.host.is_v4 ()) |
|
|
|
} |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RouterInfo::Address * RouterInfo::GetNTCPAddress (bool v4only) |
|
|
|
RouterInfo::Address * RouterInfo::GetNTCPAddress (bool v4only) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (auto& address : m_Addresses) |
|
|
|
for (auto& address : m_Addresses) |
|
|
|