From 7b2198f7e5036d57c72ef14562a110ed1efe0aa3 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 31 May 2022 06:04:12 -0700 Subject: [PATCH] handle IPv6 sourceIPs properly (#15005) --- go.mod | 2 +- go.sum | 4 ++-- internal/handlers/proxy.go | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7bba71457..30644668b 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/minio/kes v0.19.2 github.com/minio/madmin-go v1.3.14 github.com/minio/minio-go/v7 v7.0.27 - github.com/minio/pkg v1.1.23 + github.com/minio/pkg v1.1.24 github.com/minio/selfupdate v0.4.0 github.com/minio/sha256-simd v1.0.0 github.com/minio/simdjson-go v0.4.2 diff --git a/go.sum b/go.sum index eaf8032e0..c18a5551b 100644 --- a/go.sum +++ b/go.sum @@ -636,8 +636,8 @@ github.com/minio/minio-go/v7 v7.0.23/go.mod h1:ei5JjmxwHaMrgsMrn4U/+Nmg+d8MKS1U2 github.com/minio/minio-go/v7 v7.0.27 h1:yJCvm78B+2+ll1PqO9eSD1as6Ibw3IYnnD8PyBEB2zo= github.com/minio/minio-go/v7 v7.0.27/go.mod h1:x81+AX5gHSfCSqw7jxRKHvxUXMlE5uKX0Vb75Xk5yYg= github.com/minio/pkg v1.1.20/go.mod h1:Xo7LQshlxGa9shKwJ7NzQbgW4s8T/Wc1cOStR/eUiMY= -github.com/minio/pkg v1.1.23 h1:CJSoPslQCWZW3z3T79+pv9dVBDCQEK3ipiwXcoAtzY0= -github.com/minio/pkg v1.1.23/go.mod h1:z9PfmEI804KFkF6eY4LoGe8IDVvTCsYGVuaf58Dr0WI= +github.com/minio/pkg v1.1.24 h1:a2RCb6LgsCi9DvrripuvlFQRCNb5Hp1HIssnsUqLoZY= +github.com/minio/pkg v1.1.24/go.mod h1:z9PfmEI804KFkF6eY4LoGe8IDVvTCsYGVuaf58Dr0WI= github.com/minio/selfupdate v0.4.0 h1:A7t07pN4Ch1tBTIRStW0KhUVyykz+2muCqFsITQeEW8= github.com/minio/selfupdate v0.4.0/go.mod h1:mcDkzMgq8PRcpCRJo/NlPY7U45O5dfYl2Y0Rg7IustY= github.com/minio/sha256-simd v0.1.1/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= diff --git a/internal/handlers/proxy.go b/internal/handlers/proxy.go index f23d4fd73..aedab5b2d 100644 --- a/internal/handlers/proxy.go +++ b/internal/handlers/proxy.go @@ -123,5 +123,8 @@ func GetSourceIP(r *http.Request) string { // Default to remote address if headers not set. addr, _, _ = net.SplitHostPort(r.RemoteAddr) + if strings.ContainsRune(addr, ':') { + return "[" + addr + "]" + } return addr }