We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 436d046 commit 179ecffCopy full SHA for 179ecff
1 file changed
internal/utils/utils.go
@@ -85,12 +85,14 @@ func EnvSubst(input string) string {
85
}
86
87
func ReadUserIP(r *http.Request) string {
88
- IPAddress := r.Header.Get("X-Forwarded-For")
89
- if IPAddress == "" {
90
- host, _, _ := net.SplitHostPort(r.RemoteAddr)
91
- IPAddress = host
+ forwardedFor := r.Header.Get("X-Forwarded-For")
+ if forwardedFor != "" {
+ ips := strings.Split(forwardedFor, ",")
+ return strings.TrimSpace(ips[0])
92
93
- return IPAddress
+
94
+ host, _, _ := net.SplitHostPort(r.RemoteAddr)
95
+ return host
96
97
98
func StringInSlice(a string, list []string) bool {
0 commit comments