Skip to content

Commit

Permalink
Merge commit 'bce9ced9ff0aca51ff4b8855f8129eab2f2b750d' into pr/LordM…
Browse files Browse the repository at this point in the history
…rcS/522
  • Loading branch information
sstidl committed Nov 4, 2023
2 parents 8217634 + bce9ced commit d427df7
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 88 deletions.
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand All @@ -41,6 +39,5 @@ ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=80

# Final touches

EXPOSE 80
CMD ["bash", "/entrypoint.sh"]
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -29,17 +29,30 @@ 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
## 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 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).
Expand Down
70 changes: 35 additions & 35 deletions doc.md

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions doc_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,42 @@ 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`.

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`
* __`TELEMETRY`__: Whether to enable telemetry or not. Default value: `false`
* __`TITLE`__: Title of your speed test. Default value: `LibreSpeed`
* __`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.
Expand All @@ -28,6 +56,13 @@ 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:

Expand All @@ -38,7 +73,7 @@ docker run -e MODE=standalone -p 80:80 -it adolfintel/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 adolfintel/speedtest
```

## Multiple Points of Test
Expand Down
8 changes: 4 additions & 4 deletions docker/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function I(i){return document.getElementById(i);}
//LIST OF TEST SERVERS. See documentation for details if needed
var SPEEDTEST_SERVERS= <?= file_get_contents('/servers.json') ?: '[]' ?>;

//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
//INITIALIZE SPEED TEST
var s=new Speedtest(); //create speed test object
<?php if(getenv("TELEMETRY")=="true"){ ?>
s.setParameter("telemetry_level","basic");
<?php } ?>
Expand Down Expand Up @@ -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="";
Expand Down Expand Up @@ -432,7 +432,7 @@ function initUI(){
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<p>This HTML5 Speedtest server is configured with telemetry enabled.</p>
<p>This HTML5 speed test server is configured with telemetry enabled.</p>
<h4>What data we collect</h4>
<p>
At the end of the test, the following data is collected and stored:
Expand Down
8 changes: 4 additions & 4 deletions docker/standalone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript">
function I(i){return document.getElementById(i);}
//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
//INITIALIZE SPEED TEST
var s=new Speedtest(); //create speed test object
<?php if(getenv("TELEMETRY")=="true"){ ?>
s.setParameter("telemetry_level","basic");
<?php } ?>
Expand Down Expand Up @@ -65,7 +65,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="";
Expand Down Expand Up @@ -324,7 +324,7 @@ function initUI(){
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<p>This HTML5 Speedtest server is configured with telemetry enabled.</p>
<p>This HTML5 speed test server is configured with telemetry enabled.</p>
<h4>What data we collect</h4>
<p>
At the end of the test, the following data is collected and stored:
Expand Down
6 changes: 3 additions & 3 deletions example-multipleServers-full.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
];

//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
var s=new Speedtest(); //create speed test object
s.setParameter("telemetry_level","basic"); //enable telemetry

//SERVER AUTO SELECTION
Expand Down Expand Up @@ -122,7 +122,7 @@
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="";
Expand Down Expand Up @@ -447,7 +447,7 @@ <h3>Share results</h3>
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<p>This HTML5 Speedtest server is configured with telemetry enabled.</p>
<p>This HTML5 speed test server is configured with telemetry enabled.</p>
<h4>What data we collect</h4>
<p>
At the end of the test, the following data is collected and stored:
Expand Down
2 changes: 1 addition & 1 deletion example-singleServer-basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h4>Latency</h4>
document.getElementById('ping').textContent = data.pingStatus + ' ms, ' + data.jitterStatus + ' ms jitter'
document.getElementById('ip').textContent = data.clientIp
}
s.start(); // start the speedtest with default settings
s.start(); // start the speed test with default settings
</script>

<a href="https://github.com/librespeed/speedtest">Source code</a>
Expand Down
2 changes: 1 addition & 1 deletion example-singleServer-chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ <h2>Latency</h2>
<br/>
<a href="javascript:abortTest()" id="abortBtn">Abort</a>
</div>
<a href="javascript:runTest()" id="startBtn">Run speedtest</a>
<a href="javascript:runTest()" id="startBtn">Run speed test</a>
<br/><br/> Charts by <a href="http://www.chartjs.org/">Chart.js</a><br/><br/><a href="https://github.com/librespeed/speedtest">Source code</a>
</body>
</html>
2 changes: 1 addition & 1 deletion example-singleServer-full.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ <h3>Share results</h3>
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<p>This HTML5 Speedtest server is configured with telemetry enabled.</p>
<p>This HTML5 speed test server is configured with telemetry enabled.</p>
<h4>What data we collect</h4>
<p>
At the end of the test, the following data is collected and stored:
Expand Down
Loading

0 comments on commit d427df7

Please sign in to comment.