diff options
author | Kahrl <kahrl@gmx.net> | 2014-03-07 01:00:03 +0100 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-04-10 22:03:42 +0200 |
commit | 6090e95cdcea7c0600ea75941289494505295cf2 (patch) | |
tree | 83745714b25e66fe087c8abdef08d18d5bcd8576 /src/socket.cpp | |
parent | edcad09dee6daf119f3e29b0a63837500e7b8b85 (diff) | |
download | hax-minetest-server-6090e95cdcea7c0600ea75941289494505295cf2.tar.gz hax-minetest-server-6090e95cdcea7c0600ea75941289494505295cf2.zip |
Infer ipv6_server from bind_address; fix client connect to IN(6)ADDR_ANY
Diffstat (limited to 'src/socket.cpp')
-rw-r--r-- | src/socket.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/socket.cpp b/src/socket.cpp index 00856fb00..bca9c5390 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -143,6 +143,15 @@ bool Address::operator!=(Address &address) void Address::Resolve(const char *name) { + if (!name || name[0] == 0) { + if (m_addr_family == AF_INET) { + setAddress((u32) 0); + } else if (m_addr_family == AF_INET6) { + setAddress((IPv6AddressBytes*) 0); + } + return; + } + struct addrinfo *resolved, hints; memset(&hints, 0, sizeof(hints)); @@ -251,6 +260,18 @@ bool Address::isIPv6() const return m_addr_family == AF_INET6; } +bool Address::isZero() const +{ + if (m_addr_family == AF_INET) { + return m_address.ipv4.sin_addr.s_addr == 0; + } else if (m_addr_family == AF_INET6) { + static const char zero[16] = {0}; + return memcmp(m_address.ipv6.sin6_addr.s6_addr, + zero, 16) == 0; + } + return false; +} + void Address::setAddress(u32 address) { m_addr_family = AF_INET; |