1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

check availability of particular address

This commit is contained in:
orignal 2021-02-03 20:09:43 -05:00
parent 66a238045f
commit 89e8d99294
3 changed files with 10 additions and 4 deletions

View File

@ -837,6 +837,11 @@ namespace data
return m_SupportedTransports & (eNTCP2V4 | eNTCP2V6); return m_SupportedTransports & (eNTCP2V4 | eNTCP2V6);
} }
bool RouterInfo::IsNTCP2V6 () const
{
return m_SupportedTransports & eNTCP2V6;
}
bool RouterInfo::IsV6 () const bool RouterInfo::IsV6 () const
{ {
return m_SupportedTransports & (eSSUV6 | eNTCP2V6); return m_SupportedTransports & (eSSUV6 | eNTCP2V6);

View File

@ -170,6 +170,7 @@ namespace data
bool IsSSU (bool v4only = true) const; bool IsSSU (bool v4only = true) const;
bool IsSSUV6 () const; bool IsSSUV6 () const;
bool IsNTCP2 (bool v4only = true) const; bool IsNTCP2 (bool v4only = true) const;
bool IsNTCP2V6 () const;
bool IsV6 () const; bool IsV6 () const;
bool IsV4 () const; bool IsV4 () const;
bool IsMesh () const; bool IsMesh () const;
@ -179,7 +180,7 @@ namespace data
void DisableV4 (); void DisableV4 ();
void EnableMesh (); void EnableMesh ();
void DisableMesh (); void DisableMesh ();
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; }; bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
bool HasValidAddresses () const { return m_SupportedTransports; }; bool HasValidAddresses () const { return m_SupportedTransports; };
bool UsesIntroducer () const; bool UsesIntroducer () const;
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; }; bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };

View File

@ -397,7 +397,7 @@ namespace transport
std::shared_ptr<const RouterInfo::Address> address; std::shared_ptr<const RouterInfo::Address> address;
if (!peer.numAttempts) // NTCP2 ipv6 if (!peer.numAttempts) // NTCP2 ipv6
{ {
if (context.SupportsV6 ()) if (context.GetRouterInfo ().IsNTCP2V6 () && peer.router->IsNTCP2V6 ())
{ {
address = peer.router->GetPublishedNTCP2V6Address (); address = peer.router->GetPublishedNTCP2V6Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
@ -407,7 +407,7 @@ namespace transport
} }
if (!address && peer.numAttempts == 1) // NTCP2 ipv4 if (!address && peer.numAttempts == 1) // NTCP2 ipv4
{ {
if (context.SupportsV4 () && !peer.router->IsUnreachable ()) if (context.GetRouterInfo ().IsNTCP2 (true) && peer.router->IsNTCP2 (true) && !peer.router->IsUnreachable ())
{ {
address = peer.router->GetPublishedNTCP2V4Address (); address = peer.router->GetPublishedNTCP2V4Address ();
if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host)) if (address && m_CheckReserved && i2p::util::net::IsInReservedRange(address->host))
@ -453,7 +453,7 @@ namespace transport
if (peer.numAttempts == 3) // Mesh if (peer.numAttempts == 3) // Mesh
{ {
peer.numAttempts++; peer.numAttempts++;
if (context.SupportsMesh () && m_NTCP2Server) if (m_NTCP2Server && context.GetRouterInfo ().IsMesh () && peer.router->IsMesh ())
{ {
auto address = peer.router->GetYggdrasilAddress (); auto address = peer.router->GetYggdrasilAddress ();
if (address) if (address)