Match distance
query parameter behavior with PHP backend
This commit is contained in:
parent
f7ccda23e1
commit
275286cd79
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
results/idObfuscation_salt.php
|
||||
backend/getIP_serverLocation.php
|
||||
speedtest.db
|
||||
.idea/
|
|
@ -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"
|
||||
|
|
|
@ -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"`
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue