Release 5.3.0 (#587)

* Update README.md

Added simple manual instructions

* Link to docker documentation

* Add basic docker compose example

* add descriptive alt-text to GIF

* Fix some typos and formatting

* Updated Docker to use php8.2-apache as the upstream image.

* Clean up apt lists after installation in Dockerfile

* Update Dockerfile

Co-authored-by: Quentame <polletquentin74@me.com>

* fix typo

* doc: sqlite db persistance explained

* Create docker-publish.yml

* Update docker-publish.yml

* Update docker-publish.yml

* fix action

* switch docker image location

* without image signing

* remove signing

* switch units to Mbit/s

* move examples to folder

* fix ipinfo parsing

* fix regression on getIpinfo

* removed trailing whitespaces

* integrate ios favicon

closes #400

* set single-server-full as index

---------

Co-authored-by: Les W <30345058+leswaters@users.noreply.github.com>
Co-authored-by: bt90 <btom1990@googlemail.com>
Co-authored-by: An | Anton Röhm <18481195+AnTheMaker@users.noreply.github.com>
Co-authored-by: 0kyn <0kyn.dev@gmail.com>
Co-authored-by: Marc Zampetti <zampettim@users.noreply.github.com>
Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Co-authored-by: Quentame <polletquentin74@me.com>
Co-authored-by: Stefan STIDL <stefan.stidl@ffg.at>
This commit is contained in:
sstidl 2023-11-26 12:46:27 +01:00 committed by GitHub
parent 6a4a05d883
commit e5f54fbd78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 332 additions and 128 deletions

View file

@ -24,5 +24,5 @@ Browser, OS, type of connection, unusual software, ...
What should have happened
## Screenshots
If necessary, add screenshots of the test.
If necessary, add screenshots of the test.
F12 > Network screenshots can be particularly useful

80
.github/workflows/docker-publish.yml vendored Normal file
View file

@ -0,0 +1,80 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
# schedule:
# - cron: '30 20 * * *'
push:
branches: ["*"]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request:
branches: ["{{is_default_branch}}"]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
results/idObfuscation_salt.php
backend/getIP_serverLocation.php
db-dir/

View file

@ -1,4 +1,4 @@
FROM php:7.4-apache
FROM php:8-apache
# Install extensions
RUN apt-get update && apt-get install -y \
@ -9,14 +9,13 @@ RUN apt-get update && apt-get install -y \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
&& rm -rf /var/lib/apt/lists/*
# Prepare files and folders
RUN mkdir -p /speedtest/
# Copy sources
COPY backend/ /speedtest/backend
COPY results/*.php /speedtest/results/
@ -30,8 +29,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 +39,5 @@ ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=80
# Final touches
EXPOSE 80
CMD ["bash", "/entrypoint.sh"]

View file

@ -10,7 +10,7 @@ This is a very lightweight speed test implemented in Javascript, using XMLHttpRe
[Take a speed test](https://librespeed.org)
## Compatibility
All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari.
All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari.
Works with mobile versions too.
## Features
@ -23,7 +23,7 @@ Works with mobile versions too.
* Results sharing (optional)
* Multiple Points of Test (optional)
![Screenshot](https://speedtest.fdossena.com/mpot_v6.gif)
![Screenrecording of a running Speedtest](https://speedtest.fdossena.com/mpot_v6.gif)
## Server requirements
@ -32,14 +32,27 @@ Works with mobile versions too.
* MySQL database to store test results (optional, Microsoft SQL Server, 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
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 [GitHub](https://github.com/librespeed/speedtest/pkgs/container/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).
@ -48,8 +61,8 @@ A Go implementation is available in the [`speedtest-go`](https://github.com/libr
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)
[![Donate with Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate)
[Donate with PayPal](https://www.paypal.me/sineisochronic)
## License
Copyright (C) 2016-2022 Federico Dossena

View file

@ -76,7 +76,7 @@ function getIpInfoTokenString()
return '';
}
return '?token='.$IPINFO_APIKEY;
return '?token=' . $IPINFO_APIKEY;
}
/**
@ -86,7 +86,7 @@ function getIpInfoTokenString()
*/
function getIspInfo($ip)
{
$json = file_get_contents('https://ipinfo.io/'.$ip.'/json'.getIpInfoTokenString());
$json = file_get_contents('https://ipinfo.io/' . $ip . '/json' . getIpInfoTokenString());
if (!is_string($json)) {
return null;
}
@ -106,17 +106,91 @@ function getIspInfo($ip)
*/
function getIsp($rawIspInfo)
{
if (
!is_array($rawIspInfo)
|| !array_key_exists('org', $rawIspInfo)
|| !is_string($rawIspInfo['org'])
|| empty($rawIspInfo['org'])
) {
return 'Unknown ISP';
if (is_array($rawIspInfo)) {
/* variant with no token
has json like:
{
"ip": "xxx.xxx.xxx.xxx",
"hostname": "example.com",
"city": "Vienna",
"region": "Vienna",
"country": "AT",
"loc": "48.2085,16.3721",
"org": "ASxxxx T-Mobile Austria GmbH",
"postal": "nnnn",
"timezone": "Europe/Vienna",
"readme": "https://ipinfo.io/missingauth"
}
*/
if (
array_key_exists('org', $rawIspInfo)
&& is_string($rawIspInfo['org'])
&& !empty($rawIspInfo['org'])
) {
// Remove AS##### from ISP name, if present
return preg_replace('/AS\\d+\\s/', '', $rawIspInfo['org']);
}
/*
variant with valid token has json:
{
"ip": "xxx.xxx.xxx.xxx",
"hostname": "example.com",
"city": "Vienna",
"region": "Vienna",
"country": "AT",
"loc": "48.2085,16.3721",
"postal": "1010",
"timezone": "Europe/Vienna",
"asn": {
"asn": "ASxxxx",
"name": "T-Mobile Austria GmbH",
"domain": "t-mobile.at",
"route": "xxx.xxx.xxx.xxx/xx",
"type": "isp"
},
"company": {
"name": "XX",
"domain": "example.com",
"type": "isp"
},
"privacy": {
"vpn": true,
"proxy": false,
"tor": false,
"relay": false,
"hosting": false,
"service": ""
},
"abuse": {
"address": "...",
"country": "AT",
"email": "abuse@example.com",
"name": "XXX",
"network": "xxx.xxx.xxx.xxx-xxx.xxx.xxx.xxx",
"phone": ""
},
"domains": {
"total": 0,
"domains": [
]
}
}
*/
if (
array_key_exists('asn', $rawIspInfo)
&& is_array($rawIspInfo['asn'])
&& !empty($rawIspInfo['asn'])
&& array_key_exists('name', $rawIspInfo['asn'])
&& is_string($rawIspInfo['asn']['name'])
) {
// Remove AS##### from ISP name, if present
return $rawIspInfo['asn']['name'];
}
}
// Remove AS##### from ISP name, if present
return preg_replace('/AS\\d+\\s/', '', $rawIspInfo['org']);
return 'Unknown ISP';
}
/**
@ -135,7 +209,7 @@ function getServerLocation()
return $serverLoc;
}
$json = file_get_contents('https://ipinfo.io/json'.getIpInfoTokenString());
$json = file_get_contents('https://ipinfo.io/json' . getIpInfoTokenString());
if (!is_string($json)) {
return null;
}
@ -151,7 +225,7 @@ function getServerLocation()
}
$serverLoc = $details['loc'];
$cacheData = "<?php\n\n\$serverLoc = '".addslashes($serverLoc)."';\n";
$cacheData = "<?php\n\n\$serverLoc = '" . addslashes($serverLoc) . "';\n";
file_put_contents(SERVER_LOCATION_CACHE_FILE, $cacheData);
return $serverLoc;
@ -240,7 +314,7 @@ function calculateDistance($clientLocation, $serverLocation, $unit)
$dist = '<15';
}
return $dist.' mi';
return $dist . ' mi';
}
if ('km' === $unit) {
@ -249,7 +323,7 @@ function calculateDistance($clientLocation, $serverLocation, $unit)
$dist = '<20';
}
return $dist.' km';
return $dist . ' km';
}
return null;
@ -288,17 +362,17 @@ function sendResponse(
) {
$processedString = $ip;
if (is_string($ipInfo)) {
$processedString .= ' - '.$ipInfo;
$processedString .= ' - ' . $ipInfo;
}
if (
is_array($rawIspInfo)
&& array_key_exists('country', $rawIspInfo)
) {
$processedString .= ', '.$rawIspInfo['country'];
$processedString .= ', ' . $rawIspInfo['country'];
}
if (is_string($distance)) {
$processedString .= ' ('.$distance.')';
$processedString .= ' (' . $distance . ')';
}
sendHeaders();

64
doc.md
View file

@ -1,6 +1,6 @@
# LibreSpeed
> by Federico Dossena
> by Federico Dossena
> Version 5.2.4
> [https://github.com/librespeed/speedtest/](https://github.com/librespeed/speedtest/)
@ -109,7 +109,7 @@ A basic front-end for visualizing and searching tests by ID is available in `res
A login is required to access the interface. __Important__: change the default password in `results/telemetry_settings.php`.
#### The end
Now that the test is installed, rename one of the examples to `index.html` and delete the other examples.
Now that the test is installed, rename one of the examples to `index.html` and delete the other examples.
The best starting point for most people is `example-singleServer-gauges.html`. If you want to use telemetry and results sharing, use `example-singleServer-full.html` instead.
If you're not using telemetry and results sharing, you can delete the `results` folder too.
@ -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.__
@ -459,7 +459,7 @@ s.selectServer(function(server){
//do something
})
```
The `selectServer` function is asynchronous in order to avoid freeing the UI, and it will run a callback function when it is done choosing the server with the lowest ping.
The `selectServer` function is asynchronous in order to avoid freeing the UI, and it will run a callback function when it is done choosing the server with the lowest ping.
The `server` argument is the selected server, and you can display it in the UI if you want. __You cannot start the test until the selection is done!__
You can also set the test point manually (for instance, from a combobox in the UI):
@ -483,7 +483,7 @@ 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 speed test.
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`
@ -506,16 +506,16 @@ 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:
- `dlStatus`: download speed in mbps
- `ulStatus`: upload speed in mbps
* __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 Mbit/s
- `ulStatus`: upload speed in Mbit/s
- `pingStatus`: ping in ms
- `jitterStatus`: jitter in ms
- `dlProgress`: progress of the download test as a float 0-1
- `ulProgress`: progress of the upload test as a float 0-1
- `pingProgress`: progress of the ping/jitter test as a float 0-1
- `testState`: state of the test (-1=not started, 0=starting, 1=download test, 2=ping+jitter test, 3=upload test, 4=finished, 5=aborted)
- `clientIp`: IP address of the client performing the test (and optionally ISP and distance)
- `clientIp`: IP address of the client performing the test (and optionally ISP and distance)
At the end of the test, the `onend` function will be called, with a boolean specifying whether the test was aborted or if it ended normally.
The test can be aborted at any time with `abort()`.
At the end of the test, it will move to state 4
@ -575,7 +575,7 @@ Starts the test.
Note (multiple points of test): the selected server will be added to the `telemetry_extra` string. If this string was already set, then `telemetry_extra` will be a JSON string containing both the server and the original string
During the test, the `onupdate(data)` callback function will be called periodically with data from the worker.
During the test, the `onupdate(data)` callback function will be called periodically with data from the worker.
At the end of the test, the `onend(aborted)` function will be called with a boolean telling you if the test was aborted or if it ended normally.
##### abort()
@ -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,14 +741,14 @@ 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).
#### Download test gives very low result
Are garbage.php and empty.php (or your replacements) reachable?
Press F12, select network and start the test. Do you see errors? (cancelled requests are not errors)
Are garbage.php and empty.php (or your replacements) reachable?
Press F12, select network and start the test. Do you see errors? (cancelled requests are not errors)
If a small download starts, open it in a text editor. Does it say it's missing openssl_random_pseudo_bytes()? In this case, install OpenSSL (this is usually included when you install Apache and PHP on most distros).
#### Upload test is inaccurate, and/or I see lag spikes
@ -764,15 +764,15 @@ You're running the test on localhost, therefore it is trying to measure the spee
Make sure your server is sending the `Connection:keep-alive` header
#### The server is behind a load balancer, proxy, etc. and I get the wrong IP address
Edit getIP.php and replace lines 14-23 with what is more appropriate in your scenario.
Edit getIP.php and replace lines 14-23 with what is more appropriate in your scenario.
Example: `$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];`
#### The results sharing just generates a blank image
If the image doesn't display and the browser displays a broken image icon, FreeType2 is not installed or configured properly.
If the image doesn't display and the browser displays a broken image icon, FreeType2 is not installed or configured properly.
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 speed test 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
@ -781,33 +781,33 @@ This is a configuration issue. Make a file called web.config in wwwroot and adap
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<cors enabled="true" failUnlistedOrigins="false">
<add origin="*">
<cors enabled="true" failUnlistedOrigins="false">
<add origin="*">
<allowHeaders allowAllRequestedHeaders="true" />
<allowMethods>
<add method="GET" />
<add method="POST" />
<add method="PUT" />
<add method="DELETE" />
<add method="OPTIONS" />
</allowMethods>
<allowMethods>
<add method="GET" />
<add method="POST" />
<add method="PUT" />
<add method="DELETE" />
<add method="OPTIONS" />
</allowMethods>
<exposeHeaders>
</exposeHeaders>
</exposeHeaders>
</add>
</cors>
</system.webServer>
</cors>
</system.webServer>
</configuration>
```
#### ID obfuscation doesn't work (incorrect output, blank results image)
ID obfuscation only works on 64-bit PHP (requires PHP_INT_SIZE to be 8).
ID obfuscation only works on 64-bit PHP (requires PHP_INT_SIZE to be 8).
Note that older versions of PHP 5 on Windows use PHP_INT_SIZE of 4, even if they're 64 bit. If you're in this situation, update your PHP install.
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 speed test itself.
@ -818,7 +818,7 @@ Also, make sure that the web server has write permission on the `results` folder
## Contributing
Since this is an open source project, you can modify it.
If you made some changes that you think should make it into the main project, send a Pull Request on GitHub, or contact me at [info@fdossena.com](mailto:info@fdossena.com).
If you made some changes that you think should make it into the main project, send a Pull Request on GitHub, or contact me at [info@fdossena.com](mailto:info@fdossena.com).
We don't require you to use a specific coding convention, write the code however you want and we'll change the formatting if necessary.
Donations are also appreciated: you can donate with [PayPal](https://www.paypal.me/sineisochronic) or [Liberapay](https://liberapay.com/fdossena/donate).

View file

@ -1,13 +1,41 @@
A docker version of LibreSpeed is available on docker hub: [https://hub.docker.com/r/adolfintel/speedtest/](https://hub.docker.com/r/adolfintel/speedtest/)
A docker version of LibreSpeed is available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest)
## Downloading from Docker hub
To download LibreSpeed from the docker hub, use this command:
## Downloading docker image
To download LibreSpeed from the docker repo, use this command:
```
docker pull adolfintel/speedtest
docker pull ghcr.io/librespeed/speedtest
```
You will now have a new docker image called `adolfintel/speedtest`.
You will now have a new docker image called `librespeed/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: ghcr.io/librespeed/speedtest:latest
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`.
@ -16,7 +44,7 @@ The test can be accessed on port 80.
Here's a list of additional environment variables available in this mode:
* __`TITLE`__: Title of your speed test. Default value: `LibreSpeed`
* __`TELEMETRY`__: Whether to enable telemetry or not. Default value: `false`
* __`TELEMETRY`__: Whether to enable telemetry or not. If enabled, you maybe want your data to be persisted. See below. 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`
* __`PASSWORD`__: Password to access the stats page. If not set, stats page will not allow accesses.
@ -28,17 +56,24 @@ Here's a list of additional environment variables available in this mode:
If telemetry is enabled, a stats page will be available at `http://your.server/results/stats.php`, but a password must be specified.
### Persist sqlite database
Default DB driver is sqlite. The DB file is written to `/database/db.sql`.
So if you want your data to be persisted over image updates, you have to mount a volume with `-v $PWD/db-dir:/database`.
###### Example
This command starts LibreSpeed in standalone mode, with the default settings, on port 80:
```
docker run -e MODE=standalone -p 80:80 -it adolfintel/speedtest
docker run -e MODE=standalone -p 80:80 -it ghcr.io/librespeed/speedtest
```
This command starts LibreSpeed in standalone mode, with telemetry, ID obfuscation and a stats password, on port 86:
```
docker run -e MODE=standalone -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -e WEBPORT=86 -p 86:86 -it adolfintel/speedtest
docker run -e MODE=standalone -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -e WEBPORT=86 -p 86:86 -v $PWD/db-dir/:/database -it ghcr.io/librespeed/speedtest
```
## Multiple Points of Test
@ -55,7 +90,7 @@ Here's a list of additional environment variables available in this mode:
###### Example:
This command starts LibreSpeed in backend mode, with the default settings, on port 80:
```
docker run -e MODE=backend -p 80:80 -it adolfintel/speedtest
docker run -e MODE=backend -p 80:80 -it ghcr.io/librespeed/speedtest
```
### Frontend mode
@ -85,7 +120,7 @@ In frontend mode, LibreSpeed serves clients the Web UI and a list of servers. To
```
Note: if a server only supports HTTP or HTTPS, specify the protocol in the server field. If it supports both, just use `//`.
* Mount this file to `/servers.json` in the container (example at the end of this file)
The test can be accessed on port 80.
Here's a list of additional environment variables available in this mode:
@ -102,5 +137,5 @@ Here's a list of additional environment variables available in this mode:
###### Example
This command starts LibreSpeed in frontend mode, with a given `servers.json` file, and with telemetry, ID obfuscation, and a stats password:
```
docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it adolfintel/speedtest
docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it ghcr.io/librespeed/speedtest
```

View file

@ -37,7 +37,7 @@ fi
# Apply Telemetry settings when running in standalone or frontend mode and telemetry is enabled
if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalone" ) ]]; then
cp -r /speedtest/results /var/www/html/results
if [ "$MODE" == "frontend" ]; then
mkdir /var/www/html/backend
cp /speedtest/backend/getIP_util.php /var/www/html/backend
@ -82,7 +82,7 @@ chown -R www-data /var/www/html/*
# Allow selection of Apache port for network_mode: host
if [ "$WEBPORT" != "80" ]; then
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf
fi
echo "Done, Starting APACHE"

View file

@ -3,6 +3,8 @@
<head>
<link rel="shortcut icon" href="favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<link rel="apple-touch-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta charset="UTF-8" />
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript">
@ -409,13 +411,13 @@ function initUI(){
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div id="ipArea">

View file

@ -2,6 +2,8 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<link rel="apple-touch-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta charset="UTF-8" />
<link rel="shortcut icon" href="favicon.ico">
<script type="text/javascript" src="speedtest.js"></script>
@ -301,13 +303,13 @@ function initUI(){
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div id="ipArea">

View file

@ -424,13 +424,13 @@ function initUI(){
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div id="ipArea">

View file

@ -70,7 +70,7 @@ function loadServers(){ //called when the page is fully loaded
s.addTestPoints(SPEEDTEST_SERVERS);
selectServer();
}
}
@ -212,12 +212,12 @@ function I(id){return document.getElementById(id);}
<div class="testArea">
<div class="testName">Download</div>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div class="testGroup">

View file

@ -157,12 +157,12 @@ function I(id){return document.getElementById(id);}
<div class="testArea">
<div class="testName">Download</div>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
</div>

View file

@ -242,13 +242,13 @@ function initUI(){
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div id="ipArea">

View file

@ -160,12 +160,12 @@ function I(id){return document.getElementById(id);}
<div class="testArea">
<div class="testName">Download</div>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div class="testGroup">

View file

@ -180,12 +180,12 @@ function I(id){return document.getElementById(id);}
<div class="testArea">
<div class="testName">Download</div>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div class="testGroup">

View file

@ -298,13 +298,13 @@ function initUI(){
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
<div class="testArea">
<div class="testName">Upload</div>
<canvas id="ulMeter" class="meter"></canvas>
<div id="ulText" class="meterText"></div>
<div class="unit">Mbps</div>
<div class="unit">Mbit/s</div>
</div>
</div>
<div id="ipArea">

View file

@ -162,7 +162,7 @@ function drawImage($speedtest)
$POSITION_Y_WATERMARK = 223 * $SCALE;
// configure labels
$MBPS_TEXT = 'Mbps';
$MBPS_TEXT = 'Mbit/s';
$MS_TEXT = 'ms';
$PING_TEXT = 'Ping';
$JIT_TEXT = 'Jitter';

View file

@ -55,5 +55,5 @@ if (!is_array($speedtest)) {
echo '{}';
}
$speedtest = formatSpeedtestData($speedtest);
echo json_encode(array('timestamp'=>$speedtest['timestamp'],'download'=>$speedtest['dl'],'upload'=>$speedtest['ul'],'ping'=>$speedtest['ping'],'jitter'=>$speedtest['jitter'],'ispinfo'=>$speedtest['ispinfo']));

View file

@ -92,7 +92,7 @@ if(!isset($db_type) || $db_type != 'postgresql'){
echo $failed;
}
?>
</td><td>Only required if using sqlite.</td></tr>
</td><td>Only required if using postgresql.</td></tr>
<tr><td colspan="3" class='SectionHeading'>Database check</td></tr>
@ -171,7 +171,7 @@ echo ' ';
print_r($pdo);
if(!isset($pdo)){
echo 'got nothing';
}
}
if($pdo == false){
echo 'got a false';
}
@ -186,4 +186,4 @@ if (($pdo instanceof PDO)) {
$speedtest = getSpeedtestUserById(1);
print_r ($speedtest);
*/
?>
?>

View file

@ -15,7 +15,7 @@ function getPdo($returnErrorMessage = false)
) {
if($returnErrorMessage){
return 'missing TELEMETRY_SETTINGS_FILE';
}
}
return false;
}
@ -24,7 +24,7 @@ function getPdo($returnErrorMessage = false)
if (!isset($db_type)) {
if($returnErrorMessage){
return "db_type not set in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
@ -41,7 +41,7 @@ function getPdo($returnErrorMessage = false)
)) {
if($returnErrorMessage){
return "Required MSSQL database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
@ -53,7 +53,7 @@ function getPdo($returnErrorMessage = false)
) {
if($returnErrorMessage){
return "Required MSSQL database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
$dsn = 'sqlsrv:'
@ -84,7 +84,7 @@ function getPdo($returnErrorMessage = false)
)) {
if($returnErrorMessage){
return "Required mysql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
@ -100,7 +100,7 @@ function getPdo($returnErrorMessage = false)
if (!isset($Sqlite_db_file)) {
if($returnErrorMessage){
return "Required sqlite database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
@ -135,7 +135,7 @@ function getPdo($returnErrorMessage = false)
)) {
if($returnErrorMessage){
return "Required postgresql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
}
return false;
}
@ -148,13 +148,13 @@ function getPdo($returnErrorMessage = false)
} catch (Exception $e) {
if($returnErrorMessage){
return $e->getMessage();
}
}
return false;
}
if($returnErrorMessage){
return "db_type '" . $db_type . "' not supported";
}
}
return false;
}
@ -179,7 +179,7 @@ function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping,
if (!($pdo instanceof PDO)) {
if($returnExceptionOnError){
return new Exception("Failed to get database connection object");
}
}
return false;
}
@ -196,7 +196,7 @@ function insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping,
} catch (Exception $e) {
if($returnExceptionOnError){
return $e;
}
}
return false;
}
@ -222,7 +222,7 @@ function getSpeedtestUserById($id,$returnExceptionOnError = false)
if (!($pdo instanceof PDO)) {
if($returnExceptionOnError){
return new Exception("Failed to get database connection object");
}
}
return false;
}
@ -243,7 +243,7 @@ function getSpeedtestUserById($id,$returnExceptionOnError = false)
} catch (Exception $e) {
if($returnExceptionOnError){
return $e;
}
}
return false;
}

View file

@ -17,7 +17,7 @@ CREATE TABLE [dbo].[speedtest_users](
[ping] [nvarchar](max) NULL,
[jitter] [nvarchar](max) NULL,
[log] [nvarchar](max) NULL,
CONSTRAINT [PK_speedtest_users] PRIMARY KEY CLUSTERED
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]

View file

@ -15,14 +15,14 @@ SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
@ -68,7 +68,7 @@ CREATE SEQUENCE speedtest_users_id_seq
CACHE 1;
-- Commented out the following line because it assumes the user of the speedtest server, @bplower
-- ALTER TABLE speedtest_users_id_seq OWNER TO speedtest;
-- ALTER TABLE speedtest_users_id_seq OWNER TO speedtest;
--
-- Name: speedtest_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: speedtest

View file

@ -8,9 +8,9 @@
/*
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.
The best way to learn how to use this is to look at the basic example, but here's some documentation.
To initialize the test, create a new Speedtest object:
var s=new Speedtest();
Now you can think of this as a finite state machine. These are the states (use getState() to see them):
@ -27,16 +27,16 @@
}
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:
- dlStatus: download speed in mbps
- ulStatus: upload speed in mbps
- 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 Mbit/s
- ulStatus: upload speed in Mbit/s
- pingStatus: ping in ms
- jitterStatus: jitter in ms
- dlProgress: progress of the download test as a float 0-1
- ulProgress: progress of the upload test as a float 0-1
- pingProgress: progress of the ping/jitter test as a float 0-1
- testState: state of the test (-1=not started, 0=starting, 1=download test, 2=ping+jitter test, 3=upload test, 4=finished, 5=aborted)
- clientIp: IP address of the client performing the test (and optionally ISP and distance)
- clientIp: IP address of the client performing the test (and optionally ISP and distance)
At the end of the test, the onend function will be called, with a boolean specifying whether the test was aborted or if it ended normally.
The test can be aborted at any time with abort().
At the end of the test, it will move to state 4

View file

@ -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;