From af233b6119585ff2cf437e5a7c6b634378dacbe2 Mon Sep 17 00:00:00 2001 From: clalbus Date: Mon, 14 Jan 2019 15:53:34 +0200 Subject: [PATCH] Allow to specify timeout values using ENV vars (#2) * Allow to specify timeout values using ENV vars * Cleanup README formatting * Sort env vars in alphabetical order * Read config values straight from environment * Revert code formatting Signed-off-by: Andrejs Volkovs --- Dockerfile | 6 ++++++ README.md | 40 ++++++++++++++++++++++++++++++++++++++-- magic-entrypoint.py | 12 ++++++------ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4859a42..bd3f039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,12 @@ ENV NAMESERVERS="208.67.222.222 8.8.8.8 208.67.220.220 8.8.4.4" \ LISTEN=:100 \ PRE_RESOLVE=0 \ TALK=talk:100 \ + TIMEOUT_CLIENT=5s \ + TIMEOUT_CLIENT_FIN=5s \ + TIMEOUT_CONNECT=5s \ + TIMEOUT_SERVER=5s \ + TIMEOUT_SERVER_FIN=5s \ + TIMEOUT_TUNNEL=5s \ UDP=0 \ VERBOSE=0 diff --git a/README.md b/README.md index e7ebc88..591dbd0 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ and it must be written in the format used by the [`bind`][] directive. By default (`:100`), it listens in every connection at port 100 (port 100? that's stupid!... Yes, read the title :point_up::expressionless:). -### `NAMESERVERS` +#### `$NAMESERVERS` Default: `208.67.222.222 8.8.8.8 208.67.220.220 8.8.4.4` to use OpenDNS and Google DNS resolution servers by default. Only used when [pre-resolving](#pre-resolve) is enabled. -### `PRE_RESOLVE` +#### `$PRE_RESOLVE` Default: `0` @@ -65,6 +65,42 @@ required by [HAProxy][]'s [`server`][] directive. By default (`talk:100`), it talks to a host named `talk` in port 100 too. +#### `$TIMEOUT_CLIENT` + +Default: `5s` + +This variable sets the maximum inactivity time on the client side. + +#### `$TIMEOUT_CLIENT_FIN` + +Default: `5s` + +This variable sets the inactivity timeout on the client side for half-closed connections. + +#### `$TIMEOUT_CONNECT` + +Default: `5s` + +This variable sets the maximum time to wait for a connection attempt to a server to succeed. + +#### `$TIMEOUT_SERVER` + +Default: `5s` + +This variable sets the maximum inactivity time on the server side. + +#### `$TIMEOUT_SERVER_FIN` + +Default: `5s` + +This variable sets the inactivity timeout on the server side for half-closed connection. + +#### `$TIMEOUT_TUNNEL` + +Default: `5s` + +This variable sets the maximum inactivity time on the client and server side for tunnels. + ### Multi-proxy mode This image supports proxying multiple ports at once, but keep in mind diff --git a/magic-entrypoint.py b/magic-entrypoint.py index aefd8d1..3b81553 100755 --- a/magic-entrypoint.py +++ b/magic-entrypoint.py @@ -29,12 +29,12 @@ defaults log global mode tcp - timeout client 5s - timeout client-fin 5s - timeout connect 5s - timeout server 5s - timeout server-fin 5s - timeout tunnel 5s + timeout client env(TIMEOUT_CLIENT) + timeout client-fin env(TIMEOUT_CLIENT_FIN) + timeout connect env(TIMEOUT_CONNECT) + timeout server env(TIMEOUT_SERVER) + timeout server-fin env(TIMEOUT_SERVER_FIN) + timeout tunnel env(TIMEOUT_TUNNEL) """ if len(LISTENS) != len(TALKS):