Merge 3a12fb53fb44ae839d67cf131bb5952ccb99a8d3 into 0f09c3a9b4626d9fe9979cf4d0521d6ae32ab646

This commit is contained in:
criciss 2026-10-13 02:21:32 -07:00 committed by GitHub
commit e6674b6a04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

5
gin.go
View File

@ -11,6 +11,7 @@ import (
"net/http"
"os"
"path"
"slices"
"strings"
"sync"
"time"
@ -507,8 +508,8 @@ func (engine *Engine) validateHeader(header string) (clientIP string, valid bool
return "", false
}
items := strings.Split(header, ",")
for i := len(items) - 1; i >= 0; i-- {
ipStr := strings.TrimSpace(items[i])
for i, item := range slices.Backward(items) {
ipStr := strings.TrimSpace(item)
ip := net.ParseIP(ipStr)
if ip == nil {
break