diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-11 12:45:04 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-11 12:45:04 +0200 |
commit | e9ba9f703ec1afa09e004de097ba5d8666c481ea (patch) | |
tree | 315f662eb073076c13cfc1c57d3ee753c168bb60 | |
parent | ca46c321915798818d6716fb5c2be9f538f2e722 (diff) |
Improve log message for incoming proxy connection
-rw-r--r-- | server.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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"); |