Skip to content

Commit e5f54fb

Browse files
sstidlawslesbt90AnTheMaker0kyn
authored
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 <[email protected]> * 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 <[email protected]> Co-authored-by: bt90 <[email protected]> Co-authored-by: An | Anton Röhm <[email protected]> Co-authored-by: 0kyn <[email protected]> Co-authored-by: Marc Zampetti <[email protected]> Co-authored-by: Peter Dave Hello <[email protected]> Co-authored-by: Quentame <[email protected]> Co-authored-by: Stefan STIDL <[email protected]>
1 parent 6a4a05d commit e5f54fb

28 files changed

+332
-128
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ Browser, OS, type of connection, unusual software, ...
2424
What should have happened
2525

2626
## Screenshots
27-
If necessary, add screenshots of the test.
27+
If necessary, add screenshots of the test.
2828
F12 > Network screenshots can be particularly useful

.github/workflows/docker-publish.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Docker
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
# schedule:
10+
# - cron: '30 20 * * *'
11+
push:
12+
branches: ["*"]
13+
# Publish semver tags as releases.
14+
tags: ["v*.*.*"]
15+
pull_request:
16+
branches: ["{{is_default_branch}}"]
17+
18+
env:
19+
# Use docker.io for Docker Hub if empty
20+
REGISTRY: ghcr.io
21+
# github.repository as <account>/<repo>
22+
IMAGE_NAME: ${{ github.repository }}
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read
29+
packages: write
30+
# This is used to complete the identity challenge
31+
# with sigstore/fulcio when running outside of PRs.
32+
id-token: write
33+
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v3
37+
38+
# Set up BuildKit Docker container builder to be able to build
39+
# multi-platform images and export cache
40+
# https://github.com/docker/setup-buildx-action
41+
- name: Set up Docker Buildx
42+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
43+
44+
# Login against a Docker registry except on PR
45+
# https://github.com/docker/login-action
46+
- name: Log into registry ${{ env.REGISTRY }}
47+
if: github.event_name != 'pull_request'
48+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
49+
with:
50+
registry: ${{ env.REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
# Extract metadata (tags, labels) for Docker
55+
# https://github.com/docker/metadata-action
56+
- name: Extract Docker metadata
57+
id: meta
58+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
61+
tags: |
62+
type=ref,event=branch
63+
type=ref,event=pr
64+
# set latest tag for default branch
65+
type=raw,value=latest,enable={{is_default_branch}}
66+
type=semver,pattern={{version}}
67+
type=semver,pattern={{major}}.{{minor}}
68+
69+
# Build and push Docker image with Buildx (don't push on PR)
70+
# https://github.com/docker/build-push-action
71+
- name: Build and push Docker image
72+
id: build-and-push
73+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
74+
with:
75+
context: .
76+
push: ${{ github.event_name != 'pull_request' }}
77+
tags: ${{ steps.meta.outputs.tags }}
78+
labels: ${{ steps.meta.outputs.labels }}
79+
cache-from: type=gha
80+
cache-to: type=gha,mode=max

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
results/idObfuscation_salt.php
22
backend/getIP_serverLocation.php
3+
db-dir/

Dockerfile

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:7.4-apache
1+
FROM php:8-apache
22

33
# Install extensions
44
RUN apt-get update && apt-get install -y \
@@ -9,14 +9,13 @@ RUN apt-get update && apt-get install -y \
99
&& docker-php-ext-install -j$(nproc) iconv \
1010
&& docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
1111
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
12-
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql
12+
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \
13+
&& rm -rf /var/lib/apt/lists/*
1314

1415
# Prepare files and folders
15-
1616
RUN mkdir -p /speedtest/
1717

1818
# Copy sources
19-
2019
COPY backend/ /speedtest/backend
2120

2221
COPY results/*.php /speedtest/results/
@@ -30,8 +29,7 @@ COPY docker/servers.json /servers.json
3029
COPY docker/*.php /speedtest/
3130
COPY docker/entrypoint.sh /
3231

33-
# Prepare environment variabiles defaults
34-
32+
# Prepare default environment variables
3533
ENV TITLE=LibreSpeed
3634
ENV MODE=standalone
3735
ENV PASSWORD=password
@@ -41,6 +39,5 @@ ENV REDACT_IP_ADDRESSES=false
4139
ENV WEBPORT=80
4240

4341
# Final touches
44-
4542
EXPOSE 80
4643
CMD ["bash", "/entrypoint.sh"]

README.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is a very lightweight speed test implemented in Javascript, using XMLHttpRe
1010
[Take a speed test](https://librespeed.org)
1111

1212
## Compatibility
13-
All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari.
13+
All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari.
1414
Works with mobile versions too.
1515

1616
## Features
@@ -23,7 +23,7 @@ Works with mobile versions too.
2323
* Results sharing (optional)
2424
* Multiple Points of Test (optional)
2525

26-
![Screenshot](https://speedtest.fdossena.com/mpot_v6.gif)
26+
![Screenrecording of a running Speedtest](https://speedtest.fdossena.com/mpot_v6.gif)
2727

2828

2929
## Server requirements
@@ -32,14 +32,27 @@ Works with mobile versions too.
3232
* MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported)
3333
* A fast! internet connection
3434

35-
## Installation videos
35+
## Installation
36+
Assuming you have PHP installed, the installation steps are quite simple.
37+
I set this up on a QNAP.
38+
For this example, I am using a folder called **speedtest** in my web share area.
39+
40+
1. Choose one of the example-xxx.html files as your new index.html in your speedtest folder. I used: example-singleServer-full.html
41+
2. Add: speedtest.js, speedtest_worker.js, and favicon.ico to your speedtest folder.
42+
3. Download all of the backend folder into speedtest/backend.
43+
4. Download all of the results folder into speedtest/results.
44+
5. Be sure your permissions allow execute (755).
45+
6. Visit YOURSITE/speedtest/index.html and voila!
46+
47+
### Installation Video
48+
There is a more in-depth installation video here:
3649
* [Quick start installation guide for Ubuntu Server 19.04](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag)
3750

3851
## Android app
3952
A template to build an Android client for your LibreSpeed installation is available [here](https://github.com/librespeed/speedtest-android).
4053

4154
## Docker
42-
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
55+
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.
4356

4457
## Go backend
4558
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
4861
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.
4962

5063
## Donate
51-
[![Donate with Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate)
52-
[Donate with PayPal](https://www.paypal.me/sineisochronic)
64+
[![Donate with Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate)
65+
[Donate with PayPal](https://www.paypal.me/sineisochronic)
5366

5467
## License
5568
Copyright (C) 2016-2022 Federico Dossena

backend/getIP.php

+92-18
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function getIpInfoTokenString()
7676
return '';
7777
}
7878

79-
return '?token='.$IPINFO_APIKEY;
79+
return '?token=' . $IPINFO_APIKEY;
8080
}
8181

8282
/**
@@ -86,7 +86,7 @@ function getIpInfoTokenString()
8686
*/
8787
function getIspInfo($ip)
8888
{
89-
$json = file_get_contents('https://ipinfo.io/'.$ip.'/json'.getIpInfoTokenString());
89+
$json = file_get_contents('https://ipinfo.io/' . $ip . '/json' . getIpInfoTokenString());
9090
if (!is_string($json)) {
9191
return null;
9292
}
@@ -106,17 +106,91 @@ function getIspInfo($ip)
106106
*/
107107
function getIsp($rawIspInfo)
108108
{
109-
if (
110-
!is_array($rawIspInfo)
111-
|| !array_key_exists('org', $rawIspInfo)
112-
|| !is_string($rawIspInfo['org'])
113-
|| empty($rawIspInfo['org'])
114-
) {
115-
return 'Unknown ISP';
109+
if (is_array($rawIspInfo)) {
110+
/* variant with no token
111+
has json like:
112+
{
113+
"ip": "xxx.xxx.xxx.xxx",
114+
"hostname": "example.com",
115+
"city": "Vienna",
116+
"region": "Vienna",
117+
"country": "AT",
118+
"loc": "48.2085,16.3721",
119+
"org": "ASxxxx T-Mobile Austria GmbH",
120+
"postal": "nnnn",
121+
"timezone": "Europe/Vienna",
122+
"readme": "https://ipinfo.io/missingauth"
123+
}
124+
*/
125+
if (
126+
array_key_exists('org', $rawIspInfo)
127+
&& is_string($rawIspInfo['org'])
128+
&& !empty($rawIspInfo['org'])
129+
) {
130+
// Remove AS##### from ISP name, if present
131+
return preg_replace('/AS\\d+\\s/', '', $rawIspInfo['org']);
132+
}
133+
134+
/*
135+
variant with valid token has json:
136+
{
137+
"ip": "xxx.xxx.xxx.xxx",
138+
"hostname": "example.com",
139+
"city": "Vienna",
140+
"region": "Vienna",
141+
"country": "AT",
142+
"loc": "48.2085,16.3721",
143+
"postal": "1010",
144+
"timezone": "Europe/Vienna",
145+
"asn": {
146+
"asn": "ASxxxx",
147+
"name": "T-Mobile Austria GmbH",
148+
"domain": "t-mobile.at",
149+
"route": "xxx.xxx.xxx.xxx/xx",
150+
"type": "isp"
151+
},
152+
"company": {
153+
"name": "XX",
154+
"domain": "example.com",
155+
"type": "isp"
156+
},
157+
"privacy": {
158+
"vpn": true,
159+
"proxy": false,
160+
"tor": false,
161+
"relay": false,
162+
"hosting": false,
163+
"service": ""
164+
},
165+
"abuse": {
166+
"address": "...",
167+
"country": "AT",
168+
"email": "[email protected]",
169+
"name": "XXX",
170+
"network": "xxx.xxx.xxx.xxx-xxx.xxx.xxx.xxx",
171+
"phone": ""
172+
},
173+
"domains": {
174+
"total": 0,
175+
"domains": [
176+
177+
]
178+
}
179+
}
180+
*/
181+
if (
182+
array_key_exists('asn', $rawIspInfo)
183+
&& is_array($rawIspInfo['asn'])
184+
&& !empty($rawIspInfo['asn'])
185+
&& array_key_exists('name', $rawIspInfo['asn'])
186+
&& is_string($rawIspInfo['asn']['name'])
187+
) {
188+
// Remove AS##### from ISP name, if present
189+
return $rawIspInfo['asn']['name'];
190+
}
116191
}
117192

118-
// Remove AS##### from ISP name, if present
119-
return preg_replace('/AS\\d+\\s/', '', $rawIspInfo['org']);
193+
return 'Unknown ISP';
120194
}
121195

122196
/**
@@ -135,7 +209,7 @@ function getServerLocation()
135209
return $serverLoc;
136210
}
137211

138-
$json = file_get_contents('https://ipinfo.io/json'.getIpInfoTokenString());
212+
$json = file_get_contents('https://ipinfo.io/json' . getIpInfoTokenString());
139213
if (!is_string($json)) {
140214
return null;
141215
}
@@ -151,7 +225,7 @@ function getServerLocation()
151225
}
152226

153227
$serverLoc = $details['loc'];
154-
$cacheData = "<?php\n\n\$serverLoc = '".addslashes($serverLoc)."';\n";
228+
$cacheData = "<?php\n\n\$serverLoc = '" . addslashes($serverLoc) . "';\n";
155229
file_put_contents(SERVER_LOCATION_CACHE_FILE, $cacheData);
156230

157231
return $serverLoc;
@@ -240,7 +314,7 @@ function calculateDistance($clientLocation, $serverLocation, $unit)
240314
$dist = '<15';
241315
}
242316

243-
return $dist.' mi';
317+
return $dist . ' mi';
244318
}
245319

246320
if ('km' === $unit) {
@@ -249,7 +323,7 @@ function calculateDistance($clientLocation, $serverLocation, $unit)
249323
$dist = '<20';
250324
}
251325

252-
return $dist.' km';
326+
return $dist . ' km';
253327
}
254328

255329
return null;
@@ -288,17 +362,17 @@ function sendResponse(
288362
) {
289363
$processedString = $ip;
290364
if (is_string($ipInfo)) {
291-
$processedString .= ' - '.$ipInfo;
365+
$processedString .= ' - ' . $ipInfo;
292366
}
293367

294368
if (
295369
is_array($rawIspInfo)
296370
&& array_key_exists('country', $rawIspInfo)
297371
) {
298-
$processedString .= ', '.$rawIspInfo['country'];
372+
$processedString .= ', ' . $rawIspInfo['country'];
299373
}
300374
if (is_string($distance)) {
301-
$processedString .= ' ('.$distance.')';
375+
$processedString .= ' (' . $distance . ')';
302376
}
303377

304378
sendHeaders();

0 commit comments

Comments
 (0)