From d32c6d761462947fe8719dcfff98eb44572a6447 Mon Sep 17 00:00:00 2001 From: Peter Sanchez Date: Wed, 12 Jun 2024 14:39:42 -0600 Subject: [PATCH] Adding IPExtractor to echo instances --- cmd/api/main.go | 7 +++++++ cmd/links/main.go | 7 +++++++ cmd/list/main.go | 8 ++++++++ cmd/short/main.go | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/cmd/api/main.go b/cmd/api/main.go index dcb3fed..466f374 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -79,6 +79,13 @@ func run() error { } e := echo.New() + // https://echo.labstack.com/docs/ip-address + // Deployed via Caddy at the moment which uses X-Forwarded-For header by default + e.IPExtractor = echo.ExtractIPFromXFFHeader( + echo.TrustLoopback(false), + echo.TrustLinkLocal(false), + echo.TrustPrivateNet(false), + ) // email work queue and service, general task queue eq := email.NewQueue() diff --git a/cmd/links/main.go b/cmd/links/main.go index 75b1352..c2024f6 100644 --- a/cmd/links/main.go +++ b/cmd/links/main.go @@ -162,6 +162,13 @@ func run() error { tlsman := cmd.LoadAutoTLS(config, db, models.DomainServiceLinks) e := echo.New() + // https://echo.labstack.com/docs/ip-address + // Deployed via Caddy at the moment which uses X-Forwarded-For header by default + e.IPExtractor = echo.ExtractIPFromXFFHeader( + echo.TrustLoopback(false), + echo.TrustLinkLocal(false), + echo.TrustPrivateNet(false), + ) // email work queue and service, general task queue eq := email.NewQueue() diff --git a/cmd/list/main.go b/cmd/list/main.go index 60f010f..06c990c 100644 --- a/cmd/list/main.go +++ b/cmd/list/main.go @@ -66,6 +66,14 @@ func run() error { defer db.Close() e := echo.New() + // https://echo.labstack.com/docs/ip-address + // Deployed via Caddy at the moment which uses X-Forwarded-For header by default + e.IPExtractor = echo.ExtractIPFromXFFHeader( + echo.TrustLoopback(false), + echo.TrustLinkLocal(false), + echo.TrustPrivateNet(false), + ) + eq := email.NewQueue() wq := work.NewQueue("general") diff --git a/cmd/short/main.go b/cmd/short/main.go index d083b3b..1475409 100644 --- a/cmd/short/main.go +++ b/cmd/short/main.go @@ -64,6 +64,14 @@ func run() error { defer db.Close() e := echo.New() + // https://echo.labstack.com/docs/ip-address + // Deployed via Caddy at the moment which uses X-Forwarded-For header by default + e.IPExtractor = echo.ExtractIPFromXFFHeader( + echo.TrustLoopback(false), + echo.TrustLinkLocal(false), + echo.TrustPrivateNet(false), + ) + eq := email.NewQueue() wq := work.NewQueue("general") -- 2.45.2