Tobias von Dewitz 5 years ago
parent
commit
690350edde
1 changed files with 2 additions and 3 deletions
  1. 2 3
      setup.go

+ 2 - 3
setup.go

@@ -115,7 +115,7 @@ func (gip GeoIP) lookupLocation(w http.ResponseWriter, r *http.Request) {
 }
 
 func (gip GeoIP) fetchGeoipData(r *http.Request) GeoIPRecord {
-	clientIP, _ := getClientIP(r, true)
+	clientIP, _ := getClientIP(r, false)
 
 	var record = GeoIPRecord{}
 	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.
 	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 {
 		ips := strings.Split(fwdFor, ", ")
 		ip = ips[0]