Tobias von Dewitz 5 년 전
부모
커밋
690350edde
1개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  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 {
 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]