diff options
author | terminaldweller <devi@terminaldweller.com> | 2025-05-01 20:55:00 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2025-05-01 20:55:00 +0000 |
commit | 137e164d028a18a9f4f251e2250553a6a3524d6c (patch) | |
tree | b64225aee59912587b5477532606d78565b88e7c /icanhazallips.go | |
parent | using nginx as reverse proxy now (diff) | |
download | icanhazallips-137e164d028a18a9f4f251e2250553a6a3524d6c.tar.gz icanhazallips-137e164d028a18a9f4f251e2250553a6a3524d6c.zip |
added the proxy protocol to the server
Diffstat (limited to 'icanhazallips.go')
-rw-r--r-- | icanhazallips.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/icanhazallips.go b/icanhazallips.go index 1564ef4..48222bf 100644 --- a/icanhazallips.go +++ b/icanhazallips.go @@ -10,6 +10,8 @@ import ( "strconv" "strings" "time" + + "github.com/pires/go-proxyproto" ) const ( @@ -166,5 +168,16 @@ func main() { Handler: nil, } - log.Fatal(server.ListenAndServe()) + ln, err := net.Listen("tcp", config.Addr) + if err != nil { + log.Fatal(err) + } + + proxyListener := &proxyproto.Listener{ + Listener: ln, + ReadHeaderTimeout: time.Duration(config.ReadHeaderTimeout) * time.Second, + } + defer proxyListener.Close() + + log.Fatal(server.Serve(proxyListener)) } |