avoid connecting to non valid ipv4 ranges (>=240.0.0.0)
This commit is contained in:
parent
11e935b720
commit
6e5a39185e
2 changed files with 7 additions and 1 deletions
|
@ -624,6 +624,11 @@ bool CNetAddr::IsRFC1918() const
|
||||||
(GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31)));
|
(GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CNetAddr::IsReserved() const
|
||||||
|
{
|
||||||
|
return IsIPv4() && (GetByte(3) >= 240);
|
||||||
|
}
|
||||||
|
|
||||||
bool CNetAddr::IsRFC3927() const
|
bool CNetAddr::IsRFC3927() const
|
||||||
{
|
{
|
||||||
return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254);
|
return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254);
|
||||||
|
@ -740,7 +745,7 @@ bool CNetAddr::IsValid() const
|
||||||
|
|
||||||
bool CNetAddr::IsRoutable() const
|
bool CNetAddr::IsRoutable() const
|
||||||
{
|
{
|
||||||
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
|
return IsValid() && !(IsReserved() || IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Network CNetAddr::GetNetwork() const
|
enum Network CNetAddr::GetNetwork() const
|
||||||
|
|
|
@ -47,6 +47,7 @@ class CNetAddr
|
||||||
bool SetSpecial(const std::string &strName); // for Tor and I2P addresses
|
bool SetSpecial(const std::string &strName); // for Tor and I2P addresses
|
||||||
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
|
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
|
||||||
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/I2P)
|
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/I2P)
|
||||||
|
bool IsReserved() const; // Against Hetzners Abusal/Netscan Bot
|
||||||
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
|
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
|
||||||
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
|
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
|
||||||
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
|
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
|
||||||
|
|
Loading…
Reference in a new issue