From 79afc769eac1bddccfb412b0b084805e4b586692 Mon Sep 17 00:00:00 2001 From: Les W <30345058+leswaters@users.noreply.github.com> Date: Sat, 9 Jul 2022 16:13:26 +0100 Subject: [PATCH 01/11] Update README.md Added simple manual instructions --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8df437196..7608d781f 100755 --- a/README.md +++ b/README.md @@ -32,7 +32,20 @@ Works with mobile versions too. * MySQL database to store test results (optional, PostgreSQL and SQLite also supported) * A fast! internet connection -## Installation videos +## Installation +Assuming you have PHP installed, the installation steps are quite simple. +I set this up on a QNAP. +For this example, I am using a folder called **speedtest** in my web share area. + +1. Choose one of the example-xxx.html files as your new index.html in your speedtest folder. I used: example-singleServer-full.html +2. Add: speedtest.js, speedtest_worker.js, and favicon.ico to your speedtest folder. +3. Download all of the backend folder into speedtest/backend. +4. Download all of the results folder into speedtest/results. +5. Be sure your permissions allow execute (755). +6. Visit YOURSITE/speedtest/index.html and voila! + +### Installation Video +There is a more in-depth installation video here: * [Quick start installation guide for Ubuntu Server 19.04](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag) ## Android app From d1ca8c2630b56a5ed0ecd1072077d43e71f471c2 Mon Sep 17 00:00:00 2001 From: bt90 Date: Thu, 14 Jul 2022 16:45:28 +0200 Subject: [PATCH 02/11] Link to docker documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8df437196..491e346d2 100755 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Works with mobile versions too. A template to build an Android client for your LibreSpeed installation is available [here](https://github.com/librespeed/speedtest-android). ## Docker -A docker image is available on the [Docker Hub](https://registry.hub.docker.com/r/adolfintel/speedtest), see `doc_docker.md` for more info about it +A docker image is available on the [Docker Hub](https://registry.hub.docker.com/r/adolfintel/speedtest), check our [docker documentation](doc_docker.md) for more info about it ## Go backend A Go implementation is available in the [`speedtest-go`](https://github.com/librespeed/speedtest-go) repo, maintained by [Maddie Zhan](https://github.com/maddie). From 16e0fb9bf4c275262d74b49c453c6ce50e6f5ae3 Mon Sep 17 00:00:00 2001 From: bt90 Date: Thu, 14 Jul 2022 17:08:12 +0200 Subject: [PATCH 03/11] Add basic docker compose example --- doc_docker.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc_docker.md b/doc_docker.md index 753fe024c..a8cd69a36 100755 --- a/doc_docker.md +++ b/doc_docker.md @@ -9,6 +9,34 @@ docker pull adolfintel/speedtest You will now have a new docker image called `adolfintel/speedtest`. + +## Docker Compose +To start the container using [docker compose](https://docs.docker.com/compose/) the following configuration can be used: + +```yml +version: '3.7' +services: + speedtest: + container_name: speedtest + image: adolfintel/speedtest + restart: always + environment: + MODE: standalone + #TITLE: "LibreSpeed" + #TELEMETRY: "false" + #ENABLE_ID_OBFUSCATION: "false" + #REDACT_IP_ADDRESSES: "false" + #PASSWORD: + #EMAIL: + #DISABLE_IPINFO: "false" + #DISTANCE: "km" + #WEBPORT: 80 + ports: + - "80:80" # webport mapping (host:container) +``` + +Please adjust the environment variables according to the intended operating mode. + ## Standalone mode If you want to install LibreSpeed on a single server, you need to configure it in standalone mode. To do this, set the `MODE` environment variable to `standalone`. From 71e3b4713012ae32e1a026727d597f8d9fabb87a Mon Sep 17 00:00:00 2001 From: 0kyn <0kyn.dev@gmail.com> Date: Mon, 3 Oct 2022 21:16:26 +0200 Subject: [PATCH 04/11] Fix some typos and formatting --- Dockerfile | 6 +----- doc.md | 10 +++++----- speedtest.js | 2 +- speedtest_worker.js | 8 ++++---- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index c510c9896..5c5219f1b 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,11 +12,9 @@ RUN apt-get update && apt-get install -y \ && docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql # Prepare files and folders - RUN mkdir -p /speedtest/ # Copy sources - COPY backend/ /speedtest/backend COPY results/*.php /speedtest/results/ @@ -30,8 +28,7 @@ COPY docker/servers.json /servers.json COPY docker/*.php /speedtest/ COPY docker/entrypoint.sh / -# Prepare environment variabiles defaults - +# Prepare default environment variables ENV TITLE=LibreSpeed ENV MODE=standalone ENV PASSWORD=password @@ -41,6 +38,5 @@ ENV REDACT_IP_ADDRESSES=false ENV WEBPORT=80 # Final touches - EXPOSE 80 CMD ["bash", "/entrypoint.sh"] diff --git a/doc.md b/doc.md index 620b30e82..787cdeda8 100755 --- a/doc.md +++ b/doc.md @@ -117,7 +117,7 @@ If you're not using telemetry and results sharing, you can delete the `results` Details about the examples and how to make custom UIs will be discussed later. If you don't want to make a custom UI, feel free to modify the example and replace "LibreSpeed Example" with the name of your test. #### Privacy -Telemetry contains personal information (according to GDPR defintion), therefore it is important to treat this data respectfully of national and international laws, especially if you plan to offer the service in the European Union. +Telemetry contains personal information (according to GDPR definition), therefore it is important to treat this data respectfully of national and international laws, especially if you plan to offer the service in the European Union. `example-singleServer-full.html` and `example-multipleServers-full.html` both contain a privacy policy for the service: you MUST read it, change it if necessary, and add your email address for data deletion requests. __Failure to comply with GDPR regulations can get you in serious trouble.__ @@ -506,7 +506,7 @@ You can think of this as a finite state machine. These are the states (use getSt ``` While in state 1, you can only add test points, you cannot change the test settings. When you're done, use selectServer(callback) to select the test point with the lowest ping. This is asynchronous, when it's done, it will call your callback function and move to state 2. Calling setSelectedServer(server) will manually select a server and move to state 2. * __2__: test point selected, ready to start the test. Use `start()` to begin, this will move to state 3 -* __3__: test running. Here, your `onupdate` event calback will be called periodically, with data coming from the worker about speed and progress. A data object will be passed to your `onupdate` function, with the following items: +* __3__: test running. Here, your `onupdate` event callback will be called periodically, with data coming from the worker about speed and progress. A data object will be passed to your `onupdate` function, with the following items: - `dlStatus`: download speed in mbps - `ulStatus`: upload speed in mbps - `pingStatus`: ping in ms @@ -664,7 +664,7 @@ Access-Control-Allow-Headers: Content-Encoding, Content-Type This file stores telemetry information into the database. Data is passed as POST parameters: -* `ispinfo`: ISP info (if enabled, empty strng otherwise) +* `ispinfo`: ISP info (if enabled, empty string otherwise) * `extra`: the `telemetry_extra` string passed to the worker (if set, empty string otherwise) * `dl`: download speed * `ul`: upload speed @@ -741,7 +741,7 @@ s.setParameter("url_ping","backend/empty.dat"); s.setParameter("test_order","P_D_U"); ``` -This will point to our static files and set the test to only do ping/jitter, download and uplod tests. +This will point to our static files and set the test to only do ping/jitter, download and upload tests. ## Troubleshooting These are the most common issues reported by users, and how to fix them. If you still need help, contact me at [info@fdossena.com](mailto:info@fdossena.com). @@ -807,7 +807,7 @@ Also, make sure that the web server has write permission on the `results` folder ## Known bugs and limitations ### General -* The ping/jitter test is measured by seeing how long it takes for an empty XHR to complete. It is not an acutal ICMP ping. Different browsers may also show different results, especially on very fast connections on slow devices. +* The ping/jitter test is measured by seeing how long it takes for an empty XHR to complete. It is not an actual ICMP ping. Different browsers may also show different results, especially on very fast connections on slow devices. ### IE specific * The upload test is not precise on very fast connections with high latency (will probably be fixed by Edge 17) * On IE11, a same origin policy error is erroneously triggered under unknown conditions. Seems to be related to running the test from unusual URLs like a top level domain (for instance http://abc/speedtest). These are bugs in IE11's implementation of the same origin policy, not in the speedtest itself. diff --git a/speedtest.js b/speedtest.js index a2fdb68cf..f614a5365 100755 --- a/speedtest.js +++ b/speedtest.js @@ -27,7 +27,7 @@ } While in state 1, you can only add test points, you cannot change the test settings. When you're done, use selectServer(callback) to select the test point with the lowest ping. This is asynchronous, when it's done, it will call your callback function and move to state 2. Calling setSelectedServer(server) will manually select a server and move to state 2. - 2: test point selected, ready to start the test. Use start() to begin, this will move to state 3 - - 3: test running. Here, your onupdate event calback will be called periodically, with data coming from the worker about speed and progress. A data object will be passed to your onupdate function, with the following items: + - 3: test running. Here, your onupdate event callback will be called periodically, with data coming from the worker about speed and progress. A data object will be passed to your onupdate function, with the following items: - dlStatus: download speed in mbps - ulStatus: upload speed in mbps - pingStatus: ping in ms diff --git a/speedtest_worker.js b/speedtest_worker.js index 2899e70ad..a01b4aca1 100755 --- a/speedtest_worker.js +++ b/speedtest_worker.js @@ -60,12 +60,12 @@ var settings = { garbagePhp_chunkSize: 100, // size of chunks sent by garbage.php (can be different if enable_quirks is active) enable_quirks: true, // enable quirks for specific browsers. currently it overrides settings to optimize for specific browsers, unless they are already being overridden with the start command ping_allowPerformanceApi: true, // if enabled, the ping test will attempt to calculate the ping more precisely using the Performance API. Currently works perfectly in Chrome, badly in Edge, and not at all in Firefox. If Performance API is not supported or the result is obviously wrong, a fallback is provided. - overheadCompensationFactor: 1.06, //can be changed to compensatie for transport overhead. (see doc.md for some other values) + overheadCompensationFactor: 1.06, //can be changed to compensate for transport overhead. (see doc.md for some other values) useMebibits: false, //if set to true, speed will be reported in mebibits/s instead of megabits/s telemetry_level: 0, // 0=disabled, 1=basic (results only), 2=full (results and timing) 3=debug (results+log) url_telemetry: "results/telemetry.php", // path to the script that adds telemetry data to the database telemetry_extra: "", //extra data that can be passed to the telemetry through the settings - forceIE11Workaround: false //when set to true, it will foce the IE11 upload test on all browsers. Debug only + forceIE11Workaround: false //when set to true, it will force the IE11 upload test on all browsers. Debug only }; var xhr = null; // array of currently active xhr requests @@ -423,7 +423,7 @@ function dlTest(done) { 200 ); } -// upload test, calls done function whent it's over +// upload test, calls done function when it's over var ulCalled = false; // used to prevent multiple accidental calls to ulTest function ulTest(done) { tverb("ulTest"); @@ -474,7 +474,7 @@ function ulTest(done) { } } if (ie11workaround) { - // IE11 workarond: xhr.upload does not work properly, therefore we send a bunch of small 256k requests and use the onload event as progress. This is not precise, especially on fast connections + // IE11 workaround: xhr.upload does not work properly, therefore we send a bunch of small 256k requests and use the onload event as progress. This is not precise, especially on fast connections xhr[i].onload = xhr[i].onerror = function() { tverb("ul stream progress event (ie11wa)"); totLoaded += reqsmall.size; From 5956e07a7a0c8abd06f6a7a92a8b00277f3497d4 Mon Sep 17 00:00:00 2001 From: Tracy-B Date: Mon, 31 Jul 2023 18:10:56 +1200 Subject: [PATCH 05/11] Microsoft SQL Server support and Sanity Check page (#569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create telemetry_mssql.sql SQL to create the speedtest_users table on Microsoft SQL server. This SQL is based on the original templates, and continues to uses nvarchar for all fields as the templates do – even though some of the fields should be int. * Added support for Microsoft SQL Server * New sanitycheck.php page plus required updates to telemetry_db.php Created a sanity check page to verify that the required PHP extensions are installed, and that it is possible to connect to the database. * Update README.md - MS SQL support Added mention of Microsoft SQL Server as a supported DB engine. * Added missing to sanitycheck.php --- README.md | 2 +- results/sanitycheck.php | 189 +++++++++++++++++++++++++++++++++ results/telemetry_db.php | 108 ++++++++++++++++--- results/telemetry_mssql.sql | 30 ++++++ results/telemetry_settings.php | 11 +- 5 files changed, 324 insertions(+), 16 deletions(-) create mode 100644 results/sanitycheck.php create mode 100644 results/telemetry_mssql.sql diff --git a/README.md b/README.md index 8df437196..dd5bbe0b9 100755 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Works with mobile versions too. ## Server requirements * A reasonably fast web server with Apache 2 (nginx, IIS also supported) * PHP 5.4 (other backends also available) -* MySQL database to store test results (optional, PostgreSQL and SQLite also supported) +* MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported) * A fast! internet connection ## Installation videos diff --git a/results/sanitycheck.php b/results/sanitycheck.php new file mode 100644 index 000000000..133b683aa --- /dev/null +++ b/results/sanitycheck.php @@ -0,0 +1,189 @@ +Pass"; +$failed="failed"; +$na="N/A"; +?> + + + +Speed Test installation sanity check + + + + + + + + + + + + + + + + + + + + + +"; + } else { + echo $failed; + echo ""; + } +?> + + +"; + } else { + echo $pass; + echo ""; + } +?> + + +"; + } elseif(!is_array($QueryResult)) { + echo $failed; + echo ""; + } else { + echo $pass; + echo ""; + } + } else { + echo ""; + } +?> + + +
ItemStatusComment
PHP extensions
gd + +Used to render result images.
openssl + +
pdo_sqlsrv + +Only required if using MS SQL.
pdo_mysql + +Only required if using mysql.
pdo_sqlite + +Only required if using sqlite.
pdo_pgsql + +Only required if using sqlite.
Database check
Connecting to DB +". htmlspecialchars($pdo) . "
Insert into DB +"; + echo htmlspecialchars($insertResult->getMessage()) . "
Read from DB +"; + echo htmlspecialchars($insertResult->getMessage()) . "Test result not retrieved from database.Insert failed so can't test reading inserted data
+ + + \ No newline at end of file diff --git a/results/telemetry_db.php b/results/telemetry_db.php index 6a1aee3f5..e51663841 100755 --- a/results/telemetry_db.php +++ b/results/telemetry_db.php @@ -7,18 +7,24 @@ /** * @return PDO|false */ -function getPdo() +function getPdo($returnErrorMessage = false) { if ( !file_exists(TELEMETRY_SETTINGS_FILE) || !is_readable(TELEMETRY_SETTINGS_FILE) ) { + if($returnErrorMessage){ + return 'missing TELEMETRY_SETTINGS_FILE'; + } return false; } require TELEMETRY_SETTINGS_FILE; if (!isset($db_type)) { + if($returnErrorMessage){ + return "db_type not set in '" . TELEMETRY_SETTINGS_FILE . "'"; + } return false; } @@ -27,6 +33,47 @@ function getPdo() ]; try { + if ('mssql' === $db_type) { + if (!isset( + $MsSql_server, + $MsSql_databasename, + $MsSql_WindowsAuthentication + )) { + if($returnErrorMessage){ + return "Required MSSQL database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'"; + } + return false; + } + + if (!$MsSql_WindowsAuthentication and + !isset( + $MsSql_username, + $MsSql_password, + ) + ) { + if($returnErrorMessage){ + return "Required MSSQL database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'"; + } + return false; + } + $dsn = 'sqlsrv:' + .'server='.$MsSql_server + .';Database='.$MsSql_databasename; + + if($MsSql_TrustServerCertificate === true){ + $dsn = $dsn . ';TrustServerCertificate=1'; + } + if($MsSql_TrustServerCertificate === false){ + $dsn = $dsn . ';TrustServerCertificate=0'; + } + + if($MsSql_WindowsAuthentication){ + return new PDO($dsn, "", "", $pdoOptions); + } else { + return new PDO($dsn, $MySql_username, $MySql_password, $pdoOptions); + } + } + if ('mysql' === $db_type) { if (!isset( $MySql_hostname, @@ -35,7 +82,10 @@ function getPdo() $MySql_username, $MySql_password )) { - return false; + if($returnErrorMessage){ + return "Required mysql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'"; + } + return false; } $dsn = 'mysql:' @@ -48,6 +98,9 @@ function getPdo() if ('sqlite' === $db_type) { if (!isset($Sqlite_db_file)) { + if($returnErrorMessage){ + return "Required sqlite database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'"; + } return false; } @@ -80,7 +133,10 @@ function getPdo() $PostgreSql_username, $PostgreSql_password )) { - return false; + if($returnErrorMessage){ + return "Required postgresql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'"; + } + return false; } $dsn = 'pgsql:' @@ -90,9 +146,15 @@ function getPdo() return new PDO($dsn, $PostgreSql_username, $PostgreSql_password, $pdoOptions); } } catch (Exception $e) { + if($returnErrorMessage){ + return $e->getMessage(); + } return false; } + if($returnErrorMessage){ + return "db_type '" . $db_type . "' not supported"; + } return false; } @@ -109,12 +171,15 @@ function isObfuscationEnabled() } /** - * @return string|false returns the id of the inserted column or false on error + * @return string|false returns the id of the inserted column or false on error if returnErrorMessage is false or a error message if returnErrorMessage is true */ -function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log) +function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log, $returnExceptionOnError = false) { $pdo = getPdo(); if (!($pdo instanceof PDO)) { + if($returnExceptionOnError){ + return new Exception("Failed to get database connection object"); + } return false; } @@ -129,6 +194,9 @@ function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, ]); $id = $pdo->lastInsertId(); } catch (Exception $e) { + if($returnExceptionOnError){ + return $e; + } return false; } @@ -142,16 +210,19 @@ function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, /** * @param int|string $id * - * @return array|null|false returns the speedtest data as array, null + * @return array|null|false|exception returns the speedtest data as array, null * if no data is found for the given id or - * false if there was an error + * false or an exception if there was an error (based on returnExceptionOnError) * * @throws RuntimeException */ -function getSpeedtestUserById($id) +function getSpeedtestUserById($id,$returnExceptionOnError = false) { $pdo = getPdo(); if (!($pdo instanceof PDO)) { + if($returnExceptionOnError){ + return new Exception("Failed to get database connection object"); + } return false; } @@ -170,6 +241,9 @@ function getSpeedtestUserById($id) $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); } catch (Exception $e) { + if($returnExceptionOnError){ + return $e; + } return false; } @@ -195,14 +269,20 @@ function getLatestSpeedtestUsers() return false; } + require TELEMETRY_SETTINGS_FILE; + try { - $stmt = $pdo->query( - 'SELECT - id, timestamp, ip, ispinfo, ua, lang, dl, ul, ping, jitter, log, extra + $sql = 'SELECT '; + + if('mssql' === $db_type) {$sql .= ' TOP(100) ';} + + $sql .= ' id, timestamp, ip, ispinfo, ua, lang, dl, ul, ping, jitter, log, extra FROM speedtest_users - ORDER BY timestamp DESC - LIMIT 100' - ); + ORDER BY timestamp DESC '; + + if('mssql' !== $db_type) {$sql .= ' LIMIT 100 ';} + + $stmt = $pdo->query($sql); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); diff --git a/results/telemetry_mssql.sql b/results/telemetry_mssql.sql new file mode 100644 index 000000000..6c68d849a --- /dev/null +++ b/results/telemetry_mssql.sql @@ -0,0 +1,30 @@ +SET ANSI_NULLS ON +GO + +SET QUOTED_IDENTIFIER ON +GO + +CREATE TABLE [dbo].[speedtest_users]( + [id] [bigint] IDENTITY(120,1) NOT NULL, + [timestamp] [datetime] NOT NULL, + [ip] [nvarchar](max) NOT NULL, + [ispinfo] [nvarchar](max) NULL, + [extra] [nvarchar](max) NULL, + [ua] [nvarchar](max) NOT NULL, + [lang] [nvarchar](max) NOT NULL, + [dl] [nvarchar](max) NULL, + [ul] [nvarchar](max) NULL, + [ping] [nvarchar](max) NULL, + [jitter] [nvarchar](max) NULL, + [log] [nvarchar](max) NULL, + CONSTRAINT [PK_speedtest_users] PRIMARY KEY CLUSTERED +( + [id] ASC +)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] +) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] +GO + +ALTER TABLE [dbo].[speedtest_users] ADD CONSTRAINT [DF_speedtest_users_timestamp] DEFAULT (getdate()) FOR [timestamp] +GO + + diff --git a/results/telemetry_settings.php b/results/telemetry_settings.php index 78bc3438a..ea1993848 100755 --- a/results/telemetry_settings.php +++ b/results/telemetry_settings.php @@ -1,6 +1,6 @@ Date: Wed, 9 Aug 2023 16:36:48 -0400 Subject: [PATCH 06/11] Updated Docker to use php8.2-apache as the upstream image. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c510c9896..ae32f5aca 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-apache +FROM php:8.2-apache # Install extensions RUN apt-get update && apt-get install -y \ From 6a4a05d883dcbb1b3198100b8e0bcc97bb04543f Mon Sep 17 00:00:00 2001 From: Federico Dossena Date: Mon, 28 Aug 2023 22:12:08 +0200 Subject: [PATCH 07/11] Replaced speedtest with speed test --- README.md | 4 +-- doc.md | 60 +++++++++++++++---------------- doc_docker.md | 2 +- docker/frontend.php | 8 ++--- docker/standalone.php | 8 ++--- example-multipleServers-full.html | 6 ++-- example-singleServer-basic.html | 2 +- example-singleServer-chart.html | 2 +- example-singleServer-full.html | 2 +- speedtest.js | 10 +++--- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index dd5bbe0b9..1064fc49a 100755 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ No Flash, No Java, No Websocket, No Bullshit. -This is a very lightweight Speedtest implemented in Javascript, using XMLHttpRequest and Web Workers. +This is a very lightweight speed test implemented in Javascript, using XMLHttpRequest and Web Workers. ## Try it -[Take a Speedtest](https://librespeed.org) +[Take a speed test](https://librespeed.org) ## Compatibility All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari. diff --git a/doc.md b/doc.md index 620b30e82..e276d0a37 100755 --- a/doc.md +++ b/doc.md @@ -5,7 +5,7 @@ > [https://github.com/librespeed/speedtest/](https://github.com/librespeed/speedtest/) ## Introduction -LibreSpeed is a Free and Open Source speedtest that you can host on your server(s), and users can run in their browser. +LibreSpeed is a Free and Open Source speed test that you can host on your server(s), and users can run in their browser. __Features:__ * Download test @@ -30,7 +30,7 @@ The following browsers are officially supported: Client side, the test can use up to 500MB of RAM on very fast connections. ## Quick start guides -These guides cover a simple single server installation of the Speedtest. +These guides cover a simple single server installation of the speed test. * [Quick start installation guide for Ubuntu Server 19.04](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag) @@ -50,14 +50,14 @@ Server side, you'll need: * If you want to enable results sharing: - FreeType 2 and its PHP module (this is usually installed automatically by most distros) -Let's install the speedtest. +Let's install the speed test. Put all files on your web server via FTP or by copying them directly. You can install it in the root, or in a subdirectory. -__Important:__ The speedtest needs write permissions in the installation folder! +__Important:__ The speed test needs write permissions in the installation folder! #### ipinfo.io -The speedtest uses [ipinfo.io](https://ipinfo.io) to detect ISP and distance from server. This is completely optional and can be disabled if you want (see Speedtest settings), but it is enabled by default, and if you expect more than ~500 tests per day, you will need to sign up to [ipinfo.io](https://ipinfo.io) and edit `backend/getIP_ipInfo_apikey.php` to set your access token. +The speed test uses [ipinfo.io](https://ipinfo.io) to detect ISP and distance from server. This is completely optional and can be disabled if you want (see speed test settings), but it is enabled by default, and if you expect more than ~500 tests per day, you will need to sign up to [ipinfo.io](https://ipinfo.io) and edit `backend/getIP_ipInfo_apikey.php` to set your access token. IpInfo.io has kindly offered free access to their APIs for users of this project; if you're interested, contact me at [info@fdossena.com](mailto:info@fdossena.com) and provide a description of what you intend to do with the project, and you'll get the API key. @@ -122,9 +122,9 @@ Telemetry contains personal information (according to GDPR defintion), therefore `example-singleServer-full.html` and `example-multipleServers-full.html` both contain a privacy policy for the service: you MUST read it, change it if necessary, and add your email address for data deletion requests. __Failure to comply with GDPR regulations can get you in serious trouble.__ ### Multiple servers, PHP -The speedtest can automatically choose between multiple test points and use the one with the lowest ping in a list. +The speed test can automatically choose between multiple test points and use the one with the lowest ping in a list. -Note that this is an advanced use case and it is recommended that you already know how to use the speedtest with a single server. +Note that this is an advanced use case and it is recommended that you already know how to use the speed test with a single server. We must distinguish 2 types of servers: * __Frontend server__: hosts the UI, the JS files, and optionally telemetry and results sharing stuff. You only need 1 of these, and this is the server that your clients will first connect to. @@ -143,20 +143,20 @@ Requirements: * If you want to enable results sharing: - FreeType 2 and its PHP module (this is usually installed automatically by most distros) -To install the speedtest frontend, copy the following files to your web server: +To install the speed test frontend, copy the following files to your web server: * `speedtest.js` * `speedtest_worker.js` * Optionally, the `results` folder * One of the `multipleServers` examples (the best starting points are `example-multipleServers-pretty.html` if you don't want to use telemetry and results sharing, `example-multipleServers-full.html` if you want to use them). Rename the example you choose to `index.html` -__Important:__ The speedtest needs write permissions in the installation folder! +__Important:__ The speed test needs write permissions in the installation folder! ##### Server list 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 + "name":"Speed test 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) @@ -164,7 +164,7 @@ var SPEEDTEST_SERVERS=[ "getIpURL":"getIP.php" //path to getIP on this server (getIP.php or replacement) }, { - "name":"Speedtest Demo Server 2", + "name":"Speed test Demo Server 2", "server":"//mpotdemo2.fdossena.com/", "dlURL":"garbage.php", "ulURL":"empty.php", @@ -221,10 +221,10 @@ Requirements: To install a backend, simply copy all the files in the `backend` folder to your backend server. -__Important:__ The speedtest needs write permissions in the installation folder! +__Important:__ The speed test needs write permissions in the installation folder! #### ipinfo.io -The speedtest uses [ipinfo.io](https://ipinfo.io) to detect ISP and distance from server. This is completely optional and can be disabled if you want (see Speedtest settings), but it is enabled by default, and if you expect more than ~500 tests per day, you will need to sign up to [ipinfo.io](https://ipinfo.io) and edit `getIP_ipInfo_apikey.php` to set your access token. +The speed test uses [ipinfo.io](https://ipinfo.io) to detect ISP and distance from server. This is completely optional and can be disabled if you want (see speed test settings), but it is enabled by default, and if you expect more than ~500 tests per day, you will need to sign up to [ipinfo.io](https://ipinfo.io) and edit `getIP_ipInfo_apikey.php` to set your access token. IpInfo.io has kindly offered free access to their APIs for users of this project; if you're interested, contact me at [info@fdossena.com](mailto:info@fdossena.com) and provide a description of what you intend to do with the project, and you'll get the API key. @@ -247,7 +247,7 @@ __Multiple servers:__ * `example-multipleServers-full.html`: Same as `example-singleServer-full.html` but with multiple test points. Server selection is automatic but the server can be changed afterwards by the user ### Initialization -To use the speedtest in your page, first you need to load it: +To use the speed test in your page, first you need to load it: ```xml ``` @@ -271,7 +271,7 @@ s.onend=function(aborted){ } ``` -The `onupdate` event handler will be called periodically by the test with data coming from the speedtest worker thread. The `data` argument is an object containing the following: +The `onupdate` event handler will be called periodically by the test with data coming from the speed test worker thread. The `data` argument is an object containing the following: * __testState__: an integer between -1 and 5 * `-1` = Test not started yet * `0` = Test starting @@ -307,7 +307,7 @@ The `onupdate` event handler will be called periodically by the test with data c The `onend` event handler will be called at the end of the test (`onupdate` will be called first), with a boolean telling you if the test was aborted (either manually or because of an error) or if it ended normally. ### Test parameters -Before starting the test, you can change some of the settings from their default values. You might want to do this to better adapt the speedtest to a specific scenario, such as a satellite connection. To change a setting, use +Before starting the test, you can change some of the settings from their default values. You might want to do this to better adapt the speed test to a specific scenario, such as a satellite connection. To change a setting, use ```js s.setParameter("parameter_name",value); ``` @@ -362,7 +362,7 @@ __Main parameters:__ * __Important:__ On Firefox, it is better to run the upload test last * __getIp_ispInfo__: if true, the server will try to get ISP info and pass it along with the IP address. This will add `isp=true` to the request to `url_getIp`. getIP.php accomplishes this using ipinfo.io * Default: `true` -* __getIp_ispInfo_distance__: if true, the server will try to get an estimate of the distance from the client to the speedtest server. This will add a `distance` argument to the request to `url_getIp`. `__getIp_ispInfo__` must be enabled in order for this to work. getIP.php accomplishes this using ipinfo.io +* __getIp_ispInfo_distance__: if true, the server will try to get an estimate of the distance from the client to the speed test server. This will add a `distance` argument to the request to `url_getIp`. `__getIp_ispInfo__` must be enabled in order for this to work. getIP.php accomplishes this using ipinfo.io * `km`: estimate distance in kilometers * `mi`: estimate distance in miles * not set: do not measure distance @@ -421,7 +421,7 @@ __Advanced parameters:__ (Seriously, don't change these unless you know what you ### Multiple Points of Test If you want to use more than one test server, this is the time to add all your test points and select the best one. Skip this part if you don't want to use this feature. -The best way to do this is to declare an array with all your servers, and give it to the speedtest: +The best way to do this is to declare an array with all your servers, and give it to the speed test: ```js var SPEEDTEST_SERVERS=[ server1, @@ -483,15 +483,15 @@ s.abort(); When the test is finished, you can run it again if you want, or you can just destroy `s`. ## Implementation details -The purpose of this section is to help developers who want to make changes to the inner workings of the speedtest. +The purpose of this section is to help developers who want to make changes to the inner workings of the speed test. It will be divided into 4 sections: `speedtest.js`, `speedtest_worker.js`, the `backend` files and the `results` files. ### `speedtest.js` -This is the main interface between your webpage and the speedtest. -It hides the speedtest web worker to the page, and provides many convenient functions to control the test. +This is the main interface between your webpage and the speed test. +It hides the speed test web worker to the page, and provides many convenient functions to control the test. You can think of this as a finite state machine. These are the states (use getState() to see them): -* __0__: here you can change the speedtest settings (such as test duration) with the `setParameter("parameter",value)` function. From here you can either start the test using `start()` (goes to state 3) or you can add multiple test points using `addTestPoint(server)` or `addTestPoints(serverList)` (goes to state 1). Additionally, this is the perfect moment to set up callbacks for the `onupdate(data)` and `onend(aborted)` events. +* __0__: here you can change the speed test settings (such as test duration) with the `setParameter("parameter",value)` function. From here you can either start the test using `start()` (goes to state 3) or you can add multiple test points using `addTestPoint(server)` or `addTestPoints(serverList)` (goes to state 1). Additionally, this is the perfect moment to set up callbacks for the `onupdate(data)` and `onend(aborted)` events. * __1__: here you can add test points. You only need to do this if you want to use multiple test points. A server is defined as an object like this: ``` @@ -531,7 +531,7 @@ Change one of the test settings from their defaults. - parameter: string with the name of the parameter that you want to set - value: new value for the parameter -Invalid values or nonexistant parameters will be ignored by the speedtest worker. +Invalid values or nonexistant parameters will be ignored by the speed test worker. ##### addTestPoint(server) Add a test point (multiple points of test) @@ -547,7 +547,7 @@ Add a test point (multiple points of test) } ``` -Note that this will add `mpot`:`true` to the parameters sent to the speedtest worker. +Note that this will add `mpot`:`true` to the parameters sent to the speed test worker. ##### addTestPoints(list) Same as addTestPoint, but you can pass an array of servers @@ -582,7 +582,7 @@ At the end of the test, the `onend(aborted)` function will be called with a bool Aborts the test while it's running. ### `speedtest_worker.js` -This is where the actual speedtest code is. It receives the settings from the main thread, runs the test, and reports back the results. +This is where the actual speed test code is. It receives the settings from the main thread, runs the test, and reports back the results. The worker accepts 3 commands: * `start`: starts the test. Optionally, test settings can be passed as a JSON string after the word start and a space @@ -689,11 +689,11 @@ See the code for the implementation details, it's basically a bunch of bitwise o Simple UI to display and search test results. Not required to run the test. ## Alternative backends -If for some reason you can't or don't want to use PHP, the speedtest can run with other backends, or even no backend (with limited functionality). +If for some reason you can't or don't want to use PHP, the speed test can run with other backends, or even no backend (with limited functionality). You will need replacements for `backend/garbage.php` and `backend/empty.php` and optionally `backend/getIP.php`, and the test needs to know where to find them: ```js -//Speedtest initialization +//Speed test initialization var s=new Speedtest(); ... //Custom backend @@ -725,7 +725,7 @@ Your replacement can simply respond with the client's IP as plaintext or do some If you want to make your own backend, see the section on the implementation details of `getIP.php`. ### No backend -The speedtest can run, albeit with limited functionality, using only a web server as backend, with no PHP or other server-side scripting. +The speed test can run, albeit with limited functionality, using only a web server as backend, with no PHP or other server-side scripting. You will be able to run the download and upload test, but no IP, ISP and distance detection, no telemetry and results sharing, and only a single point of test. @@ -772,7 +772,7 @@ If the image doesn't display and the browser displays a broken image icon, FreeT If the image is blank, this usually happens because PHP can't find the font files inside the `results` folder. You can fix your PHP config or edit `results/index.php` and use absolute paths for the fonts. This is a [known issue with PHP](http://php.net/manual/en/function.imagefttext.php) and no real solution is known. #### My server is behind Cloudflare and I can't reach full speed on some of the tests -This is not a speedtest related issue, as it can be replicated in virtually any HTTP file upload/download. +This is not a speed test related issue, as it can be replicated in virtually any HTTP file upload/download. Go to your domain's DNS settings and change "DNS and HTTP proxy (CDN)" to "DNS only", and wait for the settings to be applied (can take a few minutes). #### On Windows Server, using IIS, the upload test doesn't work, CORS errors are visible in the console @@ -810,7 +810,7 @@ Also, make sure that the web server has write permission on the `results` folder * The ping/jitter test is measured by seeing how long it takes for an empty XHR to complete. It is not an acutal ICMP ping. Different browsers may also show different results, especially on very fast connections on slow devices. ### IE specific * The upload test is not precise on very fast connections with high latency (will probably be fixed by Edge 17) -* On IE11, a same origin policy error is erroneously triggered under unknown conditions. Seems to be related to running the test from unusual URLs like a top level domain (for instance http://abc/speedtest). These are bugs in IE11's implementation of the same origin policy, not in the speedtest itself. +* On IE11, a same origin policy error is erroneously triggered under unknown conditions. Seems to be related to running the test from unusual URLs like a top level domain (for instance http://abc/speedtest). These are bugs in IE11's implementation of the same origin policy, not in the speed test itself. * On IE11, under unknown circumstances, on some systems the test can only be run once, after which speedtest_worker.js will not be loaded by IE until the browser is restarted. This is a rare bug in IE11. ### Firefox specific * On some Linux systems with hardware acceleration turned off, the page rendering makes the browser lag, reducing the accuracy of the ping/jitter test, and potentially even the download and upload tests on very fast connections. diff --git a/doc_docker.md b/doc_docker.md index 753fe024c..71b975d4d 100755 --- a/doc_docker.md +++ b/doc_docker.md @@ -15,7 +15,7 @@ If you want to install LibreSpeed on a single server, you need to configure it i The test can be accessed on port 80. Here's a list of additional environment variables available in this mode: -* __`TITLE`__: Title of your speedtest. Default value: `LibreSpeed` +* __`TITLE`__: Title of your speed test. Default value: `LibreSpeed` * __`TELEMETRY`__: Whether to enable telemetry or not. Default value: `false` * __`ENABLE_ID_OBFUSCATION`__: When set to true with telemetry enabled, test IDs are obfuscated, to avoid exposing the database internal sequential IDs. Default value: `false` * __`REDACT_IP_ADDRESSES`__: When set to true with telemetry enabled, IP addresses and hostnames are redacted from the collected telemetry, for better privacy. Default value: `false` diff --git a/docker/frontend.php b/docker/frontend.php index 366cdadce..8e801b632 100755 --- a/docker/frontend.php +++ b/docker/frontend.php @@ -11,8 +11,8 @@ function I(i){return document.getElementById(i);} //LIST OF TEST SERVERS. See documentation for details if needed var SPEEDTEST_SERVERS= ; -//INITIALIZE SPEEDTEST -var s=new Speedtest(); //create speedtest object +//INITIALIZE SPEED TEST +var s=new Speedtest(); //create speed test object s.setParameter("telemetry_level","basic"); @@ -112,7 +112,7 @@ function format(d){ var uiData=null; function startStop(){ if(s.getState()==3){ - //speedtest is running, abort + //speed test is running, abort s.abort(); data=null; I("startStopBtn").className=""; @@ -432,7 +432,7 @@ function initUI(){ - Run speedtest + Run speed test

Charts by Chart.js

Source code diff --git a/example-singleServer-full.html b/example-singleServer-full.html index 823ef9f29..d72aa6624 100755 --- a/example-singleServer-full.html +++ b/example-singleServer-full.html @@ -321,7 +321,7 @@

Share results