summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.c15
1 files 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, "<unknown>");
+ 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");