mirror of https://github.com/gophish/gophish
Adjusting how we handle IP address parsing to more gracefully handle X-Forwarded-For headers. Ref #1999
parent
120e232cfe
commit
8b8e88b077
|
@ -360,12 +360,7 @@ func setupContext(r *http.Request) (*http.Request, error) {
|
||||||
}
|
}
|
||||||
ip, _, err := net.SplitHostPort(r.RemoteAddr)
|
ip, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
ip = r.RemoteAddr
|
||||||
return r, err
|
|
||||||
}
|
|
||||||
// Respect X-Forwarded headers
|
|
||||||
if fips := r.Header.Get("X-Forwarded-For"); fips != "" {
|
|
||||||
ip = strings.Split(fips, ", ")[0]
|
|
||||||
}
|
}
|
||||||
// Handle post processing such as GeoIP
|
// Handle post processing such as GeoIP
|
||||||
err = rs.UpdateGeo(ip)
|
err = rs.UpdateGeo(ip)
|
||||||
|
|
Loading…
Reference in New Issue