From 137e164d028a18a9f4f251e2250553a6a3524d6c Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 1 May 2025 20:55:00 +0000 Subject: added the proxy protocol to the server --- icanhazallips.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'icanhazallips.go') 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)) } -- cgit v1.2.3