|
@@ -115,7 +115,7 @@ func (gip GeoIP) lookupLocation(w http.ResponseWriter, r *http.Request) {
|
|
}
|
|
}
|
|
|
|
|
|
func (gip GeoIP) fetchGeoipData(r *http.Request) GeoIPRecord {
|
|
func (gip GeoIP) fetchGeoipData(r *http.Request) GeoIPRecord {
|
|
- clientIP, _ := getClientIP(r, true)
|
|
|
|
|
|
+ clientIP, _ := getClientIP(r, false)
|
|
|
|
|
|
var record = GeoIPRecord{}
|
|
var record = GeoIPRecord{}
|
|
err := gip.DBHandler.Lookup(clientIP, &record)
|
|
err := gip.DBHandler.Lookup(clientIP, &record)
|
|
@@ -147,8 +147,7 @@ func getClientIP(r *http.Request, strict bool) (net.IP, error) {
|
|
|
|
|
|
// Use the client ip from the 'X-Forwarded-For' header, if available.
|
|
// Use the client ip from the 'X-Forwarded-For' header, if available.
|
|
if fwdFor := r.Header.Get("CF-Connecting-IP"); fwdFor != "" && !strict {
|
|
if fwdFor := r.Header.Get("CF-Connecting-IP"); fwdFor != "" && !strict {
|
|
- ips := strings.Split(fwdFor, ", ")
|
|
|
|
- ip = ips[0]
|
|
|
|
|
|
+ ip = fwdFor
|
|
} else if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" && !strict {
|
|
} else if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" && !strict {
|
|
ips := strings.Split(fwdFor, ", ")
|
|
ips := strings.Split(fwdFor, ", ")
|
|
ip = ips[0]
|
|
ip = ips[0]
|