summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-11 23:21:37 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-11 23:21:37 +0200
commitea836c09048453babda517e6a440d7266304ca02 (patch)
tree8607a39388df4bbf647495090470222b806ff542 /proxy.c
parent76e6067e13831569deca05dbb557d921998e3eb2 (diff)
Use struct connect for the client connection as well in proxy
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/proxy.c b/proxy.c
index 58f81ca..d06803d 100644
--- a/proxy.c
+++ b/proxy.c
@@ -74,9 +74,12 @@ proxy_free(struct uring_task *task)
format_bytes(cts, sizeof(cts), proxy->client_bytes);
format_bytes(stc, sizeof(stc), proxy->server_bytes);
- fprintf(stderr, "%s: proxy connection %s -> %s closed (CtS: %s, StC: %s), duration %s\n",
- proxy->scfg->name, proxy->clientstr, proxy->serverstr, cts, stc,
- duration);
+ fprintf(stderr, "%s: proxy connection %s -> %s closed "
+ "(CtS: %s, StC: %s), duration %s\n",
+ proxy->scfg->name,
+ proxy->client_conn.remotestr,
+ proxy->server_conn.remotestr,
+ cts, stc, duration);
}
list_del(&proxy->list);
@@ -193,7 +196,9 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, int res)
proxy->sfd = proxy->servertask.fd;
fprintf(stderr, "%s: proxy connection %s -> %s opened\n",
- proxy->scfg->name, proxy->clientstr, proxy->server_conn.remotestr);
+ proxy->scfg->name,
+ proxy->client_conn.remotestr,
+ proxy->server_conn.remotestr);
proxy->begin = time(NULL);
uring_tbuf_read(cfg, &proxy->clienttask, proxy_client_data_in);
@@ -214,10 +219,11 @@ proxy_new(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *client, in
proxy->sfd = -1;
proxy->cfd = fd;
proxy->scfg = scfg;
- proxy->client = *client;
uring_task_init(&proxy->task, "proxy", &scfg->task, proxy_free);
- sockaddr_to_str(&proxy->client, proxy->clientstr, sizeof(proxy->clientstr));
+ connection_set_local(cfg, &proxy->client_conn, fd);
+ connection_set_remote(cfg, &proxy->client_conn, client);
+
uring_task_init(&proxy->clienttask, "proxy_client", &proxy->task, proxy_client_free);
uring_task_set_buf(&proxy->clienttask, &proxy->clientbuf);
uring_task_set_fd(&proxy->clienttask, fd);