diff options
author | terminaldweller <devi@terminaldweller.com> | 2025-05-01 20:59:37 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2025-05-01 20:59:37 +0000 |
commit | 1cac36f267f7c0953090c134b7afc0706ee080a8 (patch) | |
tree | ed0964289dc9ebbefda1343bc3ab3f240abc80f8 /main.go | |
parent | using nginx as reverse proxy now (diff) | |
download | icanhazallips-1cac36f267f7c0953090c134b7afc0706ee080a8.tar.gz icanhazallips-1cac36f267f7c0953090c134b7afc0706ee080a8.zip |
added the proxy protocol to the servermain2
Diffstat (limited to '')
-rw-r--r-- | main.go (renamed from icanhazallips.go) | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/icanhazallips.go b/main.go index 1564ef4..48222bf 100644 --- a/icanhazallips.go +++ b/main.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)) } |