diff --git a/.gitignore b/.gitignore index c53159e..9224f4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ results/idObfuscation_salt.php backend/getIP_serverLocation.php +speedtest.db +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index 95f4c83..0997439 100644 --- a/README.md +++ b/README.md @@ -72,8 +72,6 @@ You need Go 1.13+ to compile the binary. download_chunks=4 # ipinfo.io API key, if applicable ipinfo_api_key="" - # distance unit used in frontend, available options: M (miles), K (kilometers), N (nautical miles), default is "K" - distance_unit="K" # password for logging into statistics page, change this to enable stats page statistics_password="PASSWORD" diff --git a/config/config.go b/config/config.go index 7e889dc..0660ca5 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,6 @@ type Config struct { Port string `mapstructure:"listen_port"` DownloadChunks int `mapstructure:"download_chunks"` IPInfoAPIKey string `mapstructure:"ipinfo_api_key"` - DistanceUnit string `mapstructure:"distance_unit"` StatsPassword string `mapstructure:"statistics_password"` RedactIP bool `mapstructure:"redact_ip_addresses"` diff --git a/settings.toml b/settings.toml index 5a9566c..0ce222d 100644 --- a/settings.toml +++ b/settings.toml @@ -6,8 +6,6 @@ listen_port=8989 download_chunks=4 # ipinfo.io API key, if applicable ipinfo_api_key="" -# distance unit used in frontend, available options: M (miles), K (kilometers), N (nautical miles) -distance_unit="K" # password for logging into statistics page statistics_password="PASSWORD" diff --git a/web/helpers.go b/web/helpers.go index 32e1eda..31688fd 100644 --- a/web/helpers.go +++ b/web/helpers.go @@ -143,10 +143,10 @@ func calculateDistance(clientLocation string, unit string) string { unitString := " mi" switch unit { - case "K": + case "km": dist = dist * 1.609344 unitString = " km" - case "N": + case "NM": dist = dist * 0.8684 unitString = " NM" } diff --git a/web/web.go b/web/web.go index 72bf4f2..6eb0623 100644 --- a/web/web.go +++ b/web/web.go @@ -155,7 +155,7 @@ func getIP(w http.ResponseWriter, r *http.Request) { } getISPInfo := r.FormValue("isp") == "true" - getDistance := r.FormValue("distance") == "true" + distanceUnit := r.FormValue("distance") ret.ProcessedString = clientIP @@ -174,8 +174,8 @@ func getIP(w http.ResponseWriter, r *http.Request) { isp += ", " + ispInfo.Country } - if ispInfo.Location != "" && getDistance { - isp += " (" + calculateDistance(ispInfo.Location, config.LoadedConfig().DistanceUnit) + ")" + if ispInfo.Location != "" { + isp += " (" + calculateDistance(ispInfo.Location, distanceUnit) + ")" } ret.ProcessedString += " - " + isp