From 2d426b64c32b5054f21efc5741d32e526cf7ed7c Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Mon, 8 Feb 2021 14:24:48 +0100 Subject: [PATCH] =?UTF-8?q?add=20explanation=20=F0=9F=A6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- context.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 9efaaabd..3e040761 100644 --- a/context.go +++ b/context.go @@ -777,7 +777,7 @@ func (c *Context) RemoteIP() (net.IP, bool) { func validateHeader(header string) (clientIP string, valid bool) { if header == "" { - return + return "", false } items := strings.Split(header, ",") for i, ipStr := range items { @@ -786,6 +786,10 @@ func validateHeader(header string) (clientIP string, valid bool) { if ip == nil { return "", false } + + // We need to return the first IP in the list, but, + // we should not early return since we need to validate that + // the rest of the header is syntactically valid if i == 0 { clientIP = ipStr valid = true