From 8c1bdb219066cf4d596c229be6757265065b36f4 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 17 Jan 2024 11:38:53 -0800 Subject: [PATCH] Fix Unix listener causing 500s on Mac (#4243) Some platforms use `@` for a Unix socket address, and some leave it empty. In the empty case this causes the rate limiting code to throw a 500 error. This commit standardizes on using `@` for incoming connections over a Unix socket. --- internal/daemon/common/client_ip.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/daemon/common/client_ip.go b/internal/daemon/common/client_ip.go index 9a55b3a83..60ffa492c 100644 --- a/internal/daemon/common/client_ip.go +++ b/internal/daemon/common/client_ip.go @@ -34,6 +34,12 @@ func ClientIpFromRequest(ctx context.Context, listenerCfg *listenerutil.Listener if err != nil { return "", errors.Wrap(ctx, err, op) } + if listenerCfg.Type == "unix" && ip == "" { + // Some platforms (Linux) use "@" in this case but some like Mac + // leave it empty which causes issues with the rate limiting logic, + // so standardize on "@" in this case. + return "@", nil + } return ip, nil case trustedForwardedFor == nil && remoteAddr != nil: // not reachable given listenerutil.TrustedFromXForwardedFor