1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Disable confirmation dialog on localhost

This commit is contained in:
rubenwardy 2019-02-03 12:31:55 +00:00 committed by Loic Blot
parent b7e1bca28c
commit 7796a3118d
No known key found for this signature in database
GPG key ID: EFAA458E8C153987
3 changed files with 21 additions and 3 deletions

View file

@ -271,3 +271,19 @@ void Address::print(std::ostream *s) const
else
*s << serializeString() << ":" << m_port;
}
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};
static const unsigned char mapped_ipv4_localhost[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0x7f, 0, 0, 1};
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;
}
}