mirror of
https://github.com/skidoodle/ipinfo.git
synced 2025-02-15 08:29:17 +01:00
chore: Update IP address retrieval logic in main.go
This commit is contained in:
parent
39d4ccda0e
commit
7b0b417287
1 changed files with 1 additions and 1 deletions
2
main.go
2
main.go
|
@ -188,7 +188,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if IPAddress == "" || IPAddress == "self" {
|
||||
if realIP, ok := r.Header["X-Real-Ip"]; ok && len(realIP) > 0 {
|
||||
if realIP, ok := r.Header["X-Forwarded-For"]; ok && len(realIP) > 0 {
|
||||
IPAddress = realIP[0]
|
||||
} else {
|
||||
IPAddress = extractIP(r.RemoteAddr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue