From e9ba9f703ec1afa09e004de097ba5d8666c481ea Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 11 Jun 2020 12:45:04 +0200 Subject: Improve log message for incoming proxy connection --- server.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server.c b/server.c index 3cc2398..913fbfe 100644 --- a/server.c +++ b/server.c @@ -179,7 +179,9 @@ server_local_accept(struct cfg *cfg, struct uring_task *task, int res) struct server_local *local = container_of(task, struct server_local, task); struct server *scfg = container_of(task->parent, struct server, task); struct server_proxy *proxy; - char abuf[ADDRSTRLEN]; + char pbuf[ADDRSTRLEN]; + struct sockaddr_in46 laddr = { .addrlen = sizeof(laddr) } ; + char lbuf[ADDRSTRLEN]; fprintf(stderr, "%s called: task 0x%p and res %i\n", __func__, task, res); fprintf(stderr, "%s called: scfg name is %s\n", __func__, scfg->name); @@ -194,8 +196,15 @@ server_local_accept(struct cfg *cfg, struct uring_task *task, int res) goto out; } - sockaddr_to_str(&local->peer, abuf, sizeof(abuf)); - fprintf(stderr, "%s: incoming proxy connection: %s -> %s\n", scfg->name, abuf, local->addrstr); + if (getsockname(res, (struct sockaddr *)&laddr.storage, &laddr.addrlen) < 0) + sprintf(lbuf, ""); + else + sockaddr_to_str(&laddr, lbuf, sizeof(lbuf)); + + sockaddr_to_str(&local->peer, pbuf, sizeof(pbuf)); + + fprintf(stderr, "%s: incoming proxy connection: %s -> %s (%s)\n", + scfg->name, pbuf, lbuf, local->addrstr); if (list_empty(&scfg->remotes)) { error("scfg->remotes empty!\n"); -- cgit v1.2.3