From fa25599e90a7535a02641ef03ccfc138cf5c8fd3 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Mon, 22 Jun 2020 22:42:57 +0200 Subject: Add some more config options --- server-proxy.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'server-proxy.c') diff --git a/server-proxy.c b/server-proxy.c index f897aa2..4cbbb87 100644 --- a/server-proxy.c +++ b/server-proxy.c @@ -402,9 +402,15 @@ proxy_new(struct server *server, struct saddr *client, int fd) list_add(&proxy->list, &server->proxys); if (server->state != SERVER_STATE_RUNNING) { - server_start(server); - ptask_init(&proxy->ptask, 3, 20, proxy_connect_timer_cb); - ptimer_add_task(&proxy->ptask); + if (server_start(server) && + cfg->proxy_connection_interval > 0 && + cfg->proxy_connection_attempts > 0) { + ptask_init(&proxy->ptask, + cfg->proxy_connection_interval, + cfg->proxy_connection_attempts, + proxy_connect_timer_cb); + ptimer_add_task(&proxy->ptask); + } } proxy->connecting = true; @@ -481,15 +487,21 @@ local_open(struct server_local *local) } /* The MC protocol expects the client to send data first */ - /* FIXME: could make this configurable */ - option = true; - if (setsockopt(sfd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &option, sizeof(option)) < 0) - error("setsockopt: %m"); + if (cfg->socket_defer) { + option = true; + if (setsockopt(sfd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &option, sizeof(option)) < 0) + error("setsockopt: %m"); + } - /* FIXME: could make this configurable */ - option = true; - if (setsockopt(sfd, IPPROTO_IP, IP_FREEBIND, &option, sizeof(option)) < 0) - error("setsockopt: %m"); + /* + * This has the advantage that interfaces don't need to be up but + * it means that cfg errors will not be caught. + */ + if (cfg->socket_freebind) { + option = true; + if (setsockopt(sfd, IPPROTO_IP, IP_FREEBIND, &option, sizeof(option)) < 0) + error("setsockopt: %m"); + } socket_set_low_latency(sfd); -- cgit v1.2.3