summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-20 15:12:13 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-20 15:12:13 +0200
commit9da3a20a0b58374618d8723d7c961dd45491ba13 (patch)
tree49977d5e881fd816e3046fc54a46776f39f9cc0b /proxy.c
parent77f9be38d7469eefb0fac3adf43261b4d84315d2 (diff)
Rename scfg to server throughout for consistency
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/proxy.c b/proxy.c
index 6ced85b..a629d7c 100644
--- a/proxy.c
+++ b/proxy.c
@@ -68,7 +68,7 @@ proxy_free(struct uring_task *task)
char duration[100];
debug(DBG_PROXY, "server: %s, src: %s, dst: %s",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr);
@@ -79,7 +79,7 @@ proxy_free(struct uring_task *task)
info("%s: proxy connection %s -> %s closed "
"(CtS: %s, StC: %s), duration %s",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr,
cts, stc, duration);
@@ -94,7 +94,7 @@ proxy_client_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, clienttask);
- debug(DBG_PROXY, "%s: client connection closed", proxy->scfg->name);
+ debug(DBG_PROXY, "%s: client connection closed", proxy->server->name);
}
static void
@@ -102,13 +102,13 @@ proxy_server_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, servertask);
- debug(DBG_PROXY, "%s: server connection closed", proxy->scfg->name);
+ debug(DBG_PROXY, "%s: server connection closed", proxy->server->name);
}
void
proxy_delete(struct cfg *cfg, struct server_proxy *proxy)
{
- debug(DBG_PROXY, "%s: shutting down proxy %p", proxy->scfg->name, proxy);
+ debug(DBG_PROXY, "%s: shutting down proxy %p", proxy->server->name, proxy);
uring_task_destroy(cfg, &proxy->servertask);
uring_task_destroy(cfg, &proxy->clienttask);
@@ -125,7 +125,7 @@ proxy_client_data_out(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -144,7 +144,7 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -154,7 +154,8 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
uring_tbuf_write(cfg, task, proxy_client_data_out);
}
-static void proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res);
+static void proxy_server_data_in(struct cfg *cfg, struct uring_task *task,
+ int res);
static void
proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
@@ -164,7 +165,7 @@ proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -183,7 +184,7 @@ proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res)
assert_task_alive(DBG_PROXY, task);
if (res <= 0) {
- debug(DBG_PROXY, "%s: result was %i", proxy->scfg->name, res);
+ debug(DBG_PROXY, "%s: result was %i", proxy->server->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -203,14 +204,14 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
if (!connected) {
error("%s: proxy connection to remote server failed",
- proxy->scfg->name);
+ proxy->server->name);
proxy_delete(cfg, proxy);
return;
}
proxy->sfd = proxy->servertask.fd;
verbose("%s: proxy connection %s -> %s opened",
- proxy->scfg->name,
+ proxy->server->name,
proxy->client_conn.remote.addrstr,
proxy->server_conn.remote.addrstr);
proxy->begin = time(NULL);
@@ -220,7 +221,7 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
}
struct server_proxy *
-proxy_new(struct cfg *cfg, struct server *scfg, struct saddr *client, int fd)
+proxy_new(struct cfg *cfg, struct server *server, struct saddr *client, int fd)
{
struct server_proxy *proxy;
@@ -232,21 +233,24 @@ proxy_new(struct cfg *cfg, struct server *scfg, struct saddr *client, int fd)
proxy->sfd = -1;
proxy->cfd = fd;
- proxy->scfg = scfg;
- uring_task_init(&proxy->task, "proxy", &scfg->task, proxy_free);
+ proxy->server = server;
+ uring_task_init(&proxy->task, "proxy", &server->task, proxy_free);
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_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);
- uring_task_init(&proxy->servertask, "proxy_server", &proxy->task, proxy_server_free);
+ uring_task_init(&proxy->servertask, "proxy_server", &proxy->task,
+ proxy_server_free);
uring_task_set_buf(&proxy->servertask, &proxy->serverbuf);
- list_add(&proxy->list, &scfg->proxys);
- connect_any(cfg, &proxy->servertask, &scfg->remotes, &proxy->server_conn, proxy_connected_cb);
+ list_add(&proxy->list, &server->proxys);
+ connect_any(cfg, &proxy->servertask, &server->remotes,
+ &proxy->server_conn, proxy_connected_cb);
return proxy;
}