From 42537b4e23f735d9b8a08b37d072398ce7ae35bc Mon Sep 17 00:00:00 2001 From: dosse91 Date: Mon, 9 Mar 2020 08:52:24 +0100 Subject: [PATCH 1/4] Updated doc.md --- doc.md | 60 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/doc.md b/doc.md index c82cafb..856edfb 100644 --- a/doc.md +++ b/doc.md @@ -1,7 +1,7 @@ # LibreSpeed > by Federico Dossena -> Version 5.1 +> Version 5.2 > [https://github.com/librespeed/speedtest/](https://github.com/librespeed/speedtest/) ## Introduction @@ -156,32 +156,32 @@ Edit `index.html`, you will see a list of servers: ```js var SPEEDTEST_SERVERS=[ { - name:"Speedtest Demo Server 1", //user friendly name for the server - server:"//mpotdemo.fdossena.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically - dlURL:"garbage.php", //path to download test on this server (garbage.php or replacement) - ulURL:"empty.php", //path to upload test on this server (empty.php or replacement) - pingURL:"empty.php", //path to ping/jitter test on this server (empty.php or replacement) - getIpURL:"getIP.php" //path to getIP on this server (getIP.php or replacement) + "name":"Speedtest Demo Server 1", //user friendly name for the server + "server":"//mpotdemo.fdossena.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically + "dlURL":"garbage.php", //path to download test on this server (garbage.php or replacement) + "ulURL":"empty.php", //path to upload test on this server (empty.php or replacement) + "pingURL":"empty.php", //path to ping/jitter test on this server (empty.php or replacement) + "getIpURL":"getIP.php" //path to getIP on this server (getIP.php or replacement) }, { - name:"Speedtest Demo Server 2", - server:"//mpotdemo2.fdossena.com/", - dlURL:"garbage.php", - ulURL:"empty.php", - pingURL:"empty.php", - getIpURL:"getIP.php" + "name":"Speedtest Demo Server 2", + "server":"//mpotdemo2.fdossena.com/", + "dlURL":"garbage.php", + "ulURL":"empty.php", + "pingURL":"empty.php", + "getIpURL":"getIP.php" } //add other servers here, comma separated ]; ``` Replace the demo servers with your test points. Each server in the list is an object containing: -* `name`: user friendly name for this test point -* `server`: URL to the server. If your server only supports HTTP or HTTPS, put http:// or https:// at the beginning, respectively; if it supports both, put // at the beginning and it will be replaced automatically -* `dlURL`: path to the download test on this server (garbage.php or replacement) -* `ulURL`: path to the upload test on this server (empty.php or replacement) -* `pingURL`: path to the ping test on this server (empty.php or replacement) -* `getIpURL`: path to getIP on this server (getIP.php or replacement) +* `"name"`: user friendly name for this test point +* `"server"`: URL to the server. If your server only supports HTTP or HTTPS, put http:// or https:// at the beginning, respectively; if it supports both, put // at the beginning and it will be replaced automatically +* `"dlURL"`: path to the download test on this server (garbage.php or replacement) +* `"ulURL"`: path to the upload test on this server (empty.php or replacement) +* `"pingURL"`: path to the ping test on this server (empty.php or replacement) +* `"getIpURL"`: path to getIP on this server (getIP.php or replacement) None of these parameters can be omitted. @@ -191,6 +191,23 @@ __Important__: For HTTPS, all your servers must have valid certificates or the b __Important__: Don't use my demo servers, they're slow! +If your list of servers changes often, you might not want to have it hardcoded in the HTML file. LibreSpeed can load the server list from a JSON file. To do this, edit `index.html` and replace the list of servers with this: +```js +var SPEEDTEST_SERVERS="your URL here"; +``` + +The URL doesn't need to be complete, it can just point to a file in the current directory. The URL should point to a JSON file with the same format used above: +```js +[ + { + "name":... + }, + ... +] +``` + +__Important:__ The same origin policy applies to which URLs you can and cannot load with this method. If possible, it's best to just point it to a file on the current server. + ##### Telemetry and results sharing Telemetry is stored on the frontend server. The setup procedure is the same as the single server version. @@ -535,6 +552,11 @@ Note that this will add `mpot`:`true` to the parameters sent to the speedtest wo ##### addTestPoints(list) Same as addTestPoint, but you can pass an array of servers +##### loadServerList(url,result) +Loads a list of servers from a JSON file pointed by the `url`. + +The process is asynchronous and the `result` function will be called when it's done. If the request succeeded, an array containing the list of loaded servers will be passed to the function, otherwise `null` will be passed. + ##### getSelectedServer() Returns the selected server (multiple points of test) From b7dce2bc046cda2d62268d7611739b7613449e91 Mon Sep 17 00:00:00 2001 From: dosse91 Date: Thu, 12 Mar 2020 11:59:40 +0100 Subject: [PATCH 2/4] Updated README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7cfe82b..5d7174c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ No Flash, No Java, No Websocket, No Bullshit. This is a very lightweight Speedtest implemented in Javascript, using XMLHttpRequest and Web Workers. ## Try it -[Take a Speedtest](https://speedtest.fdossena.com) +[Take a Speedtest](https://librespeed.org) ## Compatibility All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari. @@ -41,12 +41,12 @@ A template to build an Android client for your LibreSpeed installation is availa ## Docker Please see the `docker` branch -## Node.js backend -A Node.js implementation is available in the `node` branch, maintained by [dunklesToast](https://github.com/dunklesToast). - ## Go backend A Go implementation is available in the `go` branch, maintained by [Maddie Zhan](https://github.com/maddie). +## Node.js backend +A partial Node.js implementation is available in the `node` branch, developed by [dunklesToast](https://github.com/dunklesToast). It's not recommended to use at the moment. + ## Donate [![Donate with Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate) [Donate with PayPal](https://www.paypal.me/sineisochronic) From 6fbe21f2f74f76def581c3354325048a2abe4e8e Mon Sep 17 00:00:00 2001 From: kodaihirano Date: Mon, 4 May 2020 20:38:29 +0900 Subject: [PATCH 3/4] use delay in ultest (#319) #318 --- speedtest_worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speedtest_worker.js b/speedtest_worker.js index c91f506..5d518d1 100644 --- a/speedtest_worker.js +++ b/speedtest_worker.js @@ -523,7 +523,7 @@ function ulTest(done) { xhr[i].send(req); } }.bind(this), - 1 + delay ); }.bind(this); // open streams From 9efae7c27c34ddf31cc95d3063775dec3f476176 Mon Sep 17 00:00:00 2001 From: Kristan Webb Date: Thu, 11 Jun 2020 14:34:29 +0100 Subject: [PATCH 4/4] Add Port option for MySql (#330) --- results/index.php | 2 +- results/stats.php | 2 +- results/telemetry.php | 2 +- results/telemetry_settings.php | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/results/index.php b/results/index.php index b15ba5b..a9dac38 100644 --- a/results/index.php +++ b/results/index.php @@ -81,7 +81,7 @@ if($enable_id_obfuscation) $id=deobfuscateId($id); $conn=null; $q=null; $ispinfo=null; $dl=null; $ul=null; $ping=null; $jit=null; if($db_type=="mysql"){ - $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename); + $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename, $MySql_port); $q = $conn->prepare("select ispinfo,dl,ul,ping,jitter from speedtest_users where id=?"); $q->bind_param("i",$id); $q->execute(); diff --git a/results/stats.php b/results/stats.php index 834afed..1e6ff1c 100644 --- a/results/stats.php +++ b/results/stats.php @@ -69,7 +69,7 @@ if($stats_password=="PASSWORD"){ }else{ $conn=null; if($db_type=="mysql"){ - $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename); + $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename, $MySql_port); }else if($db_type=="sqlite"){ $conn = new PDO("sqlite:$Sqlite_db_file"); } else if($db_type=="postgresql"){ diff --git a/results/telemetry.php b/results/telemetry.php index 3163f54..5699777 100644 --- a/results/telemetry.php +++ b/results/telemetry.php @@ -31,7 +31,7 @@ header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); if($db_type=="mysql"){ - $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1"); + $conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename, $MySql_port) or die("1"); $stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2"); $stmt->bind_param("ssssssssss",$ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3"); $stmt->execute() or die("4"); diff --git a/results/telemetry_settings.php b/results/telemetry_settings.php index c4e87a9..ad80cf3 100644 --- a/results/telemetry_settings.php +++ b/results/telemetry_settings.php @@ -13,6 +13,7 @@ $MySql_username="USERNAME"; $MySql_password="PASSWORD"; $MySql_hostname="DB_HOSTNAME"; $MySql_databasename="DB_NAME"; +$MySql_port="3306"; // Postgresql settings $PostgreSql_username="USERNAME"; @@ -22,4 +23,4 @@ $PostgreSql_databasename="DB_NAME"; //IMPORTANT: DO NOT ADD ANYTHING BELOW THIS PHP CLOSING TAG, NOT EVEN EMPTY LINES! -?> +?> \ No newline at end of file