version 1.67, 2013/05/17 00:13:13 |
version 1.68, 2013/10/14 23:28:22 |
|
|
get_remote_hostname(int sock, int use_dns) |
get_remote_hostname(int sock, int use_dns) |
{ |
{ |
struct sockaddr_storage from; |
struct sockaddr_storage from; |
int i; |
|
socklen_t fromlen; |
socklen_t fromlen; |
struct addrinfo hints, *ai, *aitop; |
struct addrinfo hints, *ai, *aitop; |
char name[NI_MAXHOST], ntop[NI_MAXHOST], ntop2[NI_MAXHOST]; |
char name[NI_MAXHOST], ntop[NI_MAXHOST], ntop2[NI_MAXHOST]; |
|
|
return xstrdup(ntop); |
return xstrdup(ntop); |
} |
} |
|
|
/* |
/* Names are stores in lowercase. */ |
* Convert it to all lowercase (which is expected by the rest |
lowercase(name); |
* of this software). |
|
*/ |
|
for (i = 0; name[i]; i++) |
|
if (isupper(name[i])) |
|
name[i] = (char)tolower(name[i]); |
|
/* |
/* |
* Map it back to an IP address and check that the given |
* Map it back to an IP address and check that the given |
* address actually is an address of this host. This is |
* address actually is an address of this host. This is |