diff --git a/netbase.cpp b/netbase.cpp index 2630f87..aa6df6d 100644 --- a/netbase.cpp +++ b/netbase.cpp @@ -624,6 +624,11 @@ bool CNetAddr::IsRFC1918() const (GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31))); } +bool CNetAddr::IsReserved() const +{ + return IsIPv4() && (GetByte(3) >= 240); +} + bool CNetAddr::IsRFC3927() const { return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); @@ -740,7 +745,7 @@ bool CNetAddr::IsValid() 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 diff --git a/netbase.h b/netbase.h index 560e218..a7dec78 100644 --- a/netbase.h +++ b/netbase.h @@ -47,6 +47,7 @@ class CNetAddr 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 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 IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32) bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)