Pass AF_UNSPEC to net_gethostbyname instead of 0

0 might be a valid family.
This commit is contained in:
LemonBoy 2015-09-24 11:25:09 +02:00
commit aeb3cd9dbf
4 changed files with 7 additions and 6 deletions

View file

@ -267,7 +267,7 @@ int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip,
rec->pipes[1] = g_io_channel_new(fd[1]); rec->pipes[1] = g_io_channel_new(fd[1]);
/* start nonblocking host name lookup */ /* start nonblocking host name lookup */
net_gethostbyname_nonblock(server, rec->pipes[1], 0, 0); net_gethostbyname_nonblock(server, rec->pipes[1], AF_UNSPEC, 0);
rec->tag = g_input_add(rec->pipes[0], G_INPUT_READ, rec->tag = g_input_add(rec->pipes[0], G_INPUT_READ,
(GInputFunction) simple_readpipe, rec); (GInputFunction) simple_readpipe, rec);

View file

@ -142,7 +142,7 @@ GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip)
g_return_val_if_fail(addr != NULL, NULL); g_return_val_if_fail(addr != NULL, NULL);
// XXX : should we use the my_ip->family instead ? // XXX : should we use the my_ip->family instead ?
if (net_gethostbyname(addr, &ip, 0) == -1) if (net_gethostbyname(addr, &ip, AF_UNSPEC) == -1)
return NULL; return NULL;
return net_connect_ip(&ip, port, my_ip); return net_connect_ip(&ip, port, my_ip);
@ -406,7 +406,7 @@ int net_gethostbyname(const char *addr, IPADDR *ip, int family)
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
hints.ai_family = (family == 0) ? AF_UNSPEC : family; hints.ai_family = family;
#else #else
hints.ai_family = AF_INET; hints.ai_family = AF_INET;
#endif #endif

View file

@ -56,7 +56,7 @@ static void get_source_host_ip(void)
/* FIXME: This will block! */ /* FIXME: This will block! */
hostname = settings_get_str("hostname"); hostname = settings_get_str("hostname");
source_host_ok = *hostname != '\0' && source_host_ok = *hostname != '\0' &&
net_gethostbyname(hostname, &source_host_ip, 0) == 0; net_gethostbyname(hostname, &source_host_ip, AF_UNSPEC) == 0;
} }
static void conn_set_ip(SERVER_CONNECT_REC *conn, const char *own_host, static void conn_set_ip(SERVER_CONNECT_REC *conn, const char *own_host,
@ -66,7 +66,7 @@ static void conn_set_ip(SERVER_CONNECT_REC *conn, const char *own_host,
if (*own_ip == NULL) { if (*own_ip == NULL) {
/* resolve the IP */ /* resolve the IP */
if (net_gethostbyname(own_host, &ip, 0) == 0) if (net_gethostbyname(own_host, &ip, AF_UNSPEC) == 0)
save_ips(&ip, own_ip); save_ips(&ip, own_ip);
} }
@ -103,6 +103,7 @@ static void server_setup_fill(SERVER_CONNECT_REC *conn,
conn->address = g_strdup(address); conn->address = g_strdup(address);
if (port > 0) conn->port = port; if (port > 0) conn->port = port;
conn->family = AF_UNSPEC;
if (strchr(address, '/') != NULL) if (strchr(address, '/') != NULL)
conn->unix_socket = TRUE; conn->unix_socket = TRUE;

View file

@ -593,7 +593,7 @@ static void add_listen(const char *ircnet, int port)
/* bind to specific host/ip? */ /* bind to specific host/ip? */
my_ip = NULL; my_ip = NULL;
if (*settings_get_str("irssiproxy_bind") != '\0') { if (*settings_get_str("irssiproxy_bind") != '\0') {
if (net_gethostbyname(settings_get_str("irssiproxy_bind"), &ip, 0) != 0) { if (net_gethostbyname(settings_get_str("irssiproxy_bind"), &ip, AF_UNSPEC) != 0) {
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, printtext(NULL, NULL, MSGLEVEL_CLIENTERROR,
"Proxy: can not resolve '%s' - aborting", "Proxy: can not resolve '%s' - aborting",
settings_get_str("irssiproxy_bind")); settings_get_str("irssiproxy_bind"));