diff options
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; } |