summaryrefslogtreecommitdiff
path: root/proxy.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-16 15:54:33 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-16 15:54:33 +0200
commit202fdce48fd8fb04778bd3c7e30a036a68b32ba2 (patch)
tree80045d42e0248acbb5c22e46d79d40c49160357a /proxy.c
parent7b2240a7a9387068f8da0f9bfeac90ec27034878 (diff)
Convert cfgdir and proxy to use debugging
Diffstat (limited to 'proxy.c')
-rw-r--r--proxy.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/proxy.c b/proxy.c
index 125c408..91b7c02 100644
--- a/proxy.c
+++ b/proxy.c
@@ -74,12 +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->client_conn.remotestr,
- proxy->server_conn.remotestr,
- cts, stc, duration);
+ info("%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);
@@ -91,7 +91,7 @@ proxy_client_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, clienttask);
- fprintf(stderr, "%s: %s client connection closed\n", __func__, proxy->scfg->name);
+ debug(DBG_PROXY, "%s: client connection closed\n", proxy->scfg->name);
}
static void
@@ -99,13 +99,13 @@ proxy_server_free(struct uring_task *task)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, servertask);
- fprintf(stderr, "%s: %s server connection closed\n", __func__, proxy->scfg->name);
+ debug(DBG_PROXY, "%s: server connection closed\n", proxy->scfg->name);
}
void
proxy_delete(struct cfg *cfg, struct server_proxy *proxy)
{
- fprintf(stderr, "%s: shutting down proxy 0x%p\n", __func__, proxy);
+ debug(DBG_PROXY, "%s: shutting down proxy %p\n", proxy->scfg->name, proxy);
uring_task_destroy(cfg, &proxy->servertask);
uring_task_destroy(cfg, &proxy->clienttask);
@@ -119,8 +119,8 @@ proxy_client_data_out(struct cfg *cfg, struct uring_task *task, int res)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, clienttask);
- fprintf(stderr, "%s: result was %i\n", __func__, res);
if (res <= 0) {
+ debug(DBG_PROXY, "%s: result was %i\n", proxy->scfg->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -136,8 +136,8 @@ proxy_client_data_in(struct cfg *cfg, struct uring_task *task, int res)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, clienttask);
- fprintf(stderr, "%s: result was %i\n", __func__, res);
if (res <= 0) {
+ debug(DBG_PROXY, "%s: result was %i\n", proxy->scfg->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -154,8 +154,8 @@ proxy_server_data_out(struct cfg *cfg, struct uring_task *task, int res)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, servertask);
- fprintf(stderr, "%s: result was %i\n", __func__, res);
if (res <= 0) {
+ debug(DBG_PROXY, "%s: result was %i\n", proxy->scfg->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -171,8 +171,8 @@ proxy_server_data_in(struct cfg *cfg, struct uring_task *task, int res)
{
struct server_proxy *proxy = container_of(task, struct server_proxy, servertask);
- fprintf(stderr, "%s: result was %i\n", __func__, res);
if (res <= 0) {
+ debug(DBG_PROXY, "%s: result was %i\n", proxy->scfg->name, res);
uring_task_close_fd(cfg, task);
proxy_delete(cfg, proxy);
return;
@@ -188,14 +188,14 @@ proxy_connected_cb(struct cfg *cfg, struct connection *conn, bool connected)
struct server_proxy *proxy = container_of(conn, struct server_proxy, server_conn);
if (!connected) {
- fprintf(stderr, "%s: proxy connection to remote server failed\n",
- proxy->scfg->name);
+ error("%s: proxy connection to remote server failed\n",
+ proxy->scfg->name);
proxy_delete(cfg, proxy);
return;
}
proxy->sfd = proxy->servertask.fd;
- fprintf(stderr, "%s: proxy connection %s -> %s opened\n",
+ verbose("%s: proxy connection %s -> %s opened\n",
proxy->scfg->name,
proxy->client_conn.remotestr,
proxy->server_conn.remotestr);
@@ -212,7 +212,7 @@ proxy_new(struct cfg *cfg, struct server *scfg, struct sockaddr_in46 *client, in
proxy = zmalloc(sizeof(*proxy));
if (!proxy) {
- perror("malloc");
+ error("malloc: %m");
return NULL;
}