Skip to content

Commit 1f8dc72

Browse files
authored
handle a .well-known URI (#9)
* reformat message to match custom url * retry remote fetch with .well-known URI Instead of having to type a whole URI, expect the JSON server list to be served at /.well-known/librespeed Thus, only the base URL should be necessary.
1 parent 4898bfe commit 1f8dc72

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

speedtest/speedtest.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,18 @@ func SpeedTest(c *cli.Context) error {
220220
servers, err = getLocalServers(c.Bool(defs.OptionSecure), str, c.IntSlice(defs.OptionExclude), c.IntSlice(defs.OptionServer), !c.Bool(defs.OptionList))
221221
} else {
222222
// fetch the server list JSON and parse it into the `servers` array
223-
log.Info("Retrieving LibreSpeed.org server list")
224223
serverUrl := serverListUrl
225224
if str := c.String(defs.OptionServerJSON); str != "" {
226225
serverUrl = str
227226
}
227+
log.Info("Retrieving server list from %s", serverUrl)
228228

229229
servers, err = getServerList(c.Bool(defs.OptionSecure), serverUrl, c.IntSlice(defs.OptionExclude), c.IntSlice(defs.OptionServer), !c.Bool(defs.OptionList))
230+
231+
if err != nil {
232+
log.Info("Retry with /.well-known/librespeed")
233+
servers, err = getServerList(c.Bool(defs.OptionSecure), serverUrl + "/.well-known/librespeed", c.IntSlice(defs.OptionExclude), c.IntSlice(defs.OptionServer), !c.Bool(defs.OptionList))
234+
}
230235
}
231236
if err != nil {
232237
log.Errorf("Error when fetching server list: %s", err)

0 commit comments

Comments
 (0)