From 0b41e4437925da2afe4579f192f55fe927c83058 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 23 Mar 2025 12:02:53 +0800 Subject: Separate flags --- flags.go | 18 ++++++++++++++++++ main.go | 16 ---------------- 2 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 flags.go 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() +} diff --git a/main.go b/main.go index bef172b..61fa133 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "encoding/base64" "encoding/binary" "errors" - "flag" "log" "net/http" "net/http/httputil" @@ -17,21 +16,6 @@ import ( "time" ) -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) -- cgit v1.2.3