aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2025-05-01 20:59:37 +0000
committerterminaldweller <devi@terminaldweller.com>2025-05-01 20:59:37 +0000
commit1cac36f267f7c0953090c134b7afc0706ee080a8 (patch)
treeed0964289dc9ebbefda1343bc3ab3f240abc80f8 /main.go
parentusing nginx as reverse proxy now (diff)
downloadicanhazallips-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))
}