mirror of https://github.com/BOINC/boinc.git
client: try to report an IP address other than loopback
This commit is contained in:
parent
c7aaf64423
commit
861042c00f
|
@ -146,8 +146,12 @@ int resolve_hostname(const char* hostname, sockaddr_storage &ip_addr) {
|
|||
if (!hep) {
|
||||
return ERR_GETHOSTBYNAME;
|
||||
}
|
||||
ip_addr.sin_family = AF_INET;
|
||||
ip_addr.sin_addr.s_addr = *(int*)hep->h_addr_list[0];
|
||||
for (int i=0; ; i++) {
|
||||
if (!hep->h_addr_list[i]) break;
|
||||
ip_addr.sin_family = AF_INET;
|
||||
ip_addr.sin_addr.s_addr = *(int*)hep->h_addr_list[i];
|
||||
if ((ip_addr.sin_addr.s_addr&0xff) != 0x7f) return 0; // look for non-loopback addr
|
||||
}
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
@ -162,7 +166,11 @@ int resolve_hostname(const char* hostname, sockaddr_storage &ip_addr) {
|
|||
perror("getaddrinfo");
|
||||
return retval;
|
||||
}
|
||||
memcpy(&ip_addr, res->ai_addr, res->ai_addrlen);
|
||||
while (1) {
|
||||
memcpy(&ip_addr, res->ai_addr, res->ai_addrlen);
|
||||
if ((ip_addr.sin_addr.s_addr&0xff) != 0x7f) break;
|
||||
res = res->ai_next;
|
||||
}
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue