aboutsummaryrefslogtreecommitdiff
path: root/flags.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-24 22:10:19 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-24 22:10:19 +0800
commitd5c760736f453b2923252953c726240f787e52f6 (patch)
treee21cce4467666742bbea7c051768120ef5adbc23 /flags.go
parentRefactor (diff)
downloadpowxy-d5c760736f453b2923252953c726240f787e52f6.tar.gz
powxy-d5c760736f453b2923252953c726240f787e52f6.tar.zst
powxy-d5c760736f453b2923252953c726240f787e52f6.zip
Refactor again
Diffstat (limited to '')
-rw-r--r--flags.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/flags.go b/flags.go
index 49bd3ff..1cf8b63 100644
--- a/flags.go
+++ b/flags.go
@@ -6,9 +6,13 @@ package main
import "flag"
var (
- listenAddr string
- destHost string
- secondary bool
+ listenAddr string
+ destHost string
+ secondary bool
+ readTimeout int
+ writeTimeout int
+ idleTimeout int
+ readHeaderTimeout int
)
// This init parses command line flags.
@@ -18,6 +22,10 @@ func init() {
flag.StringVar(&listenAddr, "listen", ":8081", "address to listen on")
flag.StringVar(&destHost, "upstream", "http://127.0.0.1:8080", "destination url base to proxy to")
flag.BoolVar(&secondary, "secondary", false, "trust X-Forwarded-For headers")
+ flag.IntVar(&readTimeout, "read-timeout", 0, "read timeout in seconds, 0 for no timeout")
+ flag.IntVar(&writeTimeout, "write-timeout", 0, "write timeout in seconds, 0 for no timeout")
+ flag.IntVar(&idleTimeout, "idle-timeout", 0, "idle timeout in seconds, 0 for no timeout")
+ flag.IntVar(&readHeaderTimeout, "read-header-timeout", 30, "read header timeout in seconds, 0 for no timeout")
flag.Parse()
global.NeedBitsReverse = 256 - global.NeedBits
}