From 39d25d222321e57c66e5dc22bc3fa741f0885760 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 2 Apr 2024 16:44:59 +0200 Subject: [PATCH] Replace IPv6 unspecified address for watchdog health checks --- cmd/poseidon/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/poseidon/main.go b/cmd/poseidon/main.go index faa51f4..9f0df91 100644 --- a/cmd/poseidon/main.go +++ b/cmd/poseidon/main.go @@ -24,6 +24,7 @@ import ( "net/http" "os" "os/signal" + "regexp" "runtime" "runtime/debug" "runtime/pprof" @@ -257,7 +258,10 @@ func systemdWatchdogLoop(ctx context.Context, router *mux.Router, interval time. return } healthURL := config.Config.Server.URL().String() + healthRoute.String() - healthURL = strings.ReplaceAll(healthURL, "0.0.0.0", "localhost") // Workaround for certificate subject names + + // Workaround for certificate subject names + unspecifiedAddresses := regexp.MustCompile(`0\.0\.0\.0|\[::]`) + healthURL = unspecifiedAddresses.ReplaceAllString(healthURL, "localhost") client := &http.Client{} if config.Config.Server.TLS.Active {