aboutsummaryrefslogtreecommitdiffstats
path: root/icanhazallips.go
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2025-05-01 20:55:00 +0000
committerterminaldweller <devi@terminaldweller.com>2025-05-01 20:55:00 +0000
commit137e164d028a18a9f4f251e2250553a6a3524d6c (patch)
treeb64225aee59912587b5477532606d78565b88e7c /icanhazallips.go
parentusing nginx as reverse proxy now (diff)
downloadicanhazallips-137e164d028a18a9f4f251e2250553a6a3524d6c.tar.gz
icanhazallips-137e164d028a18a9f4f251e2250553a6a3524d6c.zip
added the proxy protocol to the server
Diffstat (limited to 'icanhazallips.go')
-rw-r--r--icanhazallips.go15
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))
}