(svn r15975) -Codechange: register each of the IPs we have bound to to the masterserver

This commit is contained in:
rubidium
2009-04-08 00:26:49 +00:00
parent d466fa9672
commit 1eb4aa971e
4 changed files with 39 additions and 7 deletions

View File

@@ -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 */