speedtest-go icon indicating copy to clipboard operation
speedtest-go copied to clipboard

feat: validate the cc when using city params

Open gandol opened this issue 1 year ago • 14 comments

when just use lat lon the countty not correct, with these fix can check the valid county by the cc

gandol avatar Feb 10 '24 17:02 gandol

previous code not realy filter the cc, i just update it

gandol avatar Feb 11 '24 07:02 gandol

Hi, @gandol. It doesn't seem to work because cc was not set when using lat and lon.

r3inbowari avatar Feb 23 '24 08:02 r3inbowari

yeah its true, if the cc was not filtered set because of this if s.config.Location != nil

so the filter can run only if the cc was set before i think when use lat lon the expected result was not filtered by the cc

gandol avatar Feb 28 '24 17:02 gandol

We can preload cc from here. const speedTestConfigUrl = "https://www.speedtest.net/speedtest-config.php"

r3inbowari avatar Feb 29 '24 01:02 r3inbowari

In fact, filtering them has no practical effect, because the lat and lon parameters are determined by the ookla's server and they are always correct. Can you list a use case?

r3inbowari avatar Feb 29 '24 01:02 r3inbowari

try using yishun in CityFlag config the result not only shown list of server from cc of SG but there is server from MY and ID to

gandol avatar Feb 29 '24 02:02 gandol

This is normal, because location is searched within a rough radius. Even if you use the official speedtest, you will still get these results.

The intention of Location is to modify your current location without doing too much processing on the results. It should not be a filter.

r3inbowari avatar Feb 29 '24 02:02 r3inbowari

For now, I think the best way is to add a --cc flag to filter them:

  1. disabled by default.
  2. auto attach by ookla's API. eg: --cc=auto
  3. filter based on the provided cc. eg: --cc=SG

r3inbowari avatar Feb 29 '24 03:02 r3inbowari

try using yishun in CityFlag config the result not only shown list of server from cc of SG but there is server from MY and ID to

CityFlag and CC(country code) are not related. CityFlag only maps to a build-in geographical coordinate.

r3inbowari avatar Feb 29 '24 03:02 r3inbowari

For now, I think the best way is to add a --cc flag to filter them:

  1. disabled by default.
  2. auto attach by ookla's API. eg: --cc=auto
  3. filter based on the provided cc. eg: --cc=SG

if just use cc how to get the list of server, i was try use params of cc directly in url params can't get it it must add cityflag or use keyword or create an array of cc and keyword ?

gandol avatar Feb 29 '24 10:02 gandol

We can preload cc from here. const speedTestConfigUrl = "https://www.speedtest.net/speedtest-config.php"

  1. Through this api we can get the default cc, which depends on your network location.
  2. If the city flag is set, we can use the build-in cc instead of the default cc.

For now, I think the best way is to add a --cc flag to filter them:

  1. disabled by default.
  2. auto attach by ookla's API. eg: --cc=auto
  3. filter based on the provided cc. eg: --cc=SG

if just use cc how to get the list of server, i was try use params of cc directly in url params can't get it it must add cityflag or use keyword or create an array of cc and keyword ?

cc should be used with city location as much as possible.

r3inbowari avatar Feb 29 '24 12:02 r3inbowari

@r3inbowari check my last commit, like that what you mean ?

gandol avatar Mar 02 '24 10:03 gandol

I changed some code here.

examples:

./speedtest-go --city=tokyo -l // disable filter by default
./speedtest-go --city=tokyo --filter-cc=jp -l
./speedtest-go --city=hongkong --filter-cc=cn --filter-cc=hk -l  // excludes MO servers which close to HongKong and includes CN
./speedtest-go --city=hongkong --filter-cc=auto -l                  // auto attach which decided by your network provider
./speedtest-go --location=xx,xx --filter-cc=jp -l

If there is no server for this cc in the area you specify, the result will be empty.

Do you think this is ok?

r3inbowari avatar Mar 02 '24 19:03 r3inbowari

I changed some code here.

examples:

./speedtest-go --city=tokyo -l // disable filter by default
./speedtest-go --city=tokyo --filter-cc=jp -l
./speedtest-go --city=hongkong --filter-cc=cn --filter-cc=hk -l  // excludes MO servers which close to HongKong and includes CN
./speedtest-go --city=hongkong --filter-cc=auto -l                  // auto attach which decided by your network provider
./speedtest-go --location=xx,xx --filter-cc=jp -l

If there is no server for this cc in the area you specify, the result will be empty.

Do you think this is ok?

hmm i think this is ok

gandol avatar Mar 05 '24 16:03 gandol