Always return numeric service lookups

This commit is contained in:
Pierre Pronchery 2014-04-19 23:19:36 +02:00
parent 3a7c4e0e28
commit 7f4007d1d8
2 changed files with 8 additions and 5 deletions

View File

@ -432,6 +432,7 @@ static int _tcp_server_add_client(TCP * tcp, TCPSocket * client)
#endif
char host[NI_MAXHOST];
char const * name = host;
const int flags = NI_NUMERICSERV;
if((p = realloc(tcp->u.server.clients, sizeof(*p)
* (tcp->u.server.clients_cnt + 1)))
@ -440,9 +441,10 @@ static int _tcp_server_add_client(TCP * tcp, TCPSocket * client)
tcp->u.server.clients = p;
/* XXX may not be instant */
if(getnameinfo(client->sa, client->sa_len, host, sizeof(host), NULL, 0,
NI_NAMEREQD) != 0
NI_NAMEREQD | flags) != 0
&& getnameinfo(client->sa, client->sa_len, host,
sizeof(host), NULL, 0, NI_NUMERICHOST) != 0)
sizeof(host), NULL, 0, NI_NUMERICHOST | flags)
!= 0)
name = NULL;
if((client->client = tcp->helper->client_new(tcp->helper->transport,
name)) == NULL)

View File

@ -398,15 +398,16 @@ static int _udp_client_init(UDPClient * client, struct sockaddr * sa,
#endif
char host[NI_MAXHOST];
char const * name = host;
const int flags = NI_NUMERICSERV | NI_DGRAM;
if((client->sa = malloc(sa_len)) == NULL)
return -1;
/* XXX may not be instant */
if(getnameinfo(client->sa, client->sa_len, host, sizeof(host), NULL, 0,
NI_NAMEREQD | NI_DGRAM) != 0
NI_NAMEREQD | flags) != 0
&& getnameinfo(client->sa, client->sa_len, host,
sizeof(host), NULL, 0,
NI_NUMERICHOST | NI_DGRAM) != 0)
sizeof(host), NULL, 0, NI_NUMERICHOST | flags)
!= 0)
name = NULL;
if((client->client = helper->client_new(helper->transport, name))
== NULL)