check for published ipv4 addresses for floodfills and IBGW

debian
orignal 1 year ago
parent d580c0155a
commit caff003a85

@ -366,7 +366,7 @@ namespace data
{
if (isStaticKey)
{
if (isHost)
if (isHost && address->port)
{
if (address->host.is_v6 ())
supportedTransports |= (i2p::util::net::IsYggdrasilAddress (address->host) ? eNTCP2V6Mesh : eNTCP2V6);
@ -374,8 +374,9 @@ namespace data
supportedTransports |= eNTCP2V4;
m_ReachableTransports |= supportedTransports;
}
else if (!address->published)
else
{
address->published = false;
if (address->caps)
{
if (address->caps & AddressCaps::eV4) supportedTransports |= eNTCP2V4;
@ -982,11 +983,22 @@ namespace data
bool RouterInfo::IsEligibleFloodfill () const
{
// floodfill must be reachable by ipv4, >= 0.9.38 and not DSA
return IsReachableBy (eNTCP2V4 | eSSU2V4) && m_Version >= NETDB_MIN_FLOODFILL_VERSION &&
// floodfill must have published ipv4, >= 0.9.38 and not DSA
return m_Version >= NETDB_MIN_FLOODFILL_VERSION && IsPublished (true) &&
GetIdentity ()->GetSigningKeyType () != SIGNING_KEY_TYPE_DSA_SHA1;
}
bool RouterInfo::IsPublished (bool v4) const
{
auto addr = GetAddresses ();
if (v4)
return ((*addr)[eNTCP2V4] && ((*addr)[eNTCP2V4])->published) ||
((*addr)[eSSU2V4] && ((*addr)[eSSU2V4])->published);
else
return ((*addr)[eNTCP2V6] && ((*addr)[eNTCP2V6])->published) ||
((*addr)[eSSU2V6] && ((*addr)[eSSU2V6])->published);
}
bool RouterInfo::IsSSU2PeerTesting (bool v4) const
{
if (!(m_SupportedTransports & (v4 ? eSSU2V4 : eSSU2V6))) return false;

@ -247,6 +247,7 @@ namespace data
bool IsHighBandwidth () const { return m_Caps & RouterInfo::eHighBandwidth; };
bool IsExtraBandwidth () const { return m_Caps & RouterInfo::eExtraBandwidth; };
bool IsEligibleFloodfill () const;
bool IsPublished (bool v4) const;
bool IsSSU2PeerTesting (bool v4) const;
bool IsSSU2Introducer (bool v4) const;
bool IsHighCongestion () const;

@ -498,8 +498,7 @@ namespace tunnel
{
auto r = i2p::transport::transports.GetRandomPeer (!IsExploratory ());
if (r && r->IsECIES () && !r->GetProfile ()->IsBad () &&
(numHops > 1 || (r->IsV4 () && (!inbound ||
r->IsReachableBy (i2p::data::RouterInfo::eNTCP2V4 | i2p::data::RouterInfo::eSSU2V4))))) // first inbound must be reachable
(numHops > 1 || (r->IsV4 () && (!inbound || r->IsPublished (true))))) // first inbound must be published ipv4
{
prevHop = r;
path.Add (r);
@ -521,8 +520,7 @@ namespace tunnel
LogPrint (eLogError, "Tunnels: Can't select next hop for ", prevHop->GetIdentHashBase64 ());
return false;
}
if ((i == numHops - 1) && (!hop->IsV4 () || (inbound && // doesn't support ipv4
!hop->IsReachableBy (i2p::data::RouterInfo::eNTCP2V4 | i2p::data::RouterInfo::eSSU2V4)))) // IBGW is not reachable
if ((i == numHops - 1) && (!hop->IsV4 () || (inbound && !hop->IsPublished (true)))) // IBGW is not published ipv4
{
auto hop1 = nextHop (prevHop, true);
if (hop1) hop = hop1;

Loading…
Cancel
Save