diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-08-17 16:17:11 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-08-17 16:59:59 +0200 |
commit | 3afd81df9b58a1a0356a1104bb80d17165f5787b (patch) | |
tree | 607cb9a850ba91888dc185ca749596dfa38e249f /kike.c | |
parent | 8632e5fe8335476b82233708dd3d751cf1e7026b (diff) | |
download | xK-3afd81df9b58a1a0356a1104bb80d17165f5787b.tar.gz xK-3afd81df9b58a1a0356a1104bb80d17165f5787b.tar.xz xK-3afd81df9b58a1a0356a1104bb80d17165f5787b.zip |
Deal better with displaying IPv6 addresses
Diffstat (limited to 'kike.c')
-rw-r--r-- | kike.c | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -2661,7 +2661,10 @@ on_irc_client_available (const struct pollfd *pfd, void *user_data) host, sizeof host, port, sizeof port, NI_NUMERICSERV); if (err) print_debug ("%s: %s", "getnameinfo", gai_strerror (err)); - print_debug ("accepted connection from %s:%s", host, port); + + char *address = format_host_port_pair (host, port); + print_debug ("accepted connection from %s", address); + free (address); struct client *c = xmalloc (sizeof *c); client_init (c); @@ -2922,26 +2925,27 @@ irc_listen (struct addrinfo *gai_iter) soft_assert (setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes) != -1); - char real_host[NI_MAXHOST], real_port[NI_MAXSERV]; - real_host[0] = real_port[0] = '\0'; + char host[NI_MAXHOST], port[NI_MAXSERV]; + host[0] = port[0] = '\0'; int err = getnameinfo (gai_iter->ai_addr, gai_iter->ai_addrlen, - real_host, sizeof real_host, real_port, sizeof real_port, + host, sizeof host, port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV); if (err) print_debug ("%s: %s", "getnameinfo", gai_strerror (err)); + char *address = format_host_port_pair (host, port); if (bind (fd, gai_iter->ai_addr, gai_iter->ai_addrlen)) - print_error ("bind to %s:%s failed: %s", - real_host, real_port, strerror (errno)); + print_error ("bind to %s failed: %s", address, strerror (errno)); else if (listen (fd, 16 /* arbitrary number */)) - print_error ("listen on %s:%s failed: %s", - real_host, real_port, strerror (errno)); + print_error ("listen on %s failed: %s", address, strerror (errno)); else { - print_status ("listening on %s:%s", real_host, real_port); + print_status ("listening on %s", address); + free (address); return fd; } + free (address); xclose (fd); return -1; } @@ -2954,8 +2958,10 @@ irc_listen_resolve (struct server_context *ctx, int err = getaddrinfo (host, port, gai_hints, &gai_result); if (err) { - print_error ("bind to %s:%s failed: %s: %s", - host, port, "getaddrinfo", gai_strerror (err)); + char *address = format_host_port_pair (host, port); + print_error ("bind to %s failed: %s: %s", + address, "getaddrinfo", gai_strerror (err)); + free (address); return; } |