mirror of
https://github.com/idanoo/GoScrobble
synced 2025-06-30 21:22:18 +00:00
Add X-REAL-IP
This commit is contained in:
parent
d2e309b699
commit
91e1e83466
1 changed files with 6 additions and 2 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue