|
|
@@ -154,25 +154,32 @@ func getIP(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- rawIspInfo, ispInfo := getIPInfo(clientIP)
|
|
|
- ret.RawISPInfo = rawIspInfo
|
|
|
+ getISPInfo := r.FormValue("isp") == "true"
|
|
|
+ getDistance := r.FormValue("distance") == "true"
|
|
|
|
|
|
- removeRegexp := regexp.MustCompile(`AS\d+\s`)
|
|
|
- isp := removeRegexp.ReplaceAllString(ispInfo.Organization, "")
|
|
|
+ ret.ProcessedString = clientIP
|
|
|
|
|
|
- if isp == "" {
|
|
|
- isp = "Unknown ISP"
|
|
|
- }
|
|
|
+ if getISPInfo {
|
|
|
+ rawIspInfo, ispInfo := getIPInfo(clientIP)
|
|
|
+ ret.RawISPInfo = rawIspInfo
|
|
|
|
|
|
- if ispInfo.Country != "" {
|
|
|
- isp += ", " + ispInfo.Country
|
|
|
- }
|
|
|
+ removeRegexp := regexp.MustCompile(`AS\d+\s`)
|
|
|
+ isp := removeRegexp.ReplaceAllString(ispInfo.Organization, "")
|
|
|
|
|
|
- if ispInfo.Location != "" {
|
|
|
- isp += " (" + calculateDistance(ispInfo.Location, config.LoadedConfig().DistanceUnit) + ")"
|
|
|
- }
|
|
|
+ if isp == "" {
|
|
|
+ isp = "Unknown ISP"
|
|
|
+ }
|
|
|
|
|
|
- ret.ProcessedString = clientIP + " - " + isp
|
|
|
+ if ispInfo.Country != "" {
|
|
|
+ isp += ", " + ispInfo.Country
|
|
|
+ }
|
|
|
+
|
|
|
+ if ispInfo.Location != "" && getDistance {
|
|
|
+ isp += " (" + calculateDistance(ispInfo.Location, config.LoadedConfig().DistanceUnit) + ")"
|
|
|
+ }
|
|
|
+
|
|
|
+ ret.ProcessedString += " - " + isp
|
|
|
+ }
|
|
|
|
|
|
render.JSON(w, r, ret)
|
|
|
}
|