diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-23 12:02:53 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-23 12:02:53 +0800 |
commit | 0b41e4437925da2afe4579f192f55fe927c83058 (patch) | |
tree | a3897da084bbeef7fecfbf8dafc3401cb2e02ab7 | |
parent | Separate unsafe operations to unsafe.go (diff) | |
download | powxy-0b41e4437925da2afe4579f192f55fe927c83058.tar.gz powxy-0b41e4437925da2afe4579f192f55fe927c83058.tar.zst powxy-0b41e4437925da2afe4579f192f55fe927c83058.zip |
Separate flags
-rw-r--r-- | flags.go | 18 | ||||
-rw-r--r-- | main.go | 16 |
2 files changed, 18 insertions, 16 deletions
diff --git a/flags.go b/flags.go new file mode 100644 index 0000000..ee3b817 --- /dev/null +++ b/flags.go @@ -0,0 +1,18 @@ +package main + +import "flag" + +var ( + difficulty uint + listenAddr string + destHost string + secondary bool +) + +func init() { + flag.UintVar(&difficulty, "difficulty", 17, "leading zero bits required for the challenge") + 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.Parse() +} @@ -8,7 +8,6 @@ import ( "encoding/base64" "encoding/binary" "errors" - "flag" "log" "net/http" "net/http/httputil" @@ -18,21 +17,6 @@ import ( ) var ( - difficulty uint - listenAddr string - destHost string - secondary bool -) - -func init() { - flag.UintVar(&difficulty, "difficulty", 17, "leading zero bits required for the challenge") - 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.Parse() -} - -var ( privkey = make([]byte, 32) privkeyHash = make([]byte, 0, sha256.Size) ) |