diff options
author | rubidium <rubidium@openttd.org> | 2009-04-08 00:26:49 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-04-08 00:26:49 +0000 |
commit | 1eb4aa971ea329f18dd77b58bf7fc84d6240ea57 (patch) | |
tree | 1ad07f3d117ba228cdefef45c50d0fbc2baeed17 /src/network/core/address.cpp | |
parent | d466fa96727cdf0087367cb40dcba286ecec1878 (diff) | |
download | openttd-1eb4aa971ea329f18dd77b58bf7fc84d6240ea57.tar.xz |
(svn r15975) -Codechange: register each of the IPs we have bound to to the masterserver
Diffstat (limited to 'src/network/core/address.cpp')
-rw-r--r-- | src/network/core/address.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 14b52faa8..6045cc98b 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -16,7 +16,10 @@ const char *NetworkAddress::GetHostname() { if (StrEmpty(this->hostname)) { assert(this->address_length != 0); - getnameinfo((struct sockaddr *)&this->address, this->address_length, this->hostname, sizeof(this->hostname), NULL, 0, NI_NUMERICHOST); + char *buf = this->hostname; + if (this->address.ss_family == AF_INET6) buf = strecpy(buf, "[", lastof(this->hostname)); + getnameinfo((struct sockaddr *)&this->address, this->address_length, buf, lastof(this->hostname) - buf, NULL, 0, NI_NUMERICHOST); + if (this->address.ss_family == AF_INET6) strecat(buf, "]", lastof(this->hostname)); } return this->hostname; } @@ -92,6 +95,14 @@ const sockaddr_storage *NetworkAddress::GetAddress() return &this->address; } +bool NetworkAddress::IsFamily(int family) +{ + if (!this->IsResolved()) { + this->Resolve(family, SOCK_STREAM, AI_ADDRCONFIG, NULL, ResolveLoopProc); + } + return this->address.ss_family == family; +} + bool NetworkAddress::IsInNetmask(char *netmask) { /* Resolve it if we didn't do it already */ |