aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'server.c')
-rw-r--r--server.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/server.c b/server.c
index 0a0b3e3..09b2645 100644
--- a/server.c
+++ b/server.c
@@ -1343,7 +1343,7 @@ do_accept(int sock, short et, void *d)
struct sockaddr_storage raddr;
struct sockaddr *sraddr;
socklen_t len;
- int fd;
+ int e, fd;
sraddr = (struct sockaddr *)&raddr;
len = sizeof(raddr);
@@ -1365,6 +1365,15 @@ do_accept(int sock, short et, void *d)
memcpy(&c->raddr, &raddr, sizeof(raddr));
c->raddrlen = len;
+ e = getnameinfo(sraddr, len, c->rhost, sizeof(c->rhost),
+ c->rserv, sizeof(c->rserv), NI_NUMERICHOST | NI_NUMERICSERV);
+ if (e != 0) {
+ log_warnx("getnameinfo failed: %s", gai_strerror(e));
+ close(c->fd);
+ free(c);
+ return;
+ }
+
if (tls_accept_socket(addr->ctx, &c->ctx, fd) == -1) {
log_warnx("failed to accept socket: %s", tls_error(c->ctx));
close(c->fd);