summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2019-02-09 19:52:38 +0100
committerLoic Blot <loic.blot@unix-experience.fr>2019-02-09 19:52:56 +0100
commitff5d4ffe1c4b379b0920bef41cdbaebb751f25aa (patch)
treef07b39936ec4c671d60d6955c950bcca43dfb306 /src/network
parent7796a3118d7b4f58752fad0ca5f676dcafd7a76c (diff)
downloadminetest-ff5d4ffe1c4b379b0920bef41cdbaebb751f25aa.tar.gz
minetest-ff5d4ffe1c4b379b0920bef41cdbaebb751f25aa.tar.bz2
minetest-ff5d4ffe1c4b379b0920bef41cdbaebb751f25aa.zip
Fix Address::isLocalhost algorithm
Diffstat (limited to 'src/network')
-rw-r--r--src/network/address.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/network/address.cpp b/src/network/address.cpp
index 0ecface37..fce3b48f0 100644
--- a/src/network/address.cpp
+++ b/src/network/address.cpp
@@ -277,13 +277,13 @@ bool Address::isLocalhost() const {
static const unsigned char localhost_bytes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
static const unsigned char mapped_ipv4_localhost[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0x7f, 0, 0, 1};
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0x7f, 0, 0, 0};
auto addr = m_address.ipv6.sin6_addr.s6_addr;
return memcmp(addr, localhost_bytes, 16) == 0 ||
- memcmp(addr, mapped_ipv4_localhost, 16) == 0;
- } else {
- return m_address.ipv4.sin_addr.s_addr == 0x0100007F;
+ memcmp(addr, mapped_ipv4_localhost, 13) == 0;
}
+
+ return (m_address.ipv4.sin_addr.s_addr & 0xFF) == 0x7f;
}