Don't ban localhost

This commit is contained in:
SChernykh
2022-05-03 13:11:55 +02:00
parent 6b4640c413
commit 8f27d940e3
2 changed files with 16 additions and 0 deletions

View File

@@ -309,6 +309,14 @@ struct raw_ip
}
FORCEINLINE bool operator!=(const raw_ip& other) const { return !operator==(other); }
FORCEINLINE bool is_localhost() const
{
static constexpr raw_ip localhost_ipv4 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01 };
static constexpr raw_ip localhost_ipv6 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
return (*this == localhost_ipv4) || (*this == localhost_ipv6);
}
};
static_assert(sizeof(raw_ip) == 16, "struct raw_ip has invalid size");