1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00
This commit is contained in:
Loïc Blot 2019-02-15 12:27:29 +01:00
parent 88c68ce8ec
commit 3dafc007a9
2 changed files with 7 additions and 6 deletions

View file

@ -272,7 +272,8 @@ void Address::print(std::ostream *s) const
*s << serializeString() << ":" << m_port;
}
bool Address::isLocalhost() const {
bool Address::isLocalhost() const
{
if (isIPv6()) {
static const unsigned char localhost_bytes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
@ -281,8 +282,10 @@ bool Address::isLocalhost() const {
auto addr = m_address.ipv6.sin6_addr.s6_addr;
// clang-format off
return memcmp(addr, localhost_bytes, 16) == 0 ||
memcmp(addr, mapped_ipv4_localhost, 13) == 0;
// clang-format on
}
return (m_address.ipv4.sin_addr.s_addr & 0xFF) == 0x7f;