mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 08:25:14 +00:00
Add X-REAL-IP
This commit is contained in:
parent
d2e309b699
commit
91e1e83466
@ -46,10 +46,14 @@ func getUserIp(r *http.Request) net.IP {
|
|||||||
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
||||||
if contains(ReverseProxies, host) {
|
if contains(ReverseProxies, host) {
|
||||||
forwardedFor := r.Header.Get("X-Forwarded-For")
|
forwardedFor := r.Header.Get("X-Forwarded-For")
|
||||||
if forwardedFor != "" {
|
if !contains(ReverseProxies, forwardedFor) {
|
||||||
host = forwardedFor
|
host = forwardedFor
|
||||||
|
} else {
|
||||||
|
realIp := r.Header.Get("X-Real-IP")
|
||||||
|
if !contains(ReverseProxies, realIp) {
|
||||||
|
host = realIp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// realIp := r.Header.Get("X-Real-IP")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ip = net.ParseIP(host)
|
ip = net.ParseIP(host)
|
||||||
|
Loading…
Reference in New Issue
Block a user