Compare commits

...

307 commits
5.1 ... master

Author SHA1 Message Date
sstidl
a19536661e
Fix Speedtest worker lifecycle cleanup (#852)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
* Fix Speedtest worker lifecycle cleanup

* Preserve telemetry during aborted worker cleanup

---------

Co-authored-by: Stefan Stidl <sti-github@stidl.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-11-12 23:41:29 +01:00
W Scott Jasso
06524abd22
Make the docker entrypoint use relative backend URL (#871)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
2026-10-23 19:28:21 +02:00
Copilot
4cf44ad6ac
Point classic UI at mounted /servers.json in Docker entrypoint (#870)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
* Initial plan

* Apply remaining changes

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Apply remaining changes

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Reuse SERVER_LIST_URL sed block for mounted servers.json

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Strengthen classic mounted server list E2E assertions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: Stefan Stidl <sti-github@stidl.com>
2026-10-22 07:36:01 +02:00
Copilot
a820d7cdf1
chore(release): prepare v6.3.1 (#869)
Some checks are pending
Docker / e2e (push) Waiting to run
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-10-21 23:53:05 +02:00
Eduardo Garcia
9ae2f9e22a
Publish the image on demand after PHP security releases; turn off session upload progress (CVE-2026-109618/109619) (#867)
* ci,docker: allow a manual image rebuild, and turn off session upload progress

PHP 8.5.12, 8.4.27, 8.3.36 and 8.2.35 fix CVE-2026-109618 and CVE-2026-109619, which allow
unauthenticated remote code execution with Apache mod_php. The images are rebuilt on Sundays only,
so a maintainer needs a way to publish a rebuild right after a base image security release:
add workflow_dispatch to the Docker workflow.

The second advisory also names the session upload progress feature as a way to reach the
vulnerable path. LibreSpeed does not use it, so it is turned off in the image.

* ci: always pull the base image when building

A rebuild after a security release of the php or alpine image should not reuse a cached
older base (the job uses cache-from type=gha).
2026-10-21 23:04:38 +02:00
dependabot[bot]
f7ebbbf2b0
chore(deps-dev): bump brace-expansion from 1.1.16 to 1.1.21 (#865)
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.16 to 1.1.21.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.16...v1.1.21)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 1.1.21
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-21 22:56:03 +02:00
Copilot
aa84692df3
Make USE_NEW_DESIGN deterministic by cache-busting config.json in design switcher (#858)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
* Initial plan

* Fix design switch config caching for USE_NEW_DESIGN

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-09-27 09:50:52 +02:00
Copilot
be1e0a0daa
Fix mixed-content server selection (#855)
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-09-12 18:44:43 +02:00
Copilot
449e9962ed
Keep the modern mobile gauge row in view when a test starts (#854)
Some checks are pending
Docker / e2e (push) Waiting to run
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
* Initial plan

* fix: keep mobile gauge visible on start

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* refactor: clarify mobile gauge scroll helper

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* fix: defer mobile gauge scroll until running render

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-09-12 15:35:39 +02:00
dependabot[bot]
678d8f6bf3
chore(deps-dev): bump js-yaml from 4.3.1 to 4.3.2 (#853)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.3.1 to 4.3.2.
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.2/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.3.1...4.3.2)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-12 12:54:48 +02:00
Stefan Stidl
0490f3e935 chore(release): bump version to 6.3.0 2026-09-12 12:46:36 +02:00
Copilot
fa2e28626a
Prevent stability ping values from freezing on long tests (#851)
* Initial plan

* Clear stability ping resource timings

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add CORS headers to route fulfillment in stability test

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: sstidl <sstidl@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-09-12 12:40:56 +02:00
marcel1702
0603db7b37
Don't force the IE11 upload workaround on Safari (#847)
* Stop forcing the IE11 upload workaround on Safari via user agent sniffing

The upload test reported low and unstable numbers on Safari (macOS and
iOS) while the download test was correct.

Cause: the "start" handler in speedtest_worker.js matched every Safari
user agent and set settings.forceIE11Workaround = true. In ulTest() that
flag selects a fundamentally different, less accurate measurement path:
instead of sending one xhr_ul_blob_megabytes blob (20 MB by default) and
accumulating event.loaded from upload.onprogress, it sends a stream of
256 KB requests and adds a fixed 256 KB to totLoaded on each onload.
Progress is therefore quantised to whole requests and each request pays
a full round trip before the next one starts, so on fast or high-latency
links the measured speed is both too low and noisy.

The workaround is not needed. Its comment claims it is only required for
MPOT, but the block never checked settings.mpot. The same block also
excludes crios and fxios, which on iOS run the very same WebKit
networking stack as Safari, so the user agent test cannot have been
guarding an engine-level bug in the first place. Current WebKit
implements xhr.upload.onprogress, and the existing feature detection in
ulTest() (the try/catch that probes xhr.upload.onprogress) already
selects the workaround for browsers that genuinely lack it, without
sniffing.

Changes:
- Remove the Safari user agent block. Safari now takes the regular
  upload path, the same one Chrome and Firefox on iOS already took.
- Guard the Edge and PlayStation 4 blocks with
  typeof s.forceIE11Workaround === "undefined", matching how the other
  quirks avoid clobbering explicitly passed settings. Previously an
  explicit forceIE11Workaround: false in the start command was silently
  overwritten, so the workaround was not switchable from outside the
  worker. Default behaviour for those browsers is unchanged.
- Add tests/e2e/worker-browser-quirks.spec.js, which loads the worker
  under spoofed user agents and asserts the resolved settings.
- Update doc.md so Safari is no longer listed as affected.

The Edge and PlayStation 4 blocks are deliberately left outside the
enable_quirks condition: those browsers have no working
upload.onprogress, so running them with enable_quirks: false would
report 0 or Fail rather than a less precise number.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1bUKsok59shM69PwLMMRM

* docs: describe both detection paths for the IE11 upload workaround

The previous wording claimed affected browsers are detected by checking
whether xhr.upload is usable "not by sniffing the user agent", but Edge
and the PlayStation 4 browser are still matched by user agent regex.
Both mechanisms exist and for different reasons: feature detection only
sees a missing xhr.upload object, while those two expose the object and
simply never fire its events.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1bUKsok59shM69PwLMMRM

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-12 12:00:48 +02:00
Copilot
bd8501ad13
Allow frontend Docker mode to use SERVER_LIST_URL without a mounted /servers.json (#849)
Some checks are pending
Docker / e2e (push) Waiting to run
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
* Initial plan

* Fix SERVER_LIST_URL frontend startup

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* test(e2e): serve remote server-list fixture with CORS

* test(e2e): reject malformed static-server paths

* fix: support SERVER_LIST_URL in classic frontend

* test: preserve existing mode test formatting

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: Stefan Stidl <sti-github@stidl.com>
2026-09-12 00:30:17 +02:00
sstidl
b8d47b24cd
fix: constrain shared result image on mobile (#850)
Some checks are pending
Docker / e2e (push) Waiting to run
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
* fix: constrain shared result image on mobile

* test: cover share dialog image height

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* test: cover share dialog image dimensions

---------

Co-authored-by: Stefan Stidl <sti-github@stidl.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-09-11 20:29:20 +02:00
sstidl
22b89a76c5
Merge pull request #833 from BKPepe/feat/modern-result-image
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
feat: add a modern design for the result image
2026-09-02 07:45:01 +02:00
Josef Schlehofer
3d1118bc50
feat: add a modern design for the result image
The shared result image had one look, and it no longer matched the modern
frontend.

The renderer can now draw either design. The image follows the same
useNewDesign setting as the frontend, so a deployment has one switch rather
than two that can disagree, and classic remains the fallback.

- An explicit style query parameter overrides it, which is how the modern
  frontend asks for the design it matches.

- The modern design reuses the frontend palette and shows the client, address
  family and timestamp already present in the result data.
2026-08-15 12:29:33 +02:00
sstidl
04cdce6acf
Merge pull request #839 from darkgsl/fix-typo
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
docs: fix container port binding in docker run example (doc_docker.md)
2026-08-15 10:36:57 +02:00
darkgsl
892674a084
docs: fix container port binding in docker run example
Fixed the container port in the `Example Frontend mode` section. 

The inner container port should be `8080` instead of `80` to correctly map the frontend service.
2026-08-13 14:25:38 +03:00
Stefan Stidl
ca1e033d8d chore(release): bump version to 6.2.1 2026-08-13 01:37:46 +02:00
sstidl
154b5702ee
Merge pull request #838 from librespeed/dependabot/npm_and_yarn/js-yaml-4.3.1
chore(deps-dev): bump js-yaml from 4.3.0 to 4.3.1
2026-08-12 07:59:39 +02:00
dependabot[bot]
810c77891b
chore(deps-dev): bump js-yaml from 4.3.0 to 4.3.1
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.3.0 to 4.3.1.
- [Changelog](https://github.com/nodeca/js-yaml/blob/4.3.1/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.3.0...4.3.1)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-12 01:51:20 +00:00
sstidl
32defb4fb4
Merge pull request #832 from BKPepe/fix/results-image-timestamp
fix: format the timestamp drawn on the result image
2026-08-11 19:45:06 +02:00
sstidl
f3df5db6ab
Merge pull request #834 from BKPepe/fix/modern-frontend-asset-paths
fix: preserve the modern frontend layout in deployments (#834)

Serve the modern UI assets from frontend/ in both repository and Docker
deployments, matching the paths used by index-modern.html.

Move settings.json and server-list.json to the web root, where the modern
page resolves its configuration, and keep Docker, installation guidance, and
design-switch documentation consistent with that layout.

Add E2E coverage for:
- serving the repository unchanged with Python's static HTTP server;
- required modern UI assets and a real 404 for missing paths;
- Alpine standalone settings and modern frontend rendering.

Fixes #804
2026-08-11 08:53:10 +02:00
sstidl
bdc1521e14 test(e2e): verify static modern frontend assets 2026-08-11 08:43:31 +02:00
sstidl
35f63c988a docs: align Docker design layout guidance 2026-08-11 08:27:01 +02:00
sstidl
54179567ac test(e2e): cover Alpine modern frontend settings 2026-08-11 07:50:16 +02:00
Josef Schlehofer
8b5b4eb1b8
fix: point the modern frontend at the assets where they actually live
index-modern.html refers to styling/, javascript/ and images/ as if they sat
next to it, but they live under frontend/. Only docker/entrypoint.sh reconciles
that, by flattening those directories into the web root, so serving the
repository as it stands renders the page without stylesheet, script or logo.

Point the HTML at frontend/, have the entrypoint copy that directory as-is, and
move settings.json and server-list.json to the root that the page fetches them
from, so the repository layout and the deployed layout are the same. Update the
install instructions, which described the flattening.
2026-08-10 03:16:26 +02:00
Josef Schlehofer
c136cd4cfe
fix: format the timestamp drawn on the result image
formatSpeedtestDataForImage() assigned the timestamp to itself, so the value
reached the image exactly as the database returned it. Every other field on
that list is passed through format(); this one reads like a placeholder that
was never filled in, and static analysis flags it as a self-assignment.

How much precision the column carries is decided by the backend, and the three
schemas shipped here disagree: MySQL's `timestamp` keeps none, PostgreSQL's
`timestamp without time zone DEFAULT now()` keeps microseconds and MSSQL's
`datetime` keeps milliseconds. A PostgreSQL deployment therefore drew
"2026-08-10 02:04:13.957789" where a MySQL one drew "2026-08-10 02:04:13".
2026-08-10 02:44:04 +02:00
sstidl
3ada090eef
Merge pull request #828 from librespeed/dependabot/github_actions/actions/stale-11
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
chore(deps): bump actions/stale from 10 to 11
2026-08-03 07:27:52 +02:00
dependabot[bot]
4142a915a6
chore(deps): bump actions/stale from 10 to 11
Bumps [actions/stale](https://github.com/actions/stale) from 10 to 11.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v10...v11)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: '11'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-08-03 05:08:08 +00:00
sstidl
1af6517eb9
Merge pull request #820 from EmanuelPeixoto/fix-upload-http-status
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
Fix upload-speed inflation on HTTP errors and document request body limits
2026-07-30 07:06:37 +02:00
EmanuelPeixoto
397308de03 fix upload race: use captured x in onload, remove upload.onload restart
- xhr.onload now owns the complete lifecycle: checks x.status on
  the captured local variable, restarts only on 2xx.
- xhr.upload.onload no longer calls testStream() to avoid race
  with xhr.onload overwriting xhr[i] before status is read.
- xhr.upload.onerror also uses the captured x for consistency.
2026-07-28 16:10:41 -03:00
sstidl
18e254ff49
Merge pull request #826 from librespeed/dependabot/npm_and_yarn/minimatch-3.1.5
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5
2026-07-28 07:31:18 +02:00
sstidl
aefa645520
Merge pull request #827 from librespeed/dependabot/npm_and_yarn/flatted-3.4.3
chore(deps-dev): bump flatted from 3.3.3 to 3.4.3
2026-07-28 07:30:57 +02:00
sstidl
5e7bdbfa31
Merge pull request #825 from librespeed/dependabot/npm_and_yarn/js-yaml-4.3.0
chore(deps-dev): bump js-yaml from 4.1.1 to 4.3.0
2026-07-28 07:30:27 +02:00
sstidl
9d07f726bb
Merge pull request #824 from librespeed/dependabot/npm_and_yarn/brace-expansion-1.1.16
chore(deps-dev): bump brace-expansion from 1.1.12 to 1.1.16
2026-07-28 07:29:39 +02:00
dependabot[bot]
36584defcc
chore(deps-dev): bump flatted from 3.3.3 to 3.4.3
Bumps [flatted](https://github.com/WebReflection/flatted) from 3.3.3 to 3.4.3.
- [Commits](https://github.com/WebReflection/flatted/compare/v3.3.3...v3.4.3)

---
updated-dependencies:
- dependency-name: flatted
  dependency-version: 3.4.3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 05:26:43 +00:00
dependabot[bot]
fd0529e793
chore(deps-dev): bump minimatch from 3.1.2 to 3.1.5
Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.1.2 to 3.1.5.
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/minimatch/compare/v3.1.2...v3.1.5)

---
updated-dependencies:
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 05:26:42 +00:00
dependabot[bot]
3f59cf07cf
chore(deps-dev): bump js-yaml from 4.1.1 to 4.3.0
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.3.0.
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.1.1...4.3.0)

---
updated-dependencies:
- dependency-name: js-yaml
  dependency-version: 4.3.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 05:26:40 +00:00
dependabot[bot]
081c8bfeb5
chore(deps-dev): bump brace-expansion from 1.1.12 to 1.1.16
Bumps [brace-expansion](https://github.com/juliangruber/brace-expansion) from 1.1.12 to 1.1.16.
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](https://github.com/juliangruber/brace-expansion/compare/v1.1.12...v1.1.16)

---
updated-dependencies:
- dependency-name: brace-expansion
  dependency-version: 1.1.16
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 05:26:40 +00:00
sstidl
f4acb0d82d
Merge pull request #779 from librespeed/chore/playwright-mode-test-plan
Chore/playwright mode test plan
2026-07-28 07:25:39 +02:00
Stefan Stidl
dbb4067f5e ci: run Docker workflow for master pull requests 2026-07-27 22:18:31 +02:00
EmanuelPeixoto
2afc380e19 fix upload: check HTTP status in xhr.onload, expand IIS docs
- speedtest_worker.js: moved HTTP status check from xhr.upload.onload
  (body sent, response may not be available) to xhr.onload
  (full HTTP transaction complete, xhr.status is reliable).
- doc.md: added full IIS web.config example with maxAllowedContentLength.
2026-07-23 17:50:51 -03:00
Stefan Stidl
16e8440dff chore(release): prepare v6.2.0
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
2026-07-22 20:23:45 +02:00
sstidl
be1c7f87a7
Merge pull request #798 from akirayamamoto/fix/php-post-max-size-upload-chunks
fix(docker): raise PHP post_max_size for default 20MB upload chunks
2026-07-22 20:17:51 +02:00
EmanuelPeixoto
1b3c0ac9c4 fix upload: check HTTP status in onload, document server body size limit
- speedtest_worker.js: xhr.upload.onload now checks xhr.status
  before restarting the upload stream. Non-2xx responses (e.g.
  HTTP 413 from undersized client_max_body_size) are treated as
  failures instead of inflating upload speed measurements.

- doc.md: added explicit nginx/Apache/IIS configuration examples
  for client_max_body_size / LimitRequestBody to prevent HTTP 413
  errors on the 20MB upload test blobs.
2026-07-22 14:51:45 -03:00
sstidl
7e10d1eb96
Merge pull request #818 from sstidl/feat/add-pwa-manifest
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
feat: add installable PWA metadata
2026-07-20 22:56:57 +02:00
Stefan Stidl
e7d4fecccf fix: include PWA assets in npm package 2026-07-20 22:50:30 +02:00
Stefan Stidl
3b25d9e33a feat: add installable PWA metadata 2026-07-20 22:35:16 +02:00
sstidl
48aaa4da57
Merge pull request #809 from shaked-shlomo/fix/doc-typos
Some checks are pending
Docker / e2e (push) Waiting to run
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Blocked by required conditions
Fix typos in documentation and a code comment
2026-07-20 11:44:45 +02:00
sstidl
481b50f79b
Merge pull request #812 from librespeed/dependabot/github_actions/actions/checkout-7
chore(deps): bump actions/checkout from 6 to 7
2026-07-20 11:43:23 +02:00
sstidl
602aae8ce0
Merge pull request #817 from librespeed/dependabot/github_actions/actions/setup-node-7
chore(deps): bump actions/setup-node from 6 to 7
2026-07-20 11:42:45 +02:00
dependabot[bot]
0ae3211e44
chore(deps): bump actions/setup-node from 6 to 7
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 6 to 7.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 05:08:46 +00:00
dependabot[bot]
b0100ec3c1
chore(deps): bump actions/checkout from 6 to 7
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-22 05:07:36 +00:00
sstidl
a293ac4cb9
Merge pull request #811 from librespeed/dependabot/docker/alpine-3.24
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
chore(deps): bump alpine from 3.23 to 3.24
2026-06-15 13:21:39 +02:00
dependabot[bot]
b765d5993a
chore(deps): bump alpine from 3.23 to 3.24
Bumps alpine from 3.23 to 3.24.

---
updated-dependencies:
- dependency-name: alpine
  dependency-version: '3.24'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-15 05:08:26 +00:00
Akira Yamamoto
265c42d4bf docs: trim Docker PHP ini comments
Drop the Debian COPY comment (it only restated the code) and the
version-fragility framing in the Alpine comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 22:27:23 +10:00
Akira Yamamoto
914a29de7a docker: simplify Alpine PHP ini install 2026-06-09 18:25:14 +10:00
Akira Yamamoto
a30872a4e8 docs: shorten PHP upload limit comment 2026-06-09 18:19:10 +10:00
Akira Yamamoto
0feb8b5042 docs: update Alpine PHP ini comment 2026-06-09 18:11:52 +10:00
Akira Yamamoto
db4a5f8d5a docker: drop runtime PHP scan-dir discovery for env var + apk path glob
The previous build-time discovery via PHP_CONFIG_FILE_SCAN_DIR worked
but invoked a PHP binary just to learn a path that's already a stable
contract of each base image:

* php:8-apache exports PHP_INI_DIR=/usr/local/etc/php as part of the
  docker-library image template, stable across PHP majors. Reference
  it directly in the COPY destination — no RUN, no validation needed.

* Alpine's apk php-apache2 always installs mod_php's conf.d at
  /etc/phpXX/conf.d (currently /etc/php84). The FROM php:8-alpine
  image also ships its own PHP at /usr/local/etc/php/conf.d, but
  mod_php doesn't read from there. Glob /etc/php*/conf.d to track
  the apk-installed PHP major automatically; explicit error if the
  glob matches nothing.

Net effect: Debian goes from a 5-line RUN block to a 1-line COPY.
Alpine keeps a small RUN block but no longer invokes a PHP binary,
so it doesn't matter which of the two PHP installs `php` resolves
to via $PATH.

Verified: both variants build, install the override at the right
conf.d, mod_php reports post_max_size=32M, and a 20 MB POST to
/backend/empty.php returns HTTP 200 / 0 bytes with no warnings.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 18:06:14 +10:00
Akira Yamamoto
3b3cddeb41 fix(docker): raise PHP post_max_size for default 20MB upload chunks
speedtest_worker.js uploads in 20 MB chunks by default
(xhr_ul_blob_megabytes: 20) but the official Docker images inherit
PHP's stock post_max_size = 8M / upload_max_filesize = 2M, so every
upload chunk:

* triggers a "POST Content-Length ... exceeds the limit" warning
  (leaked into the response body of /backend/empty.php on the Debian
  variant where display_errors is on; suppressed but still emitted on
  Alpine where it's off);
* causes empty.php's subsequent header() calls to fail with "Cannot
  modify header information - headers already sent", leaving the
  response without proper status, cache, or CORS directives.

Ship a small docker/librespeed-php.ini with post_max_size = 32M,
upload_max_filesize = 32M, memory_limit = 256M and COPY it into the
right conf.d for each base image (/usr/local/etc/php/conf.d on
Debian, /etc/php84/conf.d on Alpine). 99- prefix follows the
NN-name.ini packaging convention so this loads after distro defaults
but never silently shadows operator overrides.

Verified post-fix on both variants: a 20 MB POST to /backend/empty.php
returns HTTP 200 / 0 bytes with no warning leakage.
2026-06-09 18:06:14 +10:00
Shaked Shlomo
b4eeb5c260 Fix typos in documentation and a code comment
- doc.md: 'Ifyou' -> 'If you'; remove duplicate word in 'my the network adapter'
- speedtest.js: 'nonexistant' -> 'nonexistent' (comment)
- doc_docker.md: 'shoud' -> 'should'

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-01 17:16:34 +03:00
sstidl
23b7780056
Merge pull request #805 from librespeed/internet-stability
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
add internet stability test
2026-05-27 22:54:47 +02:00
Stefan Stidl
320b908864 Add stability feature Playwright coverage, fix Server selection start race
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
2026-05-16 20:02:21 +02:00
Stefan Stidl
48263c47e8 remove duplicated lines from rebase 2026-05-16 19:10:39 +02:00
Stefan Stidl
8ba87a92bc Merge branch 'internet-stability' of https://github.com/librespeed/speedtest into internet-stability 2026-05-16 19:06:45 +02:00
Stefan Stidl
89e14e9a38 Update README for stability test 2026-05-16 18:48:13 +02:00
Stefan Stidl
7a995280a2 Fix stability test server list and timeouts 2026-05-16 18:48:13 +02:00
Stefan Stidl
fd883ba67f fix: clarify stability failed requests metric 2026-05-16 18:47:09 +02:00
Tom Hudson
5278912ed4 Fix code review issues: server loading, subdir nav, chart perf
- Load server list dynamically from servers.json for Docker frontend/dual modes
- Copy servers.json to web root in entrypoint.sh for frontend/dual modes
- Change back link from href="/" to href="./" for subdirectory installs
- Use binary search for visible chart data range (O(log n) vs O(n))
- Add 200ms minimum interval between pings to limit sample rate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-16 18:47:09 +02:00
Tom Hudson
7839a4331c Add internet stability test feature
Add a prolonged ping-based stability test with real-time canvas chart,
stats (avg/min/max/jitter/packet loss), stability rating, external ping
targets, CSV export, and Docker support. Link from main page to stability test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-16 18:47:08 +02:00
valer23
5cd7ce2efa perf: avoid O(n²) indexOf lookup in classic UI server loop
Some checks failed
Docker / e2e (push) Has been cancelled
Docker / build (./Dockerfile, , ghcr.io/${{ github.repository }}) (push) Has been cancelled
Docker / build (./Dockerfile.alpine, -alpine, ghcr.io/${{ github.repository }}) (push) Has been cancelled
Build an array of {idx, server} pairs before sorting so the original
SPEEDTEST_SERVERS index is carried through, eliminating the per-option
indexOf call.
2026-05-16 18:30:54 +02:00
valer23
69fa7a4edb fix: handle parenthetical qualifiers and multi-comma server names
Parse server names more robustly for sorting:
- "City, Country, Provider" → use second part as country
- "City, Country (1) (Hetzner)" → strip parentheticals from country
- "Frankfurt, Germany (FRA01)" → country is "Germany" not "Germany (FRA01)"
2026-05-16 18:30:54 +02:00
valer23
42d700cf08 fix: avoid mutating original server array and add null guard
Address code review findings:
- Sort a shallow copy instead of mutating the caller's array
- Add null guard on server.name to handle malformed entries
- Use original SPEEDTEST_SERVERS index for classic UI option values
2026-05-16 18:30:54 +02:00
valer23
4ec3a755fa feat: sort server list by country name instead of city name
Sort the server dropdown by country first, then by city within the same
country. This makes it easier to find servers in a specific country when
the list is long. Applies to both modern and classic UIs.
2026-05-16 18:30:54 +02:00
sstidl
c11ee9f68a
Merge pull request #800 from akirayamamoto/experiment/alpine-base-no-php
Drop FROM php:8-alpine in favor of FROM alpine:3.23 (~55% smaller image)
2026-05-16 17:57:30 +02:00
sstidl
7b5c33455d
Merge branch 'master' into experiment/alpine-base-no-php 2026-05-16 17:56:02 +02:00
Stefan Stidl
94104e9bb3 Update README for stability test 2026-05-16 17:23:34 +02:00
Stefan Stidl
a9197302b0 Fix stability test server list and timeouts 2026-05-16 15:22:06 +02:00
Stefan Stidl
8db7cdca80 fix: clarify stability failed requests metric 2026-05-16 15:08:34 +02:00
Stefan Stidl
903a7024c4 Merge origin/master into internet-stability 2026-05-16 10:23:37 +02:00
Akira Yamamoto
8c22140ebb Make ca-certificates dependency explicit
ca-certificates-bundle (which provides /etc/ssl/certs/ca-certificates.crt)
is already pulled in transitively by apache2 / php-apache2 on alpine:3.23,
so live HTTPS calls from PHP work today (verified with file_get_contents
against ipinfo.io). But the master image (FROM php:8-alpine) installs
the full ca-certificates package explicitly, and operators with
IPINFO_APIKEY configured rely on outbound HTTPS. Make the dependency
explicit to:

* Match master's package set rather than relying on a transitive pull
  that some future apk dep change could drop.
* Document the runtime TLS requirement at the Dockerfile level instead
  of leaving it implicit.

~50 KB image-size cost; the umbrella ca-certificates package adds the
update-ca-certificates CLI on top of the bundle. Per Qodo's review on
PR #800.
2026-04-27 14:27:46 +10:00
Akira Yamamoto
475cae5b0e EXPERIMENT: drop FROM php:8-alpine in favor of FROM alpine:3.21
The current Dockerfile.alpine pulls FROM php:8-alpine and then `apk
add php-apache2`. The result is two PHP installs side by side: the
docker-library PHP at /usr/local/bin/php (~30 MB, never used by
Apache) and the apk-installed PHP at /usr/bin/php (which mod_php
actually loads).

Pinning a fresh Alpine release and installing the apk packages
directly drops the dead /usr/local/bin/php install entirely.
Expected wins:
- Smaller image (~30 MB less; 2024 baseline was ~120 MB)
- One PHP binary, no $PATH ambiguity
- Cleaner story for any follow-up that touches PHP config
2026-04-27 10:03:14 +10:00
Stefan Stidl
e52fcda7c3 docs: update install instructions (closes #790) 2026-04-26 14:23:09 +02:00
Copilot
853214db6c
chore(release): v6.1.0 (#795)
Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/8a2ce044-63ba-41c9-9629-b759008e8afc

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-04-18 23:33:55 +02:00
sstidl
1ec859d63c
Rename my-agent.agent.md to release-agent.agent.md 2026-04-18 23:17:54 +02:00
sstidl
5c563305fc
Define Release Agent with purpose and responsibilities
Added detailed description and responsibilities for the Release Agent, including its purpose, workflow, output format, and constraints.
2026-04-18 23:16:28 +02:00
Copilot
ecb2a0e736
Add Docker TAGLINE env customization for modern frontend slogan (#794)
* Initial plan

* Add Docker TAGLINE env customization for modern UI slogan

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/e1da6e0e-5194-453d-bffb-961ed782e215

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Refine TAGLINE replacement and expand E2E coverage

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/e1da6e0e-5194-453d-bffb-961ed782e215

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix TAGLINE sed delimiter and add apostrophe tagline E2E test

- Switch TAGLINE sed from '#' to '/' delimiter so html_escape'd
  apostrophes (&#39;) don't break the sed expression
- Add standalone-apostrophe Docker service with TAGLINE="It'd rather be fast!"
- Add standaloneApostrophe URL (port 18186) to env.js
- Add E2E test asserting the apostrophe tagline renders correctly

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/ebe265a8-4b1e-49b5-959a-66133ea0ab3a

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-04-18 23:06:37 +02:00
sstidl
8f0323c4a7 update geoip phar and db 2026-04-18 22:29:36 +02:00
Stefan Stidl
c3d6830814 chore(release): v6.0.2 2026-04-14 14:25:27 +02:00
sstidl
18b46600d0
docker: apply TITLE to modern page heading (#788)
Co-authored-by: Stefan Stidl <sti-github@stidl.com>
2026-04-14 10:12:49 +02:00
sstidl
d18552fe8a
docker: restore TITLE env handling in entrypoint (#787)
* docker: restore TITLE env handling in entrypoint

* docker: escape TITLE for HTML output

* test(e2e): cover TITLE with umlauts and quotes

---------

Co-authored-by: Stefan Stidl <sti-github@stidl.com>
2026-04-14 09:06:03 +02:00
Copilot
03d62a0ca1
fix: add aria-label to startStopBtn for screen reader accessibility (#785)
Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/cfb05653-7d75-4f0d-9e9a-1765eeaa8903

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-04-13 07:56:17 +02:00
Copilot
da29334083
Fix accessibility: replace div#startStopBtn with <button> in classic design (#782)
* Initial plan

* Replace div#startStopBtn with button element for keyboard accessibility

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/f3d60a26-754c-48da-9672-542810806f72

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-04-13 07:40:02 +02:00
dependabot[bot]
dce0bdddb3
chore(deps): bump actions/setup-node from 4 to 6 (#783)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-13 07:32:05 +02:00
dependabot[bot]
cd89d0e313
chore(deps): bump actions/checkout from 4 to 6 (#784)
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-13 07:31:44 +02:00
Copilot
d2b9c724e6
Support legacy EMAIL env var as deprecated fallback for GDPR_EMAIL (#781)
* Initial plan

* Fix: Support legacy EMAIL env var as fallback for GDPR_EMAIL in privacy policy

Agent-Logs-Url: https://github.com/librespeed/speedtest/sessions/337248e4-5c7a-4472-ad3b-381e0cd29c96

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* fix stderr logging

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
2026-04-12 23:14:11 +02:00
Stefan Stidl
ab86aab10f http fetch timeout fix 2026-04-12 15:40:32 +02:00
Stefan Stidl
21d3fb0260 ci: use npm ci and track package-lock for reproducible e2e 2026-04-12 15:21:38 +02:00
Stefan Stidl
aa332c2528 test(e2e): make global setup readiness check node14-compatible 2026-04-12 15:20:12 +02:00
Stefan Stidl
48dcde3d1c test(e2e): fix backend-testpoint fixture port 2026-04-12 15:20:12 +02:00
sstidl
3bd9e1b7af
chore/playwright mode test plan (#778)
* ci: make standalone playwright manual and document e2e gating

* docs(test): refine playwright plan with implemented CI strategy

---------

Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
2026-04-12 15:15:14 +02:00
sstidl
49f54a5c3c
add e2e testing (#777)
* docs(test): add playwright modes test plan

* test(e2e): add playwright phase-1 mode coverage

* test(e2e): add classic standalone no-server regression

* ci(docker): gate image build on playwright e2e

* ci(e2e): run on master push and allow manual dispatch

---------

Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
2026-04-12 14:59:54 +02:00
Stefan Stidl
1a45664d81 version strings sync 2026-04-12 13:53:38 +02:00
sstidl
c4ce1d2731 doc: design-switch 2026-04-12 11:09:02 +00:00
Copilot
6693c7ee2c
Cherry-pick: revert "Use server-list.json in classic frontend by default" (#776)
* Revert "Use server-list.json in classic frontend by default"

This reverts commit fdb1681aad.

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* bump version to v6.0.1

---------

Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: sstidl <sstidl@users.noreply.github.com>
2026-04-12 12:47:38 +02:00
sstidl
3a7dc31ff2
Implement the new design from #649 (#694)
* Implement fromScratch design

* Add some documentation

* enable new design in docker (no alpine yet)

* merge fixed docker images

* alpine docker added new design

* fix #685

* Implement fromScratch design

* Add some documentation

* enable new design in docker (no alpine yet)

* alpine docker added new design

* fix #685

* fix database permissions alpine, remove baby

* hide serverselector on only one server

* Update frontend/styling/server-selector.css

Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>

* fix alpine image again

* adjust settings.json in entrypoint

so env vars are honored

* Update frontend/javascript/index.js

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

* Add feature switch for new design via config file, URL parameters, and Docker (#742)

* Initial plan

* Add feature switch for new design with config and URL parameter support

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve error handling and prevent infinite redirect loops

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Update Dockerfiles and entrypoint to support design feature switch

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Update design-switch.js

Co-authored-by: qodo-free-for-open-source-projects[bot] <189517486+qodo-free-for-open-source-projects[bot]@users.noreply.github.com>

* fix: copy actions in entrypoint

* Restructure design switch to place both designs at root level

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Flatten frontend assets in Docker to eliminate frontend directory

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* fix: entrypoint settings & server-list

disable entrypoint bash debug

* add link to modern design

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: sstidl <sstidl@users.noreply.github.com>
Co-authored-by: qodo-free-for-open-source-projects[bot] <189517486+qodo-free-for-open-source-projects[bot]@users.noreply.github.com>

* add armv7

* reformat

* Add GDPR_EMAIL environment variable for Docker deployments (#743)

* Initial plan

* Add GDPR_EMAIL environment variable for Docker deployments

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve GDPR_EMAIL handling with proper escaping and loop

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Refine GDPR_EMAIL processing - skip index.html and improve escaping

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Optimize GDPR_EMAIL sed commands and improve escaping

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Clarify sed escaping comment for GDPR_EMAIL

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* cleanup old EMAIL ENV Var

* fix: line break in html prevented sed replacement

* version 6.0.0pre1

* test: add mssql docker compose tests

* Update Speedtest screen recording link in README

* Filter unreachable servers from selector (newdesign UI) (#769)

* Filter unreachable servers from selector (newdesign UI)

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* keep // servers in list

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* fix misleading comment

---------

Co-authored-by: Lumi <lumi@openclaw.local>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Stefan Stidl <sti-github@stidl.com>

* fix: server.json handling

* Use server-list.json in classic frontend by default

* Add configurable server list URLs to frontend and Docker

---------

Co-authored-by: Timendus <mail@timendus.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: qodo-free-for-open-source-projects[bot] <189517486+qodo-free-for-open-source-projects[bot]@users.noreply.github.com>
Co-authored-by: Stefan Stidl <sti-github@stidl.com>
Co-authored-by: Lumi <lumi@openclaw.local>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-11 23:07:05 +02:00
Tom Hudson
6f1d8c50f1 Fix code review issues: server loading, subdir nav, chart perf
- Load server list dynamically from servers.json for Docker frontend/dual modes
- Copy servers.json to web root in entrypoint.sh for frontend/dual modes
- Change back link from href="/" to href="./" for subdirectory installs
- Use binary search for visible chart data range (O(log n) vs O(n))
- Add 200ms minimum interval between pings to limit sample rate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 18:27:15 -04:00
Tom Hudson
c5f5c30b28 Add internet stability test feature
Add a prolonged ping-based stability test with real-time canvas chart,
stats (avg/min/max/jitter/packet loss), stability rating, external ping
targets, CSV export, and Docker support. Link from main page to stability test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 18:07:20 -04:00
dependabot[bot]
e1310d88a3
Bump docker/setup-qemu-action from 3 to 4 (#760)
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 3 to 4.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 20:16:35 +01:00
dependabot[bot]
7c0b191a21
Bump docker/build-push-action from 6 to 7 (#762)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6 to 7.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 20:16:09 +01:00
dependabot[bot]
983f0cec83
Bump docker/setup-buildx-action from 3 to 4 (#759)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3 to 4.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 20:15:50 +01:00
dependabot[bot]
7b62e8417f
Bump docker/metadata-action from 5 to 6 (#761)
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5 to 6.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](https://github.com/docker/metadata-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 20:13:55 +01:00
dependabot[bot]
82b7a2629d
Bump docker/login-action from 3 to 4 (#763)
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-11 20:13:06 +01:00
Matthew Kobayashi
f1f48ae53e
fix: return client IPv6 address via cloudflared (#757)
* fix: return client IPv6 address via cloudflared

The cloudflared reverse proxy populates the X-Forwarded-For header for origin IPv4 addresses, however origin IPv6 addresses are added in a different header: Cf-Connecting-Ipv6. This updates the getIP.php mechanism to retrieve the value of this header and to prefer it over other client IP headers (in both cases only if the Cf-Connecting-Ipv6 header exists and is not empty).

* fix: Validate and normalise IP addresses from request headers

getClientIp() used HTTP_CF_CONNECTING_IPV6 and other headers verbatim, allowing malformed values to reach ISP lookups and the offline DB.

Add normalizeCandidateIp() helper that trims whitespace, extracts the first comma-separated token, and validates via filter_var(). Require FILTER_FLAG_IPV6 for the CF header and fall through to the next source on failure.

Written with assistance from OpenCode using Claude Opus 4.6.
2026-03-05 23:52:59 +01:00
MemphiZ
98f447c8db
Add .NET client library to README (#739) 2026-02-23 18:57:48 +01:00
Copilot
734a35f89c
Fix PHP version check for geoip2.phar compatibility (#754)
* Initial plan

* Fix PHP version check to require PHP 8.1.0+ for geoip2.phar

Changed from PHP_MAJOR_VERSION >= 8 to PHP_VERSION_ID >= 80100 to match
the actual requirement of geoip2.phar which needs PHP 8.1.0 or higher.
This prevents HTTP 500 errors on PHP 8.0.x installations.

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-01-31 21:45:28 +01:00
sstidl
85d3dd05dc
Update doc.md with nginx backend example link
Add example link for nginx backend configuration.
2026-01-23 21:18:09 +01:00
Copilot
9830af2c3a
Prepare 5.5.1 hotfix release (#747)
* Initial plan

* version numbers 5.5.1

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2026-01-11 23:16:58 +01:00
sventec
746824b77d
fix: update docker entrypoint sqlite db matching (#746)
* fix: update docker entrypoint sqlite db matching

* fixup! fix: update docker entrypoint sqlite db matching

---------

Co-authored-by: sventec <18218761+sventec@users.noreply.github.com>
2026-01-04 13:17:03 +01:00
sstidl
fdd2fd24a6 version numbers 5.5.0 2025-12-30 01:22:19 +01:00
Johan Pauwels
43116cb5a9
Add ARM v7 architecture to Docker images (#741) 2025-12-29 23:52:20 +01:00
Copilot
750f043872
Fix critical security vulnerability: Move SQLite database outside webroot (#738)
* Initial plan

* Fix critical security vulnerability: Move SQLite database outside webroot

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Update documentation to explain secure SQLite database path

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Clarify SQLite database security requirements for different installation scenarios

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve security documentation with web server configuration guidance

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix incomplete file path in documentation example

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Clarify that database file is created after first test in verification step

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2025-12-17 21:45:13 +01:00
Copilot
1360664796
Fix SQLite database path to resolve "unable to open database file" error (#736)
* Initial plan

* Fix SQLite database path and add write permission checks

- Changed default SQLite database path from '../../speedtest_telemetry.sql' to '__DIR__/speedtest_telemetry.db' to keep it within the results directory
- Added directory existence and writability checks with helpful error messages
- Added SQLite database files to .gitignore to prevent committing user data

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix indentation to use tabs consistently in telemetry_db.php

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Remove temporary backup file

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2025-12-17 21:00:20 +01:00
Copilot
a3ed06699f
Add alt attribute to speed test results image for accessibility (#731)
* Initial plan

* Add ALT attribute to SpeedTest result image for accessibility

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add alt attribute to docker/ui.php for accessibility

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
2025-12-07 23:13:38 +01:00
Stefan Stidl
17e4554e4d add test script for arm docker build 2025-12-06 21:55:45 +01:00
Stefan Stidl
cbe05e49ab fix dockerfile.alpine 2025-12-06 21:41:55 +01:00
Stefan Stidl
b065fc1c8d fix alpine image again 2025-12-06 21:40:48 +01:00
Stefan Stidl
fc2dc5125d Merge commit '1c5bde7881' 2025-12-06 21:03:47 +01:00
sstidl
1c5bde7881
Merge pull request #6 from sstidl:fix/arm-alpine
feat: update Dockerfile to use PHP 8.3-alpine3.19 and add QEMU setup for multi-arch builds
2025-12-06 20:06:06 +01:00
Stefan Stidl
6ab62409cb feat: update Dockerfile to use PHP 8.3-alpine3.19 and add QEMU setup for multi-arch builds 2025-12-06 20:04:58 +01:00
sstidl
e6ca54e20f
Fix/arm alpine (#729)
* use alpine base image

* back to php alpine image

* Update Dockerfile.alpine

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* add iconv in alpine

* seperate build base

---------

Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-06 19:50:12 +01:00
Stefan Stidl
f408183a90 seperate build base 2025-12-06 19:43:13 +01:00
Stefan Stidl
7852e3beac add iconv in alpine 2025-12-06 19:41:28 +01:00
sstidl
4efe5e6100
Update Dockerfile.alpine
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-06 19:30:02 +01:00
Stefan Stidl
81fdf0f5fd back to php alpine image 2025-12-06 19:16:15 +01:00
Stefan Stidl
dcf30adca9 use alpine base image 2025-12-06 19:08:00 +01:00
sstidl
cb265a2d91
add eslinter, update github actions (stale issues, dependabot), optimize docker image (#728)
* Create stale.yml

* Configure Dependabot for GitHub Actions and Docker

Added support for GitHub Actions and Docker updates.

* Bump actions/stale from 5 to 10

Bumps [actions/stale](https://github.com/actions/stale) from 5 to 10.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5...v10)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: '10'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump actions/checkout from 4 to 6

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump docker/build-push-action from 5 to 6

Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* typo

* Add npm package manager with development tooling and improve Docker builds (#5)

* Initial plan

* Add npm package manager with development tooling

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add package manager investigation summary

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix documentation based on code review feedback

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Initial plan

* Add npm package manager with development tooling

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Add package manager investigation summary

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Fix documentation based on code review feedback

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* Restore Dockerfile.alpine to dev version (re-enable php-apache2)

* Remove redundant docker-php-extension-installer from Dockerfile.alpine

* remove useless ai files

* typo

* Initial plan

* Initial plan

* Improve Docker build process and analyze PHP package manager needs

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>

* remove useless ai files

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>

* Update .github/workflows/stale.yml

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

* Update Dockerfile.alpine

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

* Update .github/workflows/stale.yml

Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
2025-12-06 18:47:56 +01:00
sstidl
4458c69940
Merge pull request #726 from mkl262/master
feat: allow to specify obfuscation salt string

Thank you for contributing @mkl262
2025-10-18 11:37:19 +02:00
sstidl
64e4c3b768
Update docker/entrypoint.sh
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
2025-10-18 11:34:14 +02:00
Michael Kanchuker
fd06e94de3 feat: allow to specify obfuscation salt string 2025-10-16 19:58:51 +03:00
sstidl
a1c43977ad
Merge pull request #693 from librespeed/fix-docker-images
Fix docker images and dual mode
2025-02-13 19:59:25 +01:00
sstidl
dd40a3a493
Merge pull request #668 from bogdanr/master
Added a modern design example
it doesnt do any harm to add another example :)
2024-12-29 19:49:53 +01:00
sstidl
e6fac5507e fix phar loading on alpine 2024-12-29 18:14:18 +00:00
sstidl
af9cbc0dd9 repair own url detection, switched to js 2024-12-29 18:08:52 +00:00
sstidl
13eb4494df
Update docker/test/test-script.sh
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2024-12-29 17:50:48 +01:00
sstidl
6d31010feb
Update docker/ui.php
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2024-12-29 17:50:41 +01:00
sstidl
0274f6e587
Update docker/ui.php
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2024-12-29 17:49:51 +01:00
sstidl
fe85a805ac documentation of docker tests 2024-12-29 16:41:50 +00:00
sstidl
de846743dc
Merge branch 'master' into fix-docker-images 2024-12-29 17:23:19 +01:00
sstidl
29e068654b
Merge pull request #679 from librespeed/fix-dual-mode
Fix-dual-mode
2024-12-29 17:15:08 +01:00
sstidl
5cad53ea60
Merge pull request #687 from iJuhan/fix/docker-docs
Update docker documentation
2024-12-03 14:32:38 +01:00
iJuhan
a8af966d88 fix: Update docker docs 2024-12-02 19:56:13 +01:00
sstidl
a177238636 improve test scripts 2024-12-01 22:44:37 +01:00
Stefan Stidl
c00ad26abe fix permissions on db file 2024-12-01 22:08:51 +01:00
Stefan Stidl
3f20f0e8c5 Merge branch 'fix-dual-mode' of https://github.com/librespeed/speedtest into fix-dual-mode 2024-12-01 12:31:08 +01:00
Stefan S
c8696a87fa fix Dual mode is broken #666 2024-12-01 12:30:35 +01:00
sstidl
c0c2a41c23
Merge pull request #678 from librespeed/fix-docker-images
alpine/debian docker image tests and fixes
2024-12-01 12:26:05 +01:00
Stefan S
783fd376a4 fix Dual mode is broken #666 2024-10-26 21:52:51 +02:00
Stefan S
513fe3fe6f Merge branch 'master' of https://github.com/librespeed/speedtest into fix-docker-images 2024-10-26 18:20:48 +02:00
Stefan S
a964e3c975 change from pr#671 2024-10-26 18:12:30 +02:00
sstidl
ed9b19f2d5
Merge pull request #671 from BYT-Bender/master
Added dark style for the <select> HTML property
2024-10-26 18:11:01 +02:00
Stefan S
6406d06a33 fix sqlite in alpine 2024-10-26 17:17:47 +02:00
Stefan S
8a7c145a19 test docker mysql 2024-10-26 17:16:00 +02:00
Stefan S
2c3be7b52d docker test for postgres 2024-10-26 15:52:33 +02:00
Stefan S
0c31f1de6d alpine/debian images tested with postgres 2024-10-26 15:40:13 +02:00
Robert Silén
635ac50f80
add MariaDB to README.md (#673) 2024-10-09 19:11:47 +00:00
Byte Bender
748625a985
Update index.html 2024-10-09 08:55:10 +05:30
Federico Dossena
89c8e2fc5d Updated ipinfo offline db 2024-09-26 06:40:24 +02:00
Bogdan Radulescu
4b837186e4 Added a modern design example 2024-09-25 01:06:24 +03:00
HedgehogInTheCPP
2b53bbae54
Changed var to the let/const because it's completely supported by IE11 and all other browsers since 2015. (#656) 2024-08-16 18:07:26 +00:00
HedgehogInTheCPP
c9fdd2f693
Update getIP.php return the ability to do online check for IP location on older PHP version (#651)
This patch is returns the ability to do online check for IP location on older PHP version
2024-08-16 11:45:28 +00:00
Nuno
33390e9c2f
docs: add alpine info (#654)
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-14 17:38:27 +00:00
sstidl
79436f0f0d
Merge pull request #631 from rare-magma/add-alpine-docker-image
Add alpine docker image version
2024-08-14 08:02:23 +02:00
rare-magma
76bb7de037
ci: bump php in docker
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-13 20:33:21 +02:00
rare-magma
0e4c1e2bc7
ci: add missing flavour for version
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-10 13:10:13 +02:00
rare-magma
2c39a3a8df
ci: add missing flavour for pr and branch
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-10 13:09:44 +02:00
rare-magma
09d07a1ee9
ci: add missing tag for pr and branch
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-10 12:59:50 +02:00
rare-magma
c73ed71043
ci: add missing tag
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-10 12:53:05 +02:00
rare-magma
e488bc44f6
ci: fix tags
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-08-10 12:52:32 +02:00
Federico Dossena
3ae0e9e228 Bumped version to 5.4.1 2024-08-10 11:44:01 +02:00
sstidl
7327d2f2f5
Merge pull request #648 from librespeed/633-invalid-username-password-variables-with-mssql-not-using-windows-authentication
fix: mysqlsetting were used for mssql
2024-08-10 11:08:49 +02:00
sstidl
d693074766 fix: mysqlsetting were used for mssql 2024-08-10 09:07:43 +00:00
sstidl
420be5e72f
Release 5.4 (#645)
* Initial implementation of ipinfo.io offline database

* Removed unnecessary code

* add: download ipinfo db during docker build

* fixed workflow

* rename warning in workflow

* commit to trigger workflow

* Refactor getIP

* Improved UI

* Updated docker version with 5.4 changes

* Updated README.md

* Added fallback in getIP in case the offline db is missing

* Fixed typos

* just md linting

* Removed vscode stuff

* Implemented fallback in getIP for PHP<8 (returns only the IP)

* Updated doc.md

* Fixed comments in telemetry_settings.php

* New quick start video

* Corrected image name in doc_docker.md

* Replaced speedtest with just test in stats.php

* docker documentation update

* typo

---------

Co-authored-by: Federico Dossena <info@fdossena.com>
Co-authored-by: Stefan Stidl <stefan.stidl@ffg.at>
2024-08-04 07:06:27 +00:00
Sudo Dios
b419726fef
Update README.md (#636) 2024-06-27 14:26:37 +00:00
rare-magma
301e3f5234
fix: purge php src
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 16:34:41 +02:00
rare-magma
4f067f4aa0
fix: purge build dependencies
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 16:17:57 +02:00
rare-magma
5d0cd7ef74
ci: remove unused env var
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 14:40:05 +02:00
rare-magma
348494dab4
ci: build alpine docker image
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 14:38:38 +02:00
rare-magma
611c1a1743
feat: handle alpine configuration
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 14:35:47 +02:00
rare-magma
d1aa403f38
ci: add alpine dockerfile
Signed-off-by: rare-magma <rare-magma@posteo.eu>
2024-06-02 14:34:56 +02:00
Federico Dossena
f8f290a2e8 Fixed typo in telemetry_db.php 2024-05-31 05:50:30 +02:00
sstidl
1bdffc752e
Merge pull request #626 from librespeed/update-build-pipeline
add on publish trigger
2024-05-24 16:40:43 +02:00
sstidl
ea30ad4d40 add on publish trigger
may solve #461
2024-05-24 14:27:58 +00:00
sstidl
cf536e5090
Merge pull request #625 from librespeed:update-build-pipeline
update github-actions
2024-05-24 16:19:17 +02:00
sstidl
0d03e44871 update github-actions 2024-05-24 14:17:05 +00:00
sstidl
3034bf2b2d
Merge pull request #617 from zypA13510/revert-487-patch-1
fix: download speed is 0 on certain platform
2024-05-18 22:18:59 +02:00
sstidl
8a9467b5a5
Merge pull request #623 from librespeed/dev
ipv6 regexmatch
2024-05-18 21:51:38 +02:00
Stefan Stidl
b023f31191 Merge branch 'master' into dev 2024-05-18 21:47:38 +02:00
Stefan Stidl
deb8b08aac Merge commit 'c2733a478c' into dev 2024-05-18 21:47:16 +02:00
sstidl
8713facba5
Merge pull request #614 from bt90/patch-4
Start apache with exec
2024-05-15 06:34:46 +02:00
Yuping Zuo
ea25001e42
Revert "Use random_bytes when available (#487)"
This reverts commit fa0ac8cd23.
2024-05-05 22:25:19 +08:00
Federico Dossena
dd1ce2cb88 Fixed vulnerability in json.php caused my missing Content-Type header 2024-04-27 15:12:32 +02:00
bt90
d00c9bbbed
Define stopsignal 2024-04-17 20:34:45 +02:00
bt90
c2733a478c
Start apache with exec 2024-04-17 20:28:03 +02:00
sstidl
bccdf5ff27
schedule build once a week 2024-04-15 11:55:58 +02:00
sstidl
748f49c3b6
build docker images on schedule
to ensure docker image updates, we build the image once a week
2024-04-15 11:49:40 +02:00
sstidl
4640c64412
revert .github/workflows/snyk-security.yml
was an accident. sorry. but we got a freshdocker image without php8 bugs this way ;-)
2024-04-15 11:29:24 +02:00
sstidl
5b17b397c5
Create snyk-security.yml 2024-04-15 08:06:48 +02:00
Stefan Stidl
ac1d806490 Merge branch 'master' into dev 2024-03-14 08:55:14 +01:00
sstidl
a51b59aa1a
Merge pull request #540 from JoKneeMo/master
Add dual mode to enable standalone operation with other test servers
2024-02-07 17:32:25 +01:00
sstidl
3f3faeb6a1
Merge pull request #597 from thgoebel/mention-cli
Mention CLI client in Readme
2024-02-02 16:03:49 +01:00
sstidl
c1974d5a53
fix #598 2024-02-02 15:56:48 +01:00
Thore Goebel
a6ae760279 Mention CLI client in Readme 2024-01-31 22:46:46 +01:00
sstidl
f5ad810138
Merge pull request #593 from RedPine404/master
Added IPv6 ULA regex match
2023-12-06 09:35:23 +01:00
redpine
d949663649 Added IPv6 ULA match 2023-12-05 14:48:43 -06:00
sstidl
022c2a976f
Merge pull request #590 from librespeed/dev
Docker images for ARM64
2023-12-02 12:31:15 +01:00
Stefan Stidl
c32bf52bca correct version string 2023-12-02 12:25:21 +01:00
sstidl
a6c0818b66
Update docker-publish.yml: add arm64 2023-12-02 11:58:20 +01:00
Michael Erdely
6eeda75765
Update speedtest.js (#589)
Bump version
2023-11-29 05:40:24 +01:00
sstidl
e5f54fbd78
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>
2023-11-26 12:46:27 +01:00
sstidl
05261e608c set single-server-full as index 2023-11-18 14:15:42 +00:00
JoKneeMo
11f698b376 Revert "Set content-type before sending image data for a valid response"
This reverts commit 82d64bff96.
2023-11-08 11:05:47 -05:00
sstidl
c4c87bc144 integrate ios favicon
closes #400
2023-11-08 12:21:59 +00:00
sstidl
2662491132 removed trailing whitespaces 2023-11-06 10:43:06 +01:00
sstidl
21fb3c53aa
Merge pull request #583 from sstidl/dev
Fix ipinfo

Close #511
2023-11-05 02:43:57 +01:00
Stefan Stidl
fee5799a11 fix regression on getIpinfo 2023-11-05 02:27:49 +01:00
Stefan Stidl
9b8faee10d fix ipinfo parsing 2023-11-05 02:08:11 +01:00
sstidl
58e2b413f2
Merge pull request #582 from sstidl/dev
move examples to folder
2023-11-05 01:16:26 +01:00
Stefan Stidl
338b2c27ef move examples to folder 2023-11-05 01:14:02 +01:00
sstidl
74eab590eb
Merge pull request #581 from sstidl/dev
switch units to Mbit/s
2023-11-05 01:08:30 +01:00
Stefan Stidl
63583cb3f4 switch units to Mbit/s 2023-11-05 01:05:50 +01:00
sstidl
32f6e65a2e
Merge pull request #580 from sstidl/switch-docker-repo
Switch docker repo from docker-hub to github packages
2023-11-05 00:43:23 +01:00
Stefan Stidl
b1aa63259c remove signing 2023-11-05 00:35:46 +01:00
Stefan Stidl
e468c3d068 without image signing 2023-11-05 00:20:39 +01:00
Stefan Stidl
7c05ba084e switch docker image location 2023-11-05 00:14:48 +01:00
Stefan Stidl
60ea879bc3 fix action 2023-11-04 23:52:59 +01:00
sstidl
6c92ed8091
Update docker-publish.yml 2023-11-04 23:44:07 +01:00
sstidl
cecf591d0f
Update docker-publish.yml 2023-11-04 23:14:27 +01:00
sstidl
06803a85fa
Merge pull request #512 from AnTheMaker/patch-1
Add descriptive alt-text to GIF in Readme
2023-11-04 15:14:10 +01:00
sstidl
364e6304b0
Merge pull request #1 from sstidl/sstidl-patch-1
Create docker-publish.yml
2023-11-04 02:44:48 +01:00
sstidl
992e24bab6
Create docker-publish.yml 2023-11-04 02:32:32 +01:00
sstidl
bce9ced9ff
Merge pull request #500 from awsles/patch-1
Update README.md
2023-11-04 01:26:54 +01:00
sstidl
197750eef9
Merge pull request #514 from 0kyn/fix-typos
Fix some typos and formatting
2023-11-04 01:24:38 +01:00
sstidl
8fafd70b46
Merge pull request #501 from bt90/patch-2
Link to docker documentation
2023-11-04 01:19:40 +01:00
Stefan STIDL
e0fa5148fe doc: sqlite db persistance explained 2023-11-04 00:35:21 +01:00
Stefan STIDL
013e7d56e2 fix typo 2023-11-04 00:34:33 +01:00
sstidl
34dd410d14
Merge pull request #573 from PeterDaveHelloKitchen/Dockerfile
Clean up apt lists after installation in Dockerfile
2023-11-03 23:41:59 +01:00
sstidl
871ce1a664
Merge pull request #502 from bt90/patch-3
Add basic docker compose example
2023-11-03 23:17:55 +01:00
sstidl
ae07bf2bdc
Merge pull request #570 from zampettim/upgrade-docker-php-82
Updated Docker to use php8.2-apache as the upstream image.
2023-11-03 22:48:39 +01:00
sstidl
bb1506c39a
Update Dockerfile
Co-authored-by: Quentame <polletquentin74@me.com>
2023-11-03 22:48:12 +01:00
Peter Dave Hello
abc85eb8c5 Clean up apt lists after installation in Dockerfile 2023-09-26 00:22:04 +08:00
Federico Dossena
6a4a05d883 Replaced speedtest with speed test 2023-08-28 22:12:08 +02:00
Marc Zampetti
427edfc416 Updated Docker to use php8.2-apache as the upstream image. 2023-08-09 16:36:48 -04:00
Tracy-B
5956e07a7a
Microsoft SQL Server support and Sanity Check page (#569)
* 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 <tr> to sanitycheck.php
2023-07-31 08:10:56 +02:00
JoKneeMo
20f1f46d1f Docker support for a server that behaves as a standalone frontend AND a backend for another server. 2022-12-11 23:08:46 -05:00
JoKneeMo
82d64bff96 Set content-type before sending image data for a valid response 2022-12-11 22:57:06 -05:00
0kyn
71e3b47130 Fix some typos and formatting 2022-10-03 21:16:26 +02:00
An | Anton Röhm
dd8c5f74f6
add descriptive alt-text to GIF 2022-10-01 13:45:28 +02:00
bt90
16e0fb9bf4
Add basic docker compose example 2022-07-14 17:08:12 +02:00
bt90
d1ca8c2630
Link to docker documentation 2022-07-14 16:45:28 +02:00
Les W
79afc769ea
Update README.md
Added simple manual instructions
2022-07-09 16:13:26 +01:00
rizlas
97e0390680
Postgres and mysql dependencies in docker file (#498) 2022-07-08 16:36:02 +00:00
Pavel Djundik
fa0ac8cd23
Use random_bytes when available (#487) 2022-06-24 06:53:21 +00:00
dosse91
2f19331378 Fixed a bug that caused the frontend-only mode to not work properly with telemetry enabled on the docker version 2022-03-08 13:57:30 +01:00
Jeff Bierschbach
afa84968c7
Save correct IP address to database (#457) 2022-01-08 12:16:05 +00:00
dosse91
5bddaac12a Release 5.2.5 2022-01-04 08:55:27 +01:00
dosse91
a85f2c086f Fixed minor vulnerability in stats.php 2022-01-03 16:30:39 +01:00
Jeff Bierschbach
4234f5fad3
Add mysql and postgresql settings to docker entrypoint (#452) 2021-12-21 13:24:30 +00:00
dosse91
eca7f06e21 Fixed character encoding in mysql db template 2021-06-13 19:01:13 +02:00
dosse91
3937b940e8 Results can now be fetched in json format instead of just an image (results/json.php 2021-04-21 16:20:12 +02:00
dosse91
8be8aba5ed Fixed typo in results/index.php 2021-04-13 10:27:36 +02:00
dosse91
084646d00e Moved docker stuff into the master branch instead of a separate one 2021-03-25 10:47:40 +01:00
dosse91
2ea9b4f4a3 Removed demo server from multipleServer examples because people don't understand the concept of demo 2021-03-16 08:58:29 +01:00
dosse91
624de7778b Release 5.2.3 2021-02-24 08:18:01 +01:00
dosse91
a3b20ba316 example-multipleServers-pretty now shows an error when no servers are available 2021-02-14 09:04:36 +01:00
SCG82
53fb62e096
Use unique names for nested callbacks (#397) 2021-02-09 14:00:51 +01:00
Perflyst
011f8843fc
Add timestamp (#383)
* Add timestamp in result image

* Remove format on timestamp
2020-12-17 16:00:44 +00:00
dosse91
3a35cd9cf2 Merge branch 'master' of https://github.com/librespeed/speedtest into master 2020-10-24 09:32:53 +02:00
dosse91
a8af6ba700 Improved settings behavior 2020-10-24 09:32:39 +02:00
Bernd Stellwag
fb7575b67b
Refactor results/ PHP code (#369)
* put code to insert and query data from database into separate file

* simplify obfuscation salt file handling

* use new DB interaction functions in telemetry.php

* use new DB interaction functions in stats.php

and fix indentation levels

* format telemetry settings file

* use new function for interacting with DB in index.php

* move drawing of the image into function and try to comment each section with what it does

* reorder lines for parts of the image to align with the order they appear on the image

* bugfix: display obfuscated and deobfuscated id in stats if id obfuscation is enabled

* improve error handling

* add missing PHPDocs to functions

* imageftbbox returns an array on success and false on failure so to check if the font is usable, check if we got an array

* fix dsn for postgres

* fix limit sql statement for postgresql

* remove obsolete require statement

* use require instead of require_once since the settings file might need to be loaded multiple times

because it just contains plain variables which will just get loaded into the current scope

* move require statements to the top of the file

* make sure files are readable before requiring them

* add constant to refer to the telemetry settings file and check if it is readable before loading it

* return null if no speedtest result was found for the given id and show according message to the user instead of just exiting

* use existing constant instead of string for telemetry settings file name

* uniformly use single quotes instead of double quotes as most code places already used single quotes

* somehow some tabs sneaked in, replace them to uniformly use spaces

* mysql now uses pdo, too, reflect that in the requirements documentation

* pass username and password as constructor parameters instead of via DSN
2020-10-20 07:43:48 +02:00
dosse91
c6a36e68c4 Test settings can now be changed while in state 4 and not just state 0 2020-10-20 07:35:28 +02:00
Bernd Stellwag
72cccd0619
make the clickable area around the link to the privacy message a bit bigger again so that it's easier to click on mobile devices (#366) 2020-10-11 19:21:10 +02:00
Bernd Stellwag
41638deab9
Fix privacy link width (#364)
* add missing line break

* fix privacy link being clickable over the full page width
2020-10-10 18:42:10 +02:00
Bernd Stellwag
4f9e1a9342
use correct name for accessing the X-Real-IP header via $_SERVER variable (#365) 2020-10-10 18:41:06 +02:00
Bernd Stellwag
a69a70f5f4
Refactor backend PHP code (#362)
* refactor getIP.php moving functionality into separate functions

* add some error checks

* remove closing php tags

* uniformly use single quotes for strings

most strings already used single quotes, some used double quotes

* refactor garbage moving functionality into functions
2020-10-10 07:08:17 +02:00
dosse91
d6877577d5 Bumped version to 5.2.2; Updated README.md 2020-09-27 20:35:58 +02:00
dosse91
e36de9a6ce Improved auto test duration formula 2020-09-27 20:18:01 +02:00
Niels Peen
5cef820749
fixes onend() (#358)
* fixes onend()

* Update speedtest.js
2020-09-17 18:13:35 +02:00
dosse91
3ccdd3d017 Bumped version to 5.2.1 2020-09-07 06:32:55 +02:00
dosse91
1d6568a9d3 Fixed a typo 2020-09-07 06:26:25 +02:00
Kristan Webb
9efae7c27c
Add Port option for MySql (#330) 2020-06-11 15:34:29 +02:00
kodaihirano
6fbe21f2f7
use delay in ultest (#319)
#318
2020-05-04 13:38:29 +02:00
dosse91
b7dce2bc04 Updated README.md 2020-03-12 11:59:40 +01:00
dosse91
42537b4e23 Updated doc.md 2020-03-09 08:52:24 +01:00
dosse91
bfe80d9fb9 Server list can now be loaded from a JSON file instead of hardcoding it 2020-03-09 08:16:06 +01:00
dosse91
4a1ea40b32 Updated README.md 2020-03-02 09:14:15 +01:00
dosse91
5d9b44c77b Fixed a bug where a variable wasn't initialized if enable_quirks was disabled 2020-02-17 18:49:09 +01:00
dosse91
6a3bc06757 Fixed error in doc.md 2019-12-13 19:19:14 +01:00
dosse91
cfd0eb0145 Removed Firefox xhr_ulMultistream browser quirk because it was outdated 2019-10-12 08:18:37 +02:00
dosse91
c95cfb10be Fixed a typo 2019-10-07 07:56:44 +02:00
dosse91
0c7ef8e979 Fixed query error in newer versions of sqlite and postgre 2019-10-01 06:46:22 +02:00
dosse91
1b059e6cc6 Improved redact_ip_addresses 2019-09-29 08:41:26 +02:00
dosse91
a50fcfe566 IP addresses can now be redacted automatically from telemetry 2019-09-28 08:22:14 +02:00
dosse91
247b9c0e4c Updated screenshot 2019-09-26 12:28:53 +02:00
124 changed files with 12143 additions and 1455 deletions

41
.eslintrc.json Normal file
View file

@ -0,0 +1,41 @@
{
"env": {
"browser": true,
"es6": true,
"worker": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "script"
},
"globals": {
"XMLHttpRequest": "readonly",
"Worker": "readonly",
"Blob": "readonly",
"URL": "readonly",
"navigator": "readonly",
"document": "readonly",
"window": "readonly",
"console": "readonly",
"setTimeout": "readonly",
"clearTimeout": "readonly",
"setInterval": "readonly",
"clearInterval": "readonly",
"postMessage": "readonly",
"onmessage": "writable",
"addEventListener": "readonly"
},
"rules": {
"no-unused-vars": [
"warn",
{
"args": "none"
}
],
"no-console": "off",
"no-empty": "warn",
"no-undef": "warn",
"no-const-assign": "error"
}
}

2
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file → Executable file
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

0
.github/ISSUE_TEMPLATE/feature_request.md vendored Normal file → Executable file
View file

104
.github/agents/release-agent.agent.md vendored Normal file
View file

@ -0,0 +1,104 @@
---
# Fill in the fields below to create a basic custom agent for your repository.
# The Copilot CLI can be used for local testing: https://gh.io/customagents/cli
# To make this agent available, merge this file into the default repository branch.
# For format details, see: https://gh.io/customagents/config
name: Release Agent
description: prepares releases, updates release tags in code, commits release changes, and creates the release tag
---
# My Agent
You are a release automation agent for this repository.
## Purpose
Prepare and finalize releases by analyzing repository state, updating release tags in the codebase, committing those changes, and creating the corresponding Git tag for the release.
## Responsibilities
- Inspect recent changes relevant to the next release
- Summarize user-facing changes, fixes, and breaking changes
- Draft release notes in clear markdown
- Propose a semantic version bump with justification
- Identify and update version or release tag references in the repository
- Commit the release-tag changes
- Create the release Git tag
- Identify release risks, missing checks, and follow-up items
- Verify that release artifacts and documentation appear consistent
## Workflow
1. Determine the likely release scope from recent commits, merged pull requests, and changed files
2. Group changes into:
- Features
- Fixes
- Documentation
- Maintenance
- Breaking changes
3. Recommend the next version:
- patch for fixes or internal changes
- minor for backward-compatible features
- major for breaking changes
4. Identify files that contain the current version or release tag
5. Update those files to the new release version
6. Create a commit for the release changes
7. Create the Git tag for the release
8. Draft release notes with:
- title
- summary
- highlights
- breaking changes, if any
- migration notes, if any
- acknowledgments, if available
9. Flag anything that should block or delay the release:
- failing or missing tests
- missing changelog entries
- undocumented breaking changes
- version inconsistencies
- incomplete release artifacts
## Output Format
When asked to prepare a release, respond with these sections:
### Proposed Version
`<version>` with a brief justification
### Files Updated
List of changed files and the version changes made
### Release Summary
A short paragraph describing the release
### Release Notes
Markdown-ready notes suitable for a GitHub release
### Commit Message
Proposed or created commit message
### Release Tag
Proposed or created tag name
### Risks / Blockers
Bullet list of anything that needs attention before release
### Recommended Next Actions
Short, concrete next steps
### Result
State whether the release changes were prepared only, committed, or fully tagged
## Constraints
- Prefer evidence from the repository over assumptions
- Be precise and concise
- Do not invent changes that are not supported by repository history
- Clearly label uncertain conclusions
- Only change files directly related to versioning or release tagging unless explicitly instructed otherwise
- Keep version updates consistent across all affected files
- Use semantic versioning unless the repository clearly uses a different scheme
- Do not guess hidden release rules; infer them from the repository
- If required files are missing or version locations are ambiguous, explain the issue clearly
- Ask for explicit confirmation before any action that would publish or mutate release state

15
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
- package-ecosystem: "docker" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

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

@ -0,0 +1,141 @@
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 * * Sun'
# Lets a maintainer rebuild and publish the images right after a security release of the
# php or alpine base image (Actions > Docker > Run workflow), instead of waiting for Sunday.
workflow_dispatch:
push:
branches: ["*"]
# Publish semver tags as releases.
tags: ["v*.*.*"]
pull_request:
branches: [master]
release:
types: [published]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
# Keep e2e in this workflow so Docker image build/push is hard-gated by test success.
# Do not move automatic e2e back to playwright.yml, otherwise master pushes run duplicate e2e jobs.
e2e:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Install Playwright Chromium
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npm run test:e2e
build:
needs: e2e
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./Dockerfile
image: ghcr.io/${{ github.repository }}
flavour: ""
- dockerfile: ./Dockerfile.alpine
image: ghcr.io/${{ github.repository }}
flavour: "-alpine"
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@v7
# Fetch the ipinfo database file using curl if API key is defined
- name: Fetch DB from ipinfo.io
# IPINFO_APIKEY is set in https://github.com/librespeed/speedtest/settings/secrets/actions
run: |
if [ -z "${{ secrets.IPINFO_APIKEY }}" ]; then
echo "Warning: IPINFO_APIKEY is not defined."
else
curl -L https://ipinfo.io/data/free/country_asn.mmdb?token=${{ secrets.IPINFO_APIKEY }} -o backend/country_asn.mmdb
fi
# Set up QEMU for multi-arch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
# 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@v4
# 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@v4
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@v6
with:
images: ${{ matrix.image }}
tags: |
type=ref,event=branch,suffix=${{ matrix.flavour }}
type=ref,event=pr,suffix=${{ matrix.flavour }}
# set latest tag for default branch
type=raw,value=latest${{ matrix.flavour }},enable={{is_default_branch}}
type=semver,pattern={{version}}${{ matrix.flavour }}
type=semver,pattern={{major}}${{ matrix.flavour }}
type=semver,pattern={{major}}.{{minor}}${{ matrix.flavour }}
type=semver,pattern={{major}}.{{minor}}.{{patch}}${{ matrix.flavour }}
# 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@v7
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
# Always fetch the base image again, so a rebuild after a security release of php or alpine
# does not reuse a cached older base
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

30
.github/workflows/playwright.yml vendored Normal file
View file

@ -0,0 +1,30 @@
name: Playwright E2E
# Manual-only by design:
# - Automatic e2e runs that gate Docker image builds live in docker-publish.yml.
# - Keeping this workflow manual avoids running the same e2e suite twice on master pushes.
on:
workflow_dispatch:
jobs:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Install Playwright Chromium
run: npx playwright install --with-deps chromium
- name: Run Playwright tests
run: npm run test:e2e

31
.github/workflows/stale.yml vendored Normal file
View file

@ -0,0 +1,31 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: '32 18 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v11
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
days-before-stale: 60
days-before-close: 7
close-issue-message: 'This issue was automatically closed due to inactivity.'
close-pr-message: 'This pull request was automatically closed due to inactivity.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'

8
.gitignore vendored Normal file → Executable file
View file

@ -1,2 +1,10 @@
results/idObfuscation_salt.php
backend/getIP_serverLocation.php
db-dir/
.vscode/
node_modules/
playwright-report/
test-results/
results/speedtest_telemetry.db
results/speedtest_telemetry.db-shm
results/speedtest_telemetry.db-wal

0
.logo/LibreSpeed.ai Normal file → Executable file
View file

0
.logo/LibreSpeed.svg Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 247 KiB

Before After
Before After

0
.logo/icon_huge.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Before After
Before After

0
.logo/logo2.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Before After
Before After

0
.logo/logo3.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Before After
Before After

14
.prettierignore Normal file
View file

@ -0,0 +1,14 @@
node_modules/
backend/
results/
docker/
.git/
*.php
*.md
*.sql
*.mmdb
*.phar
*.ttf
*.ico
*.png
*.gif

12
.prettierrc.json Normal file
View file

@ -0,0 +1,12 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "ignore"
}

98
DESIGN_SWITCH.md Normal file
View file

@ -0,0 +1,98 @@
# Design Feature Switch
LibreSpeed now supports switching between the classic design and the new modern design.
## Default Behavior
By default, LibreSpeed uses the **classic design** (located in `index-classic.html`).
## Architecture
### File Structure (Non-Docker)
- **`index.html`** - Entry point (lightweight switcher)
- **`index-classic.html`** - Classic design at root
- **`index-modern.html`** - Modern design at root (references assets in subdirectories)
- **`frontend/`** - Directory containing modern design assets (CSS, JS, images, fonts) - kept for non-Docker deployments
### File Structure (Docker)
Docker deployments preserve the same layout as non-Docker deployments:
- **`index.html`** - Entry point (lightweight switcher)
- **`index-classic.html`** - Classic design at root
- **`index-modern.html`** - Modern design at root
- **`frontend/`** - Modern design assets, copied into the web root unchanged
- **`settings.json` and `server-list.json`** - Configuration files at root, next to `index-modern.html`
### Benefits of the Shared Layout
✅ Docker and non-Docker deployments use the same paths
✅ Both designs are at the same level
✅ `results/` and `backend/` use the same relative paths from both designs
✅ The modern design loads assets consistently from `frontend/`
✅ Configuration files stay at the web root, where the modern page expects them
## Browser Compatibility
The feature switch uses modern JavaScript features (URLSearchParams, XMLHttpRequest). It is compatible with all modern browsers. The new design itself requires modern browser features and has no backwards compatibility with older browsers (see `frontend/README.md`).
## Enabling the New Design
There are two ways to enable the new design:
### Method 1: Configuration File (Persistent)
Edit the `config.json` file in the root directory and set `useNewDesign` to `true`:
```json
{
"useNewDesign": true
}
```
This will make the new design the default for all users visiting your site.
### Method 2: URL Parameter (Temporary Override)
You can override the configuration by adding a URL parameter:
- To use the new design: `http://yoursite.com/?design=new`
- To use the classic design: `http://yoursite.com/?design=classic` or ?design=old
URL parameters take precedence over the configuration file, making them useful for testing or allowing users to choose their preferred design.
### Shared Result Images
The `useNewDesign` setting also controls the default style of shared result
images. Result images can be explicitly overridden with `?style=modern` or
`?style=classic`.
## Design Locations
### Non-Docker Deployments
- **Entry Point**: Root `index.html` file (lightweight redirect page)
- **Old Design**: `index-classic.html` at root
- **New Design**: `index-modern.html` at root (references assets in `frontend/` subdirectory)
- **Assets**: Frontend assets (CSS, JS, images, fonts) in `frontend/` subdirectory
### Docker Deployments
- **Entry Point**: Root `index.html` file (lightweight redirect page)
- **Old Design**: `index-classic.html` at root
- **New Design**: `index-modern.html` at root (references assets in `frontend/` subdirectory)
- **Assets**: Frontend assets in `frontend/`, copied into the web root unchanged
- Same layout as a non-Docker deployment, so the two cannot drift apart
Both designs are at the same directory level, ensuring that relative paths to shared resources like `backend/` and `results/` work correctly for both.
## Technical Details
The feature switch is implemented in `design-switch.js`, which is loaded by the root `index.html`. It checks:
1. First, URL parameters (`?design=new` or `?design=old`)
2. Then, the `config.json` configuration file
3. Redirects to either `index-classic.html` or `index-modern.html`
Both design HTML files are at the root level, eliminating path issues.
### Non-Docker
The modern design references assets from the `frontend/` subdirectory (e.g., `frontend/styling/index.css`), while both designs can access shared resources like `backend/` and `results/` using the same relative paths.
### Docker
In Docker deployments, `frontend/` is copied into the web root as it stands during container startup, so the container serves the same layout the repository has and the same paths `index-modern.html` asks for.

122
DEVELOPMENT.md Normal file
View file

@ -0,0 +1,122 @@
# Development Guide
This document describes how to use the package manager (npm) for development tasks.
## Prerequisites
- Node.js 14.0.0 or higher
- npm (comes with Node.js)
## Getting Started
Install development dependencies:
```bash
npm install
```
## Available Scripts
### Linting
Check code for potential issues:
```bash
npm run lint
```
Automatically fix linting issues where possible:
```bash
npm run lint:fix
```
### Code Formatting
Check code formatting (JavaScript files only):
```bash
npm run format:check
```
Format JavaScript files:
```bash
npm run format
```
> **Note**: The existing codebase uses its original formatting style. Prettier and ESLint are provided as optional tools for new code or improvements.
### Validation
Run all checks (formatting and linting):
```bash
npm run validate
```
### Testing
Currently, there are no automated tests configured:
```bash
npm run test
```
### Docker
Build Docker images:
```bash
npm run docker:build # Standard Debian-based image
npm run docker:build-alpine # Alpine-based image
```
## Development Tools
The package manager setup includes:
- **ESLint**: JavaScript linting tool to catch common errors
- **Prettier**: Code formatting tool to maintain consistent style
These tools are configured but non-intrusive to the existing codebase.
## Project Structure
```
.
├── speedtest.js # Main speedtest library
├── speedtest_worker.js # Web Worker for speed testing
├── index.html # Default UI
├── backend/ # PHP backend files
├── examples/ # Example implementations
├── results/ # Results/telemetry handling
├── docker/ # Docker-related files
└── package.json # npm package configuration
```
## Why Use a Package Manager?
The package manager provides several benefits:
1. **Standardized tooling**: Common commands across different environments
2. **Development dependencies**: Easy installation of linting and formatting tools
3. **Project metadata**: Version, description, and licensing information
4. **Future extensibility**: Foundation for adding build tools, tests, or bundlers if needed
5. **npm distribution**: Makes the library easy to use in other Node.js projects
## Contributing
When making changes:
1. Run `npm run lint` to check for potential issues
2. Consider running `npm run format` on new files for consistency
3. Test your changes manually in a browser
4. For PHP backend changes, test with the appropriate server setup
## Notes
- The core library has **no runtime dependencies** - it's pure vanilla JavaScript
- Development dependencies (ESLint, Prettier) are only needed for development
- The library can still be used standalone without npm (just include the JS files)
- npm setup is completely optional and doesn't change how the library is deployed

68
Dockerfile Executable file
View file

@ -0,0 +1,68 @@
FROM php:8-apache
# use docker-php-extension-installer for automatically get the right packages installed
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
# Install extensions and cleanup in a single layer to reduce image size
RUN install-php-extensions iconv gd pdo pdo_mysql pdo_pgsql pgsql \
&& rm -f /usr/src/php.tar.xz /usr/src/php.tar.xz.asc \
&& apt-get autoremove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY docker/librespeed-php.ini ${PHP_INI_DIR}/conf.d/99-librespeed.ini
# Prepare files and folders
RUN mkdir -p /speedtest/
# Copy sources
COPY backend/ /speedtest/backend
COPY frontend/ /speedtest/frontend
COPY results/*.php /speedtest/results/
COPY results/*.ttf /speedtest/results/
COPY *.js /speedtest/
COPY index.html /speedtest/
COPY index-classic.html /speedtest/
COPY index-modern.html /speedtest/
COPY config.json /speedtest/
COPY settings.json /speedtest/
COPY server-list.json /speedtest/
COPY stability.html /speedtest/
COPY favicon.ico /speedtest/
COPY manifest.webmanifest /speedtest/
COPY images/ /speedtest/images/
COPY docker/entrypoint.sh /
# Prepare default environment variables
ENV TITLE=LibreSpeed
ENV TAGLINE="No Flash, No Java, No Websockets, No Bullsh*t"
ENV MODE=standalone
ENV PASSWORD=password
ENV TELEMETRY=false
ENV ENABLE_ID_OBFUSCATION=false
ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=8080
ENV USE_NEW_DESIGN=false
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH
# Add labels for better metadata
LABEL org.opencontainers.image.title="LibreSpeed"
LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
LABEL org.opencontainers.image.vendor="LibreSpeed"
LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${WEBPORT}/ || exit 1
# Final touches
EXPOSE ${WEBPORT}
CMD ["bash", "/entrypoint.sh"]

89
Dockerfile.alpine Normal file
View file

@ -0,0 +1,89 @@
FROM alpine:3.24
RUN apk add --quiet --no-cache \
bash \
apache2 \
ca-certificates \
php \
php-apache2 \
php-ctype \
php-phar \
php-gd \
php-openssl \
php-pdo \
php-pdo_mysql \
php-pdo_pgsql \
php-pdo_sqlite \
php-pgsql \
php-session \
php-sqlite3
RUN ln -sf /dev/stdout /var/log/apache2/access.log && \
ln -sf /dev/stderr /var/log/apache2/error.log
# Install the ini into the scan dir PHP itself reports.
COPY docker/librespeed-php.ini /tmp/librespeed-php.ini
RUN set -eu; \
scan_dir="$(php -r 'echo rtrim(PHP_CONFIG_FILE_SCAN_DIR);')"; \
if [ -z "$scan_dir" ]; then \
echo "ERROR: PHP_CONFIG_FILE_SCAN_DIR is empty" >&2; \
exit 1; \
fi; \
install -m 0644 /tmp/librespeed-php.ini "$scan_dir/99-librespeed.ini"; \
rm /tmp/librespeed-php.ini
# Prepare files and folders
RUN mkdir -p /speedtest/
# Copy sources
COPY backend/ /speedtest/backend
COPY frontend/ /speedtest/frontend
COPY results/*.php /speedtest/results/
COPY results/*.ttf /speedtest/results/
COPY *.js /speedtest/
COPY index.html /speedtest/
COPY index-classic.html /speedtest/
COPY index-modern.html /speedtest/
COPY config.json /speedtest/
COPY settings.json /speedtest/
COPY server-list.json /speedtest/
COPY stability.html /speedtest/
COPY favicon.ico /speedtest/
COPY manifest.webmanifest /speedtest/
COPY images/ /speedtest/images/
COPY docker/entrypoint.sh /
# Prepare default environment variables
ENV TITLE=LibreSpeed
ENV TAGLINE="No Flash, No Java, No Websockets, No Bullsh*t"
ENV MODE=standalone
ENV PASSWORD=password
ENV TELEMETRY=false
ENV ENABLE_ID_OBFUSCATION=false
ENV REDACT_IP_ADDRESSES=false
ENV WEBPORT=8080
ENV USE_NEW_DESIGN=false
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH
# Add labels for better metadata
LABEL org.opencontainers.image.title="LibreSpeed"
LABEL org.opencontainers.image.description="A Free and Open Source speed test that you can host on your server(s)"
LABEL org.opencontainers.image.vendor="LibreSpeed"
LABEL org.opencontainers.image.url="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.source="https://github.com/librespeed/speedtest"
LABEL org.opencontainers.image.documentation="https://github.com/librespeed/speedtest/blob/master/doc_docker.md"
LABEL org.opencontainers.image.licenses="LGPL-3.0-or-later"
# Add health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${WEBPORT}/ || exit 1
WORKDIR /var/www/html
# Final touches
EXPOSE ${WEBPORT}
CMD ["bash", "/entrypoint.sh"]

0
LICENSE Normal file → Executable file
View file

81
README.md Normal file → Executable file
View file

@ -4,16 +4,19 @@
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://speedtest.fdossena.com)
[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
* Download
* Upload
* Ping
@ -22,34 +25,84 @@ Works with mobile versions too.
* Telemetry (optional)
* Results sharing (optional)
* Multiple Points of Test (optional)
* Connection stability test with latency charting, loss tracking, threshold alerts, and CSV export
![Screenshot](https://speedtest.fdossena.com/mpot_v5.gif)
![Screenrecording of a running Speedtest](https://speedtest.fdossena.com/mpot_v7.gif)
## 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)
* PHP 5.4 or newer (other backends also available)
* MariaDB or MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported)
* A fast! internet connection
## Installation videos
* [Quick start installation guide for Ubuntu Server 19.04](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag)
## Installation
Assuming you have PHP and a web server installed, the installation steps are quite simple.
1. Download the source code and extract it
1. Copy the project files to your web server's shared folder (ie. `/var/www/html/speedtest` for Apache), keeping the layout as it is in the repository. The modern UI loads its assets from `frontend/`, so that directory is copied as a whole rather than unpacked.
1. Optionally, copy the results folder too, and set up the database using the config file in it.
1. Be sure your permissions allow read and execute access where needed.
1. Visit YOURSITE/speedtest/index.html and voila!
### Installation Video
This video shows the installation process of a standalone LibreSpeed server: [Quick start installation guide for Debian 12](https://fdossena.com/?p=speedtest/quickstart_deb12.frag)
More videos will be added later.
## Android app
A template to build an Android client for your LibreSpeed installation is available [here](https://github.com/librespeed/speedtest-android).
## CLI client
A command line client is available [here](https://github.com/librespeed/speedtest-cli).
## .NET client
A .NET client library is available in the [`LibreSpeed.NET`](https://github.com/Memphizzz/LibreSpeed.NET) repo ([NuGet](https://www.nuget.org/packages/LibreSpeed.NET)), maintained by [MemphiZ](https://github.com/Memphizzz).
## Development
If you want to contribute or develop with LibreSpeed, see [DEVELOPMENT.md](DEVELOPMENT.md) for information about using npm for development tasks, linting, and formatting.
## Design switch
LibreSpeed supports both the classic and modern UI. The root `index.html` acts as a lightweight switcher and redirects to `index-classic.html` or `index-modern.html` based on `config.json` (`useNewDesign`) or URL overrides (`?design=new` / `?design=old`). For architecture and deployment details (including Docker behavior), see [DESIGN_SWITCH.md](DESIGN_SWITCH.md).
## Stability test
LibreSpeed includes a standalone connection stability test at `stability.html`, linked from both the classic and modern interfaces. It repeatedly measures ping over a selected duration and reports current, average, minimum, maximum, jitter, and failed request percentage values with a live chart.
The stability test can target the local LibreSpeed backend, one of the configured multiple points of test, or built-in external targets such as Google, Cloudflare, and Apple. It also supports optional latency threshold alerts and CSV export of the collected samples. Docker deployments copy `stability.html` and `stability_worker.js` into the web root and reuse the same server list configuration as the main UI.
## Docker
Please see the `docker` branch
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.
The image is built every week to include an updated version of the ipinfo-DB used for ISP detection. Also this ensures, that the latest security patches in PHP are installed. Therefore we recommend to use the `latest` image.
## 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).
## Rust backend
A Rust implementation is available in the [`speedtest-rust`](https://github.com/librespeed/speedtest-rust) repo, maintained by [Sudo Dios](https://github.com/sudodios).
## Node.js backend
A Node.js implementation is available in the `node` branch, maintained by [dunklesToast](https://github.com/dunklesToast).
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-2019 Federico Dossena
Copyright (C) 2016-2024 Federico Dossena
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by

BIN
backend/country_asn.mmdb Normal file

Binary file not shown.

16
backend/empty.php Normal file → Executable file
View file

@ -1,12 +1,14 @@
<?php
header( "HTTP/1.1 200 OK" );
if(isset($_GET["cors"])){
header('HTTP/1.1 200 OK');
if (isset($_GET['cors'])) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: Content-Encoding, Content-Type');
}
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Connection: keep-alive");
?>
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Connection: keep-alive');

72
backend/garbage.php Normal file → Executable file
View file

@ -1,31 +1,63 @@
<?php
// Disable Compression
@ini_set('zlib.output_compression', 'Off');
@ini_set('output_buffering', 'Off');
@ini_set('output_handler', '');
// Headers
header('HTTP/1.1 200 OK');
if(isset($_GET["cors"])){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
/**
* @return int
*/
function getChunkCount()
{
if (
!array_key_exists('ckSize', $_GET)
|| !ctype_digit($_GET['ckSize'])
|| (int) $_GET['ckSize'] <= 0
) {
return 4;
}
if ((int) $_GET['ckSize'] > 1024) {
return 1024;
}
return (int) $_GET['ckSize'];
}
// Download follows...
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=random.dat');
header('Content-Transfer-Encoding: binary');
// Never cache me
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
/**
* @return void
*/
function sendHeaders()
{
header('HTTP/1.1 200 OK');
if (isset($_GET['cors'])) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
}
// Indicate a file download
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=random.dat');
header('Content-Transfer-Encoding: binary');
// Cache settings: never cache this request
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
}
// Determine how much data we should send
$chunks = getChunkCount();
// Generate data
$data=openssl_random_pseudo_bytes(1048576);
$data = openssl_random_pseudo_bytes(1048576);
// Deliver chunks of 1048576 bytes
$chunks=isset($_GET['ckSize']) ? intval($_GET['ckSize']) : 4;
if(empty($chunks)){$chunks = 4;}
if($chunks>1024){$chunks = 1024;}
for($i=0;$i<$chunks;$i++){
sendHeaders();
for ($i = 0; $i < $chunks; $i++) {
echo $data;
flush();
}
?>

BIN
backend/geoip2.phar Normal file

Binary file not shown.

322
backend/getIP.php Normal file → Executable file
View file

@ -1,154 +1,198 @@
<?php
/*
This script detects the client's IP address and fetches ISP info from ipinfo.io/
Output from this script is a JSON string composed of 2 objects: a string called processedString which contains the combined IP, ISP, Contry and distance as it can be presented to the user; and an object called rawIspInfo which contains the raw data from ipinfo.io (will be empty if isp detection is disabled).
Client side, the output of this script can be treated as JSON or as regular text. If the output is regular text, it will be shown to the user as is.
*/
* This script detects the client's IP address and fetches ISP info from ipinfo.io/
* Output from this script is a JSON string composed of 2 objects: a string called processedString which contains the combined IP, ISP, Country and distance as it can be presented to the user; and an object called rawIspInfo which contains the raw data from ipinfo.io (or an empty string if isp detection is disabled or if it failed).
* Client side, the output of this script can be treated as JSON or as regular text. If the output is regular text, it will be shown to the user as is.
*/
error_reporting(0);
$ip = "";
define('API_KEY_FILE', 'getIP_ipInfo_apikey.php');
define('SERVER_LOCATION_CACHE_FILE', 'getIP_serverLocation.php');
define('OFFLINE_IPINFO_DB_FILE', 'country_asn.mmdb');
require_once 'getIP_util.php';
function getLocalOrPrivateIpInfo($ip){
// ::1/128 is the only localhost ipv6 address. there are no others, no need to strpos this
if ('::1' === $ip) {
return 'localhost IPv6 access';
}
// simplified IPv6 link-local address (should match fe80::/10)
if (stripos($ip, 'fe80:') === 0) {
return 'link-local IPv6 access';
}
// fc00::/7 Unique Local IPv6 Unicast Addresses
if (preg_match('/^(fc|fd)([0-9a-f]{0,4}:){1,7}[0-9a-f]{1,4}$/i', $ip) === 1) {
return 'ULA IPv6 access';
}
// anything within the 127/8 range is localhost ipv4, the ip must start with 127.0
if (strpos($ip, '127.') === 0) {
return 'localhost IPv4 access';
}
// 10/8 private IPv4
if (strpos($ip, '10.') === 0) {
return 'private IPv4 access';
}
// 172.16/12 private IPv4
if (preg_match('/^172\.(1[6-9]|2\d|3[01])\./', $ip) === 1) {
return 'private IPv4 access';
}
// 192.168/16 private IPv4
if (strpos($ip, '192.168.') === 0) {
return 'private IPv4 access';
}
// IPv4 link-local
if (strpos($ip, '169.254.') === 0) {
return 'link-local IPv4 access';
}
return null;
}
function getIspInfo_ipinfoApi($ip){
if (!file_exists(API_KEY_FILE) || !is_readable(API_KEY_FILE)){
return null;
}
require API_KEY_FILE;
if(empty($IPINFO_APIKEY)){
return null;
}
$json = file_get_contents('https://ipinfo.io/' . $ip . '/json?token=' . $IPINFO_APIKEY);
if (!is_string($json)) {
return null;
}
$data = json_decode($json, true);
if (!is_array($data)) {
return null;
}
$isp=null;
//ISP name, if present, is either in org or asn.name
if (array_key_exists('org', $data) && is_string($data['org']) && !empty($data['org'])) {
// Remove AS##### from ISP name, if present
$isp = preg_replace('/AS\\d+\\s/', '', $data['org']);
} elseif (array_key_exists('asn', $data) && is_array($data['asn']) && !empty($data['asn']) && array_key_exists('name', $data['asn']) && is_string($data['asn']['name'])) {
$isp = $data['asn']['name'];
} else{
return null;
}
$country=null;
if(array_key_exists('country',$data) && is_string($data['country'])){
$country = $data['country'];
}
//If requested by the client (and we have the required information), calculate the distance
$distance=null;
if(isset($_GET['distance']) && ($_GET['distance']==='mi' || $_GET['distance']==='km') && array_key_exists('loc', $data) && is_string($data['loc'])){
$unit = $_GET['distance'];
$clientLoc = $data['loc'];
$serverLoc = null;
if (file_exists(SERVER_LOCATION_CACHE_FILE) && is_readable(SERVER_LOCATION_CACHE_FILE)) {
require SERVER_LOCATION_CACHE_FILE;
}
if (!is_string($serverLoc) || empty($serverLoc)) {
$json = file_get_contents('https://ipinfo.io/json?token=' . $IPINFO_APIKEY);
if (!is_string($json)) {
return null;
}
$sdata = json_decode($json, true);
if (!is_array($sdata) || !array_key_exists('loc', $sdata) || !is_string($sdata['loc']) || empty($sdata['loc'])) {
return null;
}
$serverLoc = $sdata['loc'];
file_put_contents(SERVER_LOCATION_CACHE_FILE, "<?php\n\n\$serverLoc = '" . addslashes($serverLoc) . "';\n");
}
list($clientLatitude, $clientLongitude) = explode(',', $clientLoc);
list($serverLatitude, $serverLongitude) = explode(',', $serverLoc);
//distance calculation adapted from http://www.codexworld.com
$rad = M_PI / 180;
$dist = acos(sin($clientLatitude * $rad) * sin($serverLatitude * $rad) + cos($clientLatitude * $rad) * cos($serverLatitude * $rad) * cos(($clientLongitude - $serverLongitude) * $rad)) / $rad * 60 * 1.853;
if ($unit === 'mi') {
$dist /= 1.609344;
$dist = round($dist, -1);
if ($dist < 15) {
$dist = '<15';
}
$distance = $dist . ' mi';
}elseif ($unit === 'km') {
$dist = round($dist, -1);
if ($dist < 20) {
$dist = '<20';
}
$distance = $dist . ' km';
}
}
$processedString=$ip.' - '.$isp;
if(is_string($country)){
$processedString.=', '.$country;
}
if(is_string($distance)){
$processedString.=' ('.$distance.')';
}
return json_encode([
'processedString' => $processedString,
'rawIspInfo' => $data ?: '',
]);
}
if (PHP_VERSION_ID >= 80100){
require_once("geoip2.phar");
}
function getIspInfo_ipinfoOfflineDb($ip){
if (PHP_VERSION_ID < 80100 || !file_exists(OFFLINE_IPINFO_DB_FILE) || !is_readable(OFFLINE_IPINFO_DB_FILE)){
return null;
}
$reader = new MaxMind\Db\Reader(OFFLINE_IPINFO_DB_FILE);
$data = $reader->get($ip);
if(!is_array($data)){
return null;
}
$processedString = $ip.' - ' . $data['as_name'] . ', ' . $data['country_name'];
return json_encode([
'processedString' => $processedString,
'rawIspInfo' => $data ?: '',
]);
}
function formatResponse_simple($ip,$ispName=null){
$processedString=$ip;
if(is_string($ispName)){
$processedString.=' - '.$ispName;
}
return json_encode([
'processedString' => $processedString,
'rawIspInfo' => '',
]);
}
header('Content-Type: application/json; charset=utf-8');
if(isset($_GET["cors"])){
if (isset($_GET['cors'])) {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
}
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['X-Real-IP'])) {
$ip = $_SERVER['X-Real-IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$ip = preg_replace("/,.*/", "", $ip); # hosts are comma-separated, client is first
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$ip = preg_replace("/^::ffff:/", "", $ip);
if ($ip == "::1") { // ::1/128 is the only localhost ipv6 address. there are no others, no need to strpos this
echo json_encode(['processedString' => $ip . " - localhost IPv6 access", 'rawIspInfo' => ""]);
die();
}
if (stripos($ip, 'fe80:') === 0) { // simplified IPv6 link-local address (should match fe80::/10)
echo json_encode(['processedString' => $ip . " - link-local IPv6 access", 'rawIspInfo' => ""]);
die();
}
if (strpos($ip, '127.') === 0) { //anything within the 127/8 range is localhost ipv4, the ip must start with 127.0
echo json_encode(['processedString' => $ip . " - localhost IPv4 access", 'rawIspInfo' => ""]);
die();
}
if (strpos($ip, '10.') === 0) { // 10/8 private IPv4
echo json_encode(['processedString' => $ip . " - private IPv4 access", 'rawIspInfo' => ""]);
die();
}
if (preg_match('/^172\.(1[6-9]|2\d|3[01])\./', $ip) === 1) { // 172.16/12 private IPv4
echo json_encode(['processedString' => $ip . " - private IPv4 access", 'rawIspInfo' => ""]);
die();
}
if (strpos($ip, '192.168.') === 0) { // 192.168/16 private IPv4
echo json_encode(['processedString' => $ip . " - private IPv4 access", 'rawIspInfo' => ""]);
die();
}
if (strpos($ip, '169.254.') === 0) { // IPv4 link-local
echo json_encode(['processedString' => $ip . " - link-local IPv4 access", 'rawIspInfo' => ""]);
die();
}
/**
* Optimized algorithm from http://www.codexworld.com
*
* @param float $latitudeFrom
* @param float $longitudeFrom
* @param float $latitudeTo
* @param float $longitudeTo
*
* @return float [km]
*/
function distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo) {
$rad = M_PI / 180;
$theta = $longitudeFrom - $longitudeTo;
$dist = sin($latitudeFrom * $rad) * sin($latitudeTo * $rad) + cos($latitudeFrom * $rad) * cos($latitudeTo * $rad) * cos($theta * $rad);
return acos($dist) / $rad * 60 * 1.853;
}
function getIpInfoTokenString(){
$apikeyFile="getIP_ipInfo_apikey.php";
if(!file_exists($apikeyFile)) return "";
require $apikeyFile;
if(empty($IPINFO_APIKEY)) return "";
return "?token=".$IPINFO_APIKEY;
}
if (isset($_GET["isp"])) {
$isp = "";
$rawIspInfo=null;
try {
$json = file_get_contents("https://ipinfo.io/" . $ip . "/json".getIpInfoTokenString());
$details = json_decode($json, true);
$rawIspInfo=$details;
if (array_key_exists("org", $details)){
$isp .= $details["org"];
$isp=preg_replace("/AS\d{1,}\s/","",$isp); //Remove AS##### from ISP name, if present
}else{
$isp .= "Unknown ISP";
}
if (array_key_exists("country", $details)){
$isp .= ", " . $details["country"];
}
$clientLoc = NULL;
$serverLoc = NULL;
if (array_key_exists("loc", $details)){
$clientLoc = $details["loc"];
}
if (isset($_GET["distance"])) {
if ($clientLoc) {
$locFile="getIP_serverLocation.php";
$serverLoc=null;
if(file_exists($locFile)){
require $locFile;
}else{
$json = file_get_contents("https://ipinfo.io/json".getIpInfoTokenString());
$details = json_decode($json, true);
if (array_key_exists("loc", $details)){
$serverLoc = $details["loc"];
}
if($serverLoc){
$lf=fopen($locFile,"w");
fwrite($lf,chr(60)."?php\n");
fwrite($lf,'$serverLoc="'.addslashes($serverLoc).'";');
fwrite($lf,"\n");
fwrite($lf,"?".chr(62));
fclose($lf);
}
}
if ($serverLoc) {
try {
$clientLoc = explode(",", $clientLoc);
$serverLoc = explode(",", $serverLoc);
$dist = distance($clientLoc[0], $clientLoc[1], $serverLoc[0], $serverLoc[1]);
if ($_GET["distance"] == "mi") {
$dist /= 1.609344;
$dist = round($dist, -1);
if ($dist < 15)
$dist = "<15";
$isp .= " (" . $dist . " mi)";
}else if ($_GET["distance"] == "km") {
$dist = round($dist, -1);
if ($dist < 20)
$dist = "<20";
$isp .= " (" . $dist . " km)";
}
} catch (Exception $e) {
}
}
$ip = getClientIp();
//if the user requested the ISP info, we first try to fetch it using ipinfo.io (if there is no api key set it fails without sending data, it can also fail because of rate limiting or invalid responses), then we try with the offline db, if that also fails (or if ISP info was not requested) we just respond with the IP address
if(isset($_GET['isp'])){
$localIpInfo = getLocalOrPrivateIpInfo($ip);
//local ip, no need to fetch further information
if (is_string($localIpInfo)) {
echo formatResponse_simple($ip,$localIpInfo);
}else{
$r=getIspInfo_ipinfoApi($ip);
if(!is_null($r)){
echo $r;
}else{
$r=getIspInfo_ipinfoOfflineDb($ip);
if(!is_null($r)){
echo $r;
}else{
echo formatResponse_simple($ip);
}
}
} catch (Exception $ex) {
$isp = "Unknown ISP";
}
echo json_encode(['processedString' => $ip . " - " . $isp, 'rawIspInfo' => $rawIspInfo]);
} else {
echo json_encode(['processedString' => $ip, 'rawIspInfo' => ""]);
}else{
echo formatResponse_simple($ip);
}
?>

5
backend/getIP_ipInfo_apikey.php Normal file → Executable file
View file

@ -1,3 +1,4 @@
<?php
$IPINFO_APIKEY=""; //put your token between the quotes if you have one
?>
// put your token between the quotes if you have one
$IPINFO_APIKEY = '';

55
backend/getIP_util.php Executable file
View file

@ -0,0 +1,55 @@
<?php
/**
* Normalize and validate an IP address candidate from a request header.
*
* Trims whitespace, takes the first comma-separated token (for XFF-like
* headers that may contain a chain of addresses), and validates the result
* with filter_var().
*
* @param string $raw Raw header value.
* @param int $extraFlags Additional FILTER_FLAG_* flags (e.g. FILTER_FLAG_IPV6).
*
* @return string|false The validated IP string, or false on failure.
*/
function normalizeCandidateIp($raw, $extraFlags = 0)
{
$ip = trim($raw);
// For XFF-like values, take the first address before a comma.
if (($pos = strpos($ip, ',')) !== false) {
$ip = trim(substr($ip, 0, $pos));
}
if ($ip === '') {
return false;
}
return filter_var($ip, FILTER_VALIDATE_IP, $extraFlags);
}
/**
* @return string
*/
function getClientIp()
{
// Cloudflare IPv6 header — must be a valid IPv6 address.
if (!empty($_SERVER['HTTP_CF_CONNECTING_IPV6'])) {
$ip = normalizeCandidateIp($_SERVER['HTTP_CF_CONNECTING_IPV6'], FILTER_FLAG_IPV6);
if ($ip !== false) {
return preg_replace('/^::ffff:/', '', $ip);
}
}
// Other forwarding / proxy headers — accept any valid IP.
foreach (['HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'HTTP_X_FORWARDED_FOR'] as $header) {
if (!empty($_SERVER[$header])) {
$ip = normalizeCandidateIp($_SERVER[$header]);
if ($ip !== false) {
return preg_replace('/^::ffff:/', '', $ip);
}
}
}
// Fallback: REMOTE_ADDR is set by the web server and is always a single IP.
$ip = normalizeCandidateIp($_SERVER['REMOTE_ADDR'] ?? '');
if ($ip !== false) {
return preg_replace('/^::ffff:/', '', $ip);
}
return $_SERVER['REMOTE_ADDR'] ?? '';
}

3
config.json Normal file
View file

@ -0,0 +1,3 @@
{
"useNewDesign": false
}

73
design-switch.js Normal file
View file

@ -0,0 +1,73 @@
/**
* Feature switch for enabling the new LibreSpeed design
*
* This script checks for:
* 1. URL parameter: ?design=new or ?design=old
* 2. Configuration file: config.json with useNewDesign flag
*
* Default behavior: Shows the old design
*
* Note: This script is only loaded on the root index.html
*/
(function () {
'use strict';
// Don't run this script if we're already on a specific design page
// This prevents infinite redirect loops
const currentPath = window.location.pathname;
if (currentPath.includes('index-classic.html') || currentPath.includes('index-modern.html')) {
return;
}
// Check URL parameters first (they override config)
const urlParams = new URLSearchParams(window.location.search);
const designParam = urlParams.get('design');
if (designParam === 'new') {
redirectToNewDesign();
return;
}
if (designParam === 'old' || designParam === 'classic') {
redirectToOldDesign();
return;
}
// Check config.json for design preference
try {
const xhr = new XMLHttpRequest();
// Use a synchronous request to prevent a flash of the old design before redirecting
// Bypass stale browser caches so Docker env changes are reflected immediately
xhr.open('GET', 'config.json?_=' + Date.now(), false);
xhr.send(null);
// Check for a successful response, but not 304 Not Modified, which can have an empty response body
if (xhr.status >= 200 && xhr.status < 300) {
const config = JSON.parse(xhr.responseText);
if (config.useNewDesign === true) {
redirectToNewDesign();
} else {
redirectToOldDesign();
}
} else {
// Config not found or error - default to old design
redirectToOldDesign();
}
} catch (error) {
// If there's any error (e.g., network, JSON parse), default to old design
console.log('Using default (old) design:', error.message || 'config error');
redirectToOldDesign();
}
function redirectToNewDesign() {
// Preserve any URL parameters when redirecting
const currentParams = window.location.search;
window.location.href = 'index-modern.html' + currentParams;
}
function redirectToOldDesign() {
// Preserve any URL parameters when redirecting
const currentParams = window.location.search;
window.location.href = 'index-classic.html' + currentParams;
}
})();

663
doc.md Normal file → Executable file

File diff suppressed because it is too large Load diff

178
doc_docker.md Executable file
View file

@ -0,0 +1,178 @@
# Using the docker image
A docker version of LibreSpeed is available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest)
# Alpine Linux variant
An Alpine Linux based docker version of LibreSpeed is also available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest) under all the tags that have the `-alpine` suffix. This variant is significantly smaller but can have slightly different behaviour due to its toolchain being based in [musl](https://en.wikipedia.org/wiki/Musl) libc as mentioned in [here](https://alpinelinux.org/about/).
## Quickstart
If you just want to try it, the fastest way is:
```shell
docker run -p 80:8080 -d --name speedtest --rm ghcr.io/librespeed/speedtest
```
Then go with your browser to port 80 of your server and try it out. If port 80 is already in use, adjust the first number in 80:8080 above.
Default is to run in standalone mode.
## Docker Compose
In production environments we would recommend using docker-compose.
To start the container using [docker compose](https://docs.docker.com/compose/) the following `docker-compose.yml` 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"
#TAGLINE: "No Flash, No Java, No Websockets, No Bullsh*t"
#TELEMETRY: "false"
#ENABLE_ID_OBFUSCATION: "false"
#REDACT_IP_ADDRESSES: "false"
#PASSWORD:
#GDPR_EMAIL: "privacy@example.com"
#DISABLE_IPINFO: "false"
#IPINFO_APIKEY: "your api key"
#DISTANCE: "km"
#WEBPORT: 8080
ports:
- "80:8080" # 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 speed test. Default value: `LibreSpeed`
* __`TAGLINE`__: Slogan shown below the heading on the modern frontend (`index-modern.html`). Default value: `No Flash, No Java, No Websockets, No Bullsh*t`
* __`USE_NEW_DESIGN`__: When set to `true`, enables the new modern frontend design. When set to `false` (default), uses the classic design. The design can also be switched using URL parameters (`?design=new` or `?design=old`). Default value: `false`
* __`SERVER_LIST_URL`__: When set, both frontend designs load their server list from this URL instead of the generated or mounted `server-list.json`. This is useful if you want the containerized frontend to consume a remote shared server list.
* __`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`
* __`OBFUSCATION_SALT`__: The salt string that is used to obfuscate the test IDs. The format should be a 2 byte hex string (e.g. `0x1234abcd`). If not specified, a random one will be generated.
* __`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`
* __`DB_TYPE`__: When set to one of the supported DB-Backends it will use this instead of the default sqlite database backend. TELEMETRY has to be set to `true`. Also you have to create the database as described in [doc.md](doc.md#creating-the-database). Supported backend types are:
* sqlite - no additional settings required
* mysql, postgresql - set additional env-variables:
* DB_HOSTNAME - Name or IP of the DB server
* DB_PORT (mysql only) - Port where DB is running
* DB_NAME - Name of the telemetry db
* DB_USERNAME, DB_PASSWORD - credentials of the user with read and update permissions to the db
* mssql - not supported in docker image yet (feel free to open a PR with that, has to be done in `entrypoint.sh`)
* __`PASSWORD`__: Password to access the stats page. If not set, stats page will not allow accesses.
* __`GDPR_EMAIL`__: Email address displayed in the privacy policy for data deletion requests. If not set, the default placeholder text will be shown. This should be set to comply with GDPR requirements when running in production. Must be specified when telemetry is enabled. Note: the old `EMAIL` environment variable is still accepted as a fallback but is deprecated — please migrate to `GDPR_EMAIL`.
* __`DISABLE_IPINFO`__: If set to `true`, ISP info and distance will not be fetched from either [ipinfo.io](https://ipinfo.io) or the offline database. Default: value: `false`
* __`IPINFO_APIKEY`__: API key for [ipinfo.io](https://ipinfo.io). Optional, but required if you want to use the full [ipinfo.io](https://ipinfo.io) APIs (required for distance measurement)
* __`DISTANCE`__: When `DISABLE_IPINFO` is set to false, this specifies how the distance from the server is measured. Can be either `km` for kilometers, `mi` for miles, or an empty string to disable distance measurement. Requires an [ipinfo.io](https://ipinfo.io) API key. Default value: `km`
* __`WEBPORT`__: Allows choosing a custom port for the included web server. Default value: `8080`. Note that you will have to expose it through docker with the -p argument. This is not the port where the service is exposed outside docker!
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 Standalone Mode with telemetry
This command starts LibreSpeed in standalone mode, with persisted telemetry, ID obfuscation and a stats password, on port 86:
```shell
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
For multiple servers, you need to set up 1+ LibreSpeed backends, and 1 LibreSpeed frontend.
### Backend mode
In backend mode, LibreSpeed provides only a test point with no UI. To do this, set the `MODE` environment variable to `backend`.
The following backend files can be accessed on port 80: `garbage.php`, `empty.php`, `getIP.php`
Here's a list of additional environment variables available in this mode:
* __`IPINFO_APIKEY`__: API key for [ipinfo.io](https://ipinfo.io). Optional, but required if you want to use the full [ipinfo.io](https://ipinfo.io) APIs (required for distance measurement). If no API key is provided, the offline database will be used instead.
#### Example Backend mode
This command starts LibreSpeed in backend mode, with the default settings, on port 80:
```shell
docker run -e MODE=backend -p 80:8080 -it ghcr.io/librespeed/speedtest
```
### Frontend mode
In frontend mode, LibreSpeed serves clients the Web UI and a list of servers. To do this:
* Set the `MODE` environment variable to `frontend`
* Create a servers.json file with your test points. The syntax is the following:
```jsonc
[
{
"name": "Friendly name for Server 1",
"server" :"//server1.mydomain.com/",
"dlURL" :"garbage.php",
"ulURL" :"empty.php",
"pingURL" :"empty.php",
"getIpURL" :"getIP.php"
},
{
"name": "Friendly name for Server 2",
"server" :"https://server2.mydomain.com/",
"dlURL" :"garbage.php",
"ulURL" :"empty.php",
"pingURL" :"empty.php",
"getIpURL" :"getIP.php"
},
//...more servers...
]
```
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.
The list of environment variables available in this mode is the same as [above in standalone mode](#standalone-mode).
If you want the Docker frontend to load its server list from another URL instead of `/servers.json`, set `SERVER_LIST_URL`:
```shell
docker run -e MODE=frontend -e SERVER_LIST_URL="https://example.com/custom-server-list.json" -p 80:8080 -it ghcr.io/librespeed/speedtest
```
#### Example Frontend mode
This command starts LibreSpeed in frontend mode, with a given `servers.json` file, and with telemetry, ID obfuscation, and a stats password and a persistant sqlite database for results:
```shell
docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $PWD/servers.json:/servers.json -v $PWD/db-dir/:/database -p 80:8080 -it ghcr.io/librespeed/speedtest
```
### Dual mode
In dual mode, LibreSpeed operates as a standalone server that can also connect to other test points.
To do this:
* Set the `MODE` environment variable to `dual`
* Follow the `servers.json` instructions for the frontend mode
* The first server entry should be the local server, using the server endpoint address that a client can access.

244
docker/entrypoint.sh Executable file
View file

@ -0,0 +1,244 @@
#!/bin/bash
echo "Setting up docker env..."
echo "MODE: $MODE"
echo "USE_NEW_DESIGN: $USE_NEW_DESIGN"
echo "SERVER_LIST_URL: $SERVER_LIST_URL"
echo "WEBPORT: $WEBPORT"
echo "REDACT_IP_ADDRESSES: $REDACT_IP_ADDRESSES"
echo "DB_TYPE: $DB_TYPE"
echo "ENABLE_ID_OBFUSCATION: $ENABLE_ID_OBFUSCATION"
echo "GDPR_EMAIL: $GDPR_EMAIL"
set -e
#set -x
is_alpine() {
[ -f /etc/alpine-release ]
}
html_escape() {
printf '%s' "$1" | sed \
-e 's/&/\&amp;/g' \
-e 's/</\&lt;/g' \
-e 's/>/\&gt;/g' \
-e 's/"/\&quot;/g' \
-e "s/'/\&#39;/g"
}
sed_escape() {
printf '%s\n' "$1" | sed 's/[&/\\]/\\&/g; s/\$/\\$/g'
}
# Cleanup
rm -rf /var/www/html/*
# Copy frontend files
cp /speedtest/*.js /var/www/html/
cp /speedtest/stability.html /var/www/html/
# Copy design switch files
cp /speedtest/config.json /var/www/html/
cp /speedtest/design-switch.js /var/www/html/
# Copy PWA metadata and icons
cp /speedtest/favicon.ico /var/www/html/
cp /speedtest/manifest.webmanifest /var/www/html/
cp -r /speedtest/images /var/www/html/
# Set custom webroot on alpine
if is_alpine; then
echo "ALPINE IMAGE"
sed -i "s#\"/var/www/localhost/htdocs\"#\"/var/www/html\"#g" /etc/apache2/httpd.conf
else
echo "DEBIAN IMAGE"
fi
# Copy servers.json for stability page (frontend/dual modes)
if [[ "$MODE" == "frontend" || "$MODE" == "dual" ]] && [ -f /servers.json ]; then
cp /servers.json /var/www/html/servers.json
fi
# Set up backend side for standlone modes
if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then
cp -r /speedtest/backend/ /var/www/html/backend
if [ ! -z "$IPINFO_APIKEY" ]; then
sed -i s/\$IPINFO_APIKEY\ =\ \'\'/\$IPINFO_APIKEY\ =\ \'$IPINFO_APIKEY\'/g /var/www/html/backend/getIP_ipInfo_apikey.php
fi
fi
if [ "$MODE" == "backend" ]; then
cp -r /speedtest/backend/* /var/www/html
if [ ! -z "$IPINFO_APIKEY" ]; then
sed -i s/\$IPINFO_APIKEY\ =\ \'\'/\$IPINFO_APIKEY\ =\ \'$IPINFO_APIKEY\'/g /var/www/html/getIP_ipInfo_apikey.php
fi
fi
# Set up index.php for frontend-only or standalone modes
if [[ "$MODE" == "frontend" || "$MODE" == "dual" || "$MODE" == "standalone" ]]; then
# Copy design files (switcher + both designs)
cp /speedtest/index.html /var/www/html/
cp /speedtest/index-classic.html /var/www/html/
cp /speedtest/index-modern.html /var/www/html/
cp /speedtest/stability.html /var/www/html/
# Keep the frontend assets under frontend/, which is where the HTML looks for
# them and where they sit in the repository
cp -a /speedtest/frontend /var/www/html/
# Copy frontend config files
cp /speedtest/settings.json /var/www/html/settings.json 2>/dev/null || true
if [ -f /servers.json ]; then
echo "using mounted /servers.json for server-list.json"
cp /servers.json /var/www/html/server-list.json
# default the frontend list to the mounted file so the classic design uses it too
SERVER_LIST_URL="${SERVER_LIST_URL:-server-list.json}"
elif [ -n "$SERVER_LIST_URL" ]; then
echo "no /servers.json found, relying on SERVER_LIST_URL"
elif [ "$MODE" == "frontend" ]; then
echo "ERROR: /servers.json not found and SERVER_LIST_URL is not set" >&2
exit 1
else
echo "no /servers.json found, create one for local host"
# generate config for just the local server
echo '[{"name":"local","server":"backend", "dlURL": "garbage.php", "ulURL": "empty.php", "pingURL": "empty.php", "getIpURL": "getIP.php", "sponsorName": "", "sponsorURL": "", "id":1 }]' > /var/www/html/server-list.json
fi
if [ ! -z "$SERVER_LIST_URL" ]; then
echo "using SERVER_LIST_URL for frontend server list"
SERVER_LIST_URL_ESCAPED=$(printf '%s\n' "$SERVER_LIST_URL" | sed 's/[&/\\]/\\&/g; s/\$/\\$/g')
sed -i "s/var SPEEDTEST_SERVERS = \"server-list.json\";/var SPEEDTEST_SERVERS = \"$SERVER_LIST_URL_ESCAPED\";/" /var/www/html/index-modern.html
sed -i "/var SPEEDTEST_SERVERS = \\[/,/^[[:space:]]*];/c\\\t\tvar SPEEDTEST_SERVERS = \"$SERVER_LIST_URL_ESCAPED\";" /var/www/html/index-classic.html
sed -i "s/var SPEEDTEST_SERVERS = \"server-list.json\";/var SPEEDTEST_SERVERS = \"$SERVER_LIST_URL_ESCAPED\";/" /var/www/html/stability.html
fi
# The stability page reads the same local server list as the main UI when present.
if [ -f /var/www/html/server-list.json ]; then
cp /var/www/html/server-list.json /var/www/html/servers.json
fi
# Replace title placeholders if TITLE is set
if [ ! -z "$TITLE" ]; then
TITLE_ONE_LINE=${TITLE//$'\r'/}
TITLE_ONE_LINE=${TITLE_ONE_LINE//$'\n'/ }
TITLE_HTML_ESCAPED=$(html_escape "$TITLE_ONE_LINE")
TITLE_ESCAPED=$(sed_escape "$TITLE_HTML_ESCAPED")
sed -i "s/<title>LibreSpeed<\\/title>/<title>$TITLE_ESCAPED<\\/title>/g; s/<h1>LibreSpeed<\\/h1>/<h1>$TITLE_ESCAPED<\\/h1>/g" /var/www/html/index-classic.html
sed -i "s/<title>LibreSpeed<\\/title>/<title>$TITLE_ESCAPED<\\/title>/g" /var/www/html/index.html
sed -i "s/<title>LibreSpeed - Free and Open Source Speedtest<\\/title>/<title>$TITLE_ESCAPED - Free and Open Source Speedtest<\\/title>/g; s/<h1>Free and Open Source Speedtest\\.<\\/h1>/<h1>$TITLE_ESCAPED<\\/h1>/g" /var/www/html/index-modern.html
fi
# Replace modern page tagline if TAGLINE is set
if [ -n "$TAGLINE" ]; then
TAGLINE_ONE_LINE=${TAGLINE//$'\r'/}
TAGLINE_ONE_LINE=${TAGLINE_ONE_LINE//$'\n'/ }
TAGLINE_HTML_ESCAPED=$(html_escape "$TAGLINE_ONE_LINE")
TAGLINE_ESCAPED=$(sed_escape "$TAGLINE_HTML_ESCAPED")
sed -i "s/<p class=\"tagline\">No Flash, No Java, No Websockets, No Bullsh\\*t<\\/p>/<p class=\"tagline\">$TAGLINE_ESCAPED<\\/p>/g" /var/www/html/index-modern.html
fi
# Support legacy EMAIL env var as fallback for GDPR_EMAIL
if [ -z "$GDPR_EMAIL" ] && [ ! -z "$EMAIL" ]; then
echo "WARNING: EMAIL env var is deprecated, please use GDPR_EMAIL instead" >&2
GDPR_EMAIL="$EMAIL"
echo "GDPR_EMAIL: $GDPR_EMAIL"
fi
# Replace GDPR email placeholder if GDPR_EMAIL is set
if [ ! -z "$GDPR_EMAIL" ]; then
# Escape special sed characters: & (replacement), / (delimiter), \ (escape), $ (variable)
GDPR_EMAIL_ESCAPED=$(printf '%s\n' "$GDPR_EMAIL" | sed 's/[&/\\]/\\&/g; s/\$/\\$/g')
for html_file in /var/www/html/index-modern.html /var/www/html/index-classic.html; do
if [ -f "$html_file" ]; then
sed -i "s/TO BE FILLED BY DEVELOPER/$GDPR_EMAIL_ESCAPED/g; s/PUT@YOUR_EMAIL.HERE/$GDPR_EMAIL_ESCAPED/g" "$html_file"
fi
done
fi
fi
# Configure design preference via config.json
if [ "$USE_NEW_DESIGN" == "true" ]; then
sed -i 's/"useNewDesign": false/"useNewDesign": true/' /var/www/html/config.json
fi
# Apply Telemetry settings when running in standalone or frontend mode and telemetry is enabled
if [[ "$TELEMETRY" == "true" && ("$MODE" == "frontend" || "$MODE" == "standalone" || "$MODE" == "dual") ]]; then
cp -r /speedtest/results /var/www/html/results
sed -i 's/telemetry_level": ".*"/telemetry_level": "basic"/' /var/www/html/settings.json
if [ "$MODE" == "frontend" ]; then
mkdir /var/www/html/backend
cp /speedtest/backend/getIP_util.php /var/www/html/backend
fi
if [ "$DB_TYPE" == "mysql" ]; then
sed -i 's/$db_type = '\''.*'\''/$db_type = '\'$DB_TYPE\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$MySql_username = '\''.*'\''/$MySql_username = '\'$DB_USERNAME\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$MySql_password = '\''.*'\''/$MySql_password = '\'$DB_PASSWORD\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$MySql_hostname = '\''.*'\''/$MySql_hostname = '\'$DB_HOSTNAME\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$MySql_databasename = '\''.*'\''/$MySql_databasename = '\'$DB_NAME\''/g' /var/www/html/results/telemetry_settings.php
if [ "$DB_PORT" != "" ]; then
sed -i 's/$MySql_port = '\''.*'\''/$MySql_port = '\'$DB_PORT\''/g' /var/www/html/results/telemetry_settings.php
fi
elif [ "$DB_TYPE" == "postgresql" ]; then
sed -i 's/$db_type = '\''.*'\''/$db_type = '\'$DB_TYPE\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$PostgreSql_username = '\''.*'\''/$PostgreSql_username = '\'$DB_USERNAME\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$PostgreSql_password = '\''.*'\''/$PostgreSql_password = '\'$DB_PASSWORD\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$PostgreSql_hostname = '\''.*'\''/$PostgreSql_hostname = '\'$DB_HOSTNAME\''/g' /var/www/html/results/telemetry_settings.php
sed -i 's/$PostgreSql_databasename = '\''.*'\''/$PostgreSql_databasename = '\'$DB_NAME\''/g' /var/www/html/results/telemetry_settings.php
else
sed -i s/\$db_type\ =\ \'.*\'/\$db_type\ =\ \'sqlite\'\/g /var/www/html/results/telemetry_settings.php
fi
# Override SQLite database path for Docker environment
# In Docker, we use /database/db.sql which is outside the web-accessible directory
sed -i s/\$Sqlite_db_file\ =\ .*\'/\$Sqlite_db_file=\'\\\/database\\\/db.sql\'/g /var/www/html/results/telemetry_settings.php
sed -i s/\$stats_password\ =\ \'.*\'/\$stats_password\ =\ \'$PASSWORD\'/g /var/www/html/results/telemetry_settings.php
if [ "$ENABLE_ID_OBFUSCATION" == "true" ]; then
sed -i s/\$enable_id_obfuscation\ =\ .*\;/\$enable_id_obfuscation\ =\ true\;/g /var/www/html/results/telemetry_settings.php
if [ ! -z "$OBFUSCATION_SALT" ]; then
if [[ "$OBFUSCATION_SALT" =~ ^0x[0-9a-fA-F]+$ ]]; then
echo "<?php" > /var/www/html/results/idObfuscation_salt.php
echo "\$OBFUSCATION_SALT = $OBFUSCATION_SALT;" >> /var/www/html/results/idObfuscation_salt.php
else
echo "WARNING: Invalid OBFUSCATION_SALT format. It must be a hex string (e.g., 0x1234abcd). Using random salt." >&2
fi
fi
fi
if [ "$REDACT_IP_ADDRESSES" == "true" ]; then
sed -i s/\$redact_ip_addresses\ =\ .*\;/\$redact_ip_addresses\ =\ true\;/g /var/www/html/results/telemetry_settings.php
fi
mkdir -p /database/
if is_alpine; then
chown -R apache /database/
else
chown -R www-data /database/
fi
fi
if is_alpine; then
chown -R apache /var/www/html/*
else
chown -R www-data /var/www/html/*
fi
# Allow selection of Apache port for network_mode: host
if [ "$WEBPORT" != "80" ]; then
if is_alpine; then
sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/httpd.conf
else
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
fi
fi
echo "Done, Starting APACHE"
# This runs apache
if is_alpine; then
exec httpd -DFOREGROUND
else
exec apache2-foreground
fi

11
docker/librespeed-php.ini Normal file
View file

@ -0,0 +1,11 @@
; speedtest_worker.js defaults xhr_ul_blob_megabytes to 20.
; PHP's stock post_max_size = 8M rejects those upload chunks before
; empty.php can send its headers. 32M leaves modest headroom.
post_max_size = 32M
; LibreSpeed does not use the session upload progress feature, and PHP's advisory
; for CVE-2026-109619 (GHSA-6wmf-4rv5-p3rp) names it as a way to reach the
; vulnerable code path, recommending it be off if it is not needed. Updating PHP is
; the real fix; this only removes a feature nobody here uses.
session.upload_progress.enabled = 0

19
docker/servers.json Executable file
View file

@ -0,0 +1,19 @@
[
{
"name": "Example server 1 (HTTP and HTTPS)",
"server" :"//example1.mydomain.com/",
"dlURL" :"garbage.php",
"ulURL" :"empty.php",
"pingURL" :"empty.php",
"getIpURL" :"getIP.php"
},
{
"name": "Example server 2 (HTTPS only)",
"server" :"https://example2.mydomain.com/",
"dlURL" :"garbage.php",
"ulURL" :"empty.php",
"pingURL" :"empty.php",
"getIpURL" :"getIP.php"
}
]

1
docker/test/.env Normal file
View file

@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=speedtest-test

4
docker/test/README.md Normal file
View file

@ -0,0 +1,4 @@
The files in this folder represent a simple end to end test.
At the moment it is interactive, so you need to run `docker compose up` in the folder and watch the output for errors.
Sometimes the mysql container needs more than 15 seconds, so the test_script fails.
Just try it again.

View file

@ -0,0 +1,208 @@
## this is a docker compose file used to test all scenarios
## do not use it in production
x-shared:
speedtest-service: &speedtest-service
environment:
- PASSWORD=gimmeTheStats1337
- GDPR_EMAIL=test@example.com
- ENABLE_ID_OBFUSCATION=true
- MODE=standalone
- REDACT_IP_ADDRESSES=true
- TELEMETRY=true
services:
###################### POSTGRESQL ################################
pg:
image: postgres:alpine
environment:
POSTGRES_PASSWORD: Not4SecureProduction
POSTGRES_USER: librespeed
volumes:
# mount init script from source to create database tables
- ../../results/telemetry_postgresql.sql:/docker-entrypoint-initdb.d/01-init.sql
speedtest-debian-pg:
build:
context: ../..
dockerfile: Dockerfile
environment: &env_vars_pg
- PASSWORD=gimmeTheStats1337
- DB_HOSTNAME=pg
- DB_NAME=librespeed
- DB_PASSWORD=Not4SecureProduction
- DB_TYPE=postgresql
- DB_USERNAME=librespeed
- GDPR_EMAIL=test@example.com
- ENABLE_ID_OBFUSCATION=true
- MODE=standalone
- REDACT_IP_ADDRESSES=true
- TELEMETRY=true
ports:
- 9123:8080
speedtest-alpine-pg:
build:
context: ../..
dockerfile: Dockerfile.alpine
environment: *env_vars_pg
ports:
- 9124:8080
####################### MYSQL ##############################
mysql:
image: mysql:lts
environment:
MYSQL_ROOT_PASSWORD: Not4SecureProduction
MYSQL_USER: librespeed
MYSQL_PASSWORD: Not4SecureProduction
MYSQL_DATABASE: librespeed
volumes:
# mount init script from source to create database tables
- ../../results/telemetry_mysql.sql:/docker-entrypoint-initdb.d/01-init.sql
speedtest-debian-mysql:
# check at http://localhost:9125/results/sanitycheck.php
build:
context: ../..
dockerfile: Dockerfile
environment: &env_vars_mysql
- PASSWORD=gimmeTheStats1337
- DB_HOSTNAME=mysql
- DB_NAME=librespeed
- DB_PASSWORD=Not4SecureProduction
- DB_TYPE=mysql
- DB_USERNAME=librespeed
- GDPR_EMAIL=test@example.com
- ENABLE_ID_OBFUSCATION=true
- MODE=standalone
- REDACT_IP_ADDRESSES=true
- TELEMETRY=true
ports:
- 9125:8080
speedtest-alpine-mysql:
build:
context: ../..
dockerfile: Dockerfile.alpine
environment: *env_vars_mysql
ports:
- 9126:8080
####################### MSSQL ##############################
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Not4SecureProduction1337
- MSSQL_PID=Express
healthcheck:
test:
["CMD-SHELL", "/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P $$SA_PASSWORD -C -Q 'SELECT 1' || exit 1"]
interval: 10s
retries: 5
start_period: 30s
mssql-init:
image: mcr.microsoft.com/mssql/server:2022-latest
depends_on:
mssql:
condition: service_healthy
environment:
- SA_PASSWORD=Not4SecureProduction1337
volumes:
- ../../results/telemetry_mssql.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
command: >
bash -c '
echo "Waiting for MSSQL to be ready...";
until /opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P "$$SA_PASSWORD" -C -Q "SELECT 1"; do
sleep 1;
done;
echo "Running init scripts...";
for f in /docker-entrypoint-initdb.d/*.sql; do
echo "Executing $$f...";
/opt/mssql-tools18/bin/sqlcmd -S mssql -U sa -P "$$SA_PASSWORD" -C -i "$$f";
done;
echo "Initialization complete!";
'
speedtest-debian-mssql:
build:
context: ../..
dockerfile: Dockerfile
environment: &env_vars_mssql
- PASSWORD=gimmeTheStats1337
- DB_HOSTNAME=mssql
- DB_NAME=librespeed
- DB_PASSWORD=Not4SecureProduction1337
- DB_TYPE=mssql
- DB_USERNAME=sa
- GDPR_EMAIL=test@example.com
- ENABLE_ID_OBFUSCATION=true
- MODE=standalone
- REDACT_IP_ADDRESSES=true
- TELEMETRY=true
ports:
- 9130:8080
speedtest-alpine-mssql:
build:
context: ../..
dockerfile: Dockerfile.alpine
environment: *env_vars_mssql
ports:
- 9131:8080
################ SQLITE ####################################
speedtest-debian-sqlite:
# check at http://localhost:9125/results/sanitycheck.php
build:
context: ../..
dockerfile: Dockerfile
environment: &env_vars_sqlite
- PASSWORD=gimmeTheStats1337
- GDPR_EMAIL=test@example.com
- ENABLE_ID_OBFUSCATION=true
- MODE=standalone
- REDACT_IP_ADDRESSES=true
- TELEMETRY=true
ports:
- 9127:8080
speedtest-alpine-sqlite:
build:
context: ../..
dockerfile: Dockerfile.alpine
environment: *env_vars_sqlite
ports:
- 9128:8080
speedtest-alpine-sqlite-dual:
<<: *speedtest-service
build:
context: ../..
dockerfile: Dockerfile.alpine
environment:
- MODE=dual
volumes:
- ./servers.json:/servers.json:ro
ports:
- 9129:8080
############## TEST CONTAINER ###############################################################
test-container:
image: alpine
depends_on:
- pg
- mysql
- mssql-init
- speedtest-alpine-mysql
- speedtest-alpine-pg
- speedtest-alpine-mssql
volumes:
- ./test-script.sh:/test-script.sh
command:
- sh
- /test-script.sh

409
docker/test/servers.json Normal file
View file

@ -0,0 +1,409 @@
[
{
"name": "Amsterdam, Netherlands (Clouvider)",
"server": "//ams.speedtest.clouvider.net/backend",
"id": 51,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Amsterdam, Netherlands (Sharktech)",
"server": "https://amsspeed.sharktech.net",
"id": 94,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Atlanta, United States (Clouvider)",
"server": "//atl.speedtest.clouvider.net/backend",
"id": 53,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Bangalore, India (DigitalOcean)",
"server": "//in1.backend.librespeed.org/",
"id": 75,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "DigitalOcean",
"sponsorURL": "https://www.digitalocean.com"
},
{
"name": "Bari, Italy (GARR)",
"server": "https://st-be-ba1.infra.garr.it",
"id": 33,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Bologna, Italy (GARR)",
"server": "https://st-be-bo1.infra.garr.it",
"id": 34,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Chicago, USA (Sharktech)",
"server": "https://chispeed.sharktech.net",
"id": 93,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Denver, USA (Sharktech)",
"server": "https://denspeed.sharktech.net",
"id": 92,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Frankfurt, Germany (Clouvider)",
"server": "//fra.speedtest.clouvider.net/backend",
"id": 50,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Frankfurt, Germany (FRA01)",
"server": "https://speedtest.lumischvps.cloud/",
"id": 86,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "LumischVPS",
"sponsorURL": "https://discord.gg/GxYzPwJmA2"
},
{
"name": "Ghom, Iran (Amin IDC)",
"server": "https://fastme.ir/",
"id": 77,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech/"
},
{
"name": "Helsinki, Finland (3) (Hetzner)",
"server": "//finew.openspeed.org/",
"id": 22,
"dlURL": "backend437/garbage.php",
"ulURL": "backend437/empty.php",
"pingURL": "backend437/empty.php",
"getIpURL": "backend437/getIP.php",
"sponsorName": "Daily Health Insurance Group",
"sponsorURL": "//dhig.net/"
},
{
"name": "Helsinki, Finland (5) (Hetzner)",
"server": "//fast.kabi.tk/",
"id": 24,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "KABI.tk",
"sponsorURL": "//kabi.tk"
},
{
"name": "Johannesburg, South Africa (Host Africa)",
"server": "//za1.backend.librespeed.org/",
"id": 70,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "HOSTAFRICA",
"sponsorURL": "https://www.hostafrica.co.za"
},
{
"name": "Las Vegas, USA (Sharktech)",
"server": "https://lasspeed.sharktech.net",
"id": 90,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "London, England (Clouvider)",
"server": "//lon.speedtest.clouvider.net/backend",
"id": 49,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Los Angeles, United States (1) (Clouvider)",
"server": "//la.speedtest.clouvider.net/backend",
"id": 54,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Los Angeles, USA (Sharktech)",
"server": "https://laxspeed.sharktech.net",
"id": 91,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "New York, United States (2) (Clouvider)",
"server": "//nyc.speedtest.clouvider.net/backend",
"id": 52,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Nottingham, England (LayerIP)",
"server": "https://uk1.backend.librespeed.org",
"id": 43,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "fosshost.org",
"sponsorURL": "https://fosshost.org"
},
{
"name": "Nuremberg, Germany (1) (Hetzner)",
"server": "//de1.backend.librespeed.org",
"id": 28,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Snopyta",
"sponsorURL": "https://snopyta.org"
},
{
"name": "Nuremberg, Germany (2) (Hetzner)",
"server": "//de4.backend.librespeed.org",
"id": 27,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (3) (Hetzner)",
"server": "//de3.backend.librespeed.org",
"id": 30,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (4) (Hetzner)",
"server": "//de5.backend.librespeed.org",
"id": 31,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (6) (Hetzner)",
"server": "//librespeed.lukas-heinrich.com/",
"id": 46,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "luki9100",
"sponsorURL": "https://lukas-heinrich.com/"
},
{
"name": "Ohio, USA (Rust backend)",
"server": "https://librespeed-rs.ir/",
"id": 95,
"dlURL": "backend/garbage",
"ulURL": "backend/empty",
"pingURL": "backend/empty",
"getIpURL": "backend/getIP",
"sponsorName": "Sudo Dios",
"sponsorURL": "https://github.com/SudoDios"
},
{
"name": "Poznan, Poland (INEA)",
"server": "https://speedtest.kamilszczepanski.com",
"id": 74,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Kamil Szczepański",
"sponsorURL": "https://kamilszczepanski.com"
},
{
"name": "Prague, Czech Republic (CESNET)",
"server": "//speedtest.cesnet.cz",
"id": 79,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "CESNET",
"sponsorURL": "https://www.cesnet.cz"
},
{
"name": "Prague, Czech Republic (Turris)",
"server": "//librespeed.turris.cz",
"id": 85,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Turris",
"sponsorURL": "https://www.turris.com"
},
{
"name": "Roma, Italy (GARR)",
"server": "https://st-be-rm2.infra.garr.it",
"id": 35,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Serbia (SOX)",
"server": "https://speedtest2.sox.rs",
"id": 87,
"dlURL": "libre/backend/garbage.php",
"ulURL": "libre/backend/empty.php",
"pingURL": "libre/backend/empty.php",
"getIpURL": "libre/backend/getIP.php",
"sponsorName": "Serbian Open eXchange (SOX)",
"sponsorURL": "https://sox.rs"
},
{
"name": "Singapore (Salvatore Cahyo)",
"server": "https://speedtest.dsgroupmedia.com",
"id": 68,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Salvatore Cahyo",
"sponsorURL": "https://salvatorecahyo.my.id"
},
{
"name": "Tehran, Iran (Fanava)",
"server": "https://speedme.ir/",
"id": 76,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech"
},
{
"name": "Tehran, Iran (Faraso)",
"server": "https://st.bardia.tech",
"id": 80,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech/"
},
{
"name": "Tokyo, Japan (A573)",
"server": "https://librespeed.a573.net/",
"id": 82,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "A573",
"sponsorURL": "https://mirror.a573.net/"
},
{
"name": "Vilnius, Lithuania (RackRay)",
"server": "//lt1.backend.librespeed.org/",
"id": 69,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Time4VPS",
"sponsorURL": "https://www.time4vps.com"
},
{
"name": "Virginia, United States, OVH",
"server": "https://speed.riverside.rocks/",
"id": 78,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Riverside Rocks",
"sponsorURL": "https://riverside.rocks"
}
]

25
docker/test/test-arm-build.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
set -e
# register QEMU handlers for emulation (one-time)
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# create and use a buildx builder (if you don't already have one)
if ! docker buildx inspect mybuilder > /dev/null 2>&1; then
docker buildx create --name mybuilder --use
else
docker buildx use mybuilder
fi
docker buildx inspect --bootstrap
# change to repo root
cd ../..
# build the alpine image for arm64 and amd64
# Note: We cannot use --load with multiple platforms.
# We will build for arm64 specifically to test the emulation and load it.
echo "Building for linux/arm64..."
docker buildx build --platform linux/arm64 -f Dockerfile.alpine -t local-speedtest:alpine-arm64 --load .
# To build for both platforms, you typically need to push to a registry:
# docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile.alpine -t local-speedtest:alpine --push .

View file

@ -0,0 +1,21 @@
#!/bin/sh
## simple script to call sanitycheck on all containers
PORT=8080
if ! apk add w3m; then
echo "Failed to install w3m package"
exit 1
fi
echo sleeping a little to get things settled...
sleep 15
for db in sqlite pg mysql mssql; do
for distro in alpine debian; do
hostname=speedtest-$distro-$db
echo $hostname
w3m -dump http://$hostname:$PORT/results/sanitycheck.php|grep -v 'N/A'
done
done

View file

@ -1,355 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<meta charset="UTF-8" />
<link rel="shortcut icon" href="favicon.ico">
<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
s.setParameter("telemetry_level","basic"); //enable telemetry
var meterBk=/Trident.*rv:(\d+\.\d+)/i.test(navigator.userAgent)?"#EAEAEA":"#80808040";
var dlColor="#6060AA",
ulColor="#616161";
var progColor=meterBk;
//CODE FOR GAUGES
function drawMeter(c,amount,bk,fg,progress,prog){
var ctx=c.getContext("2d");
var dp=window.devicePixelRatio||1;
var cw=c.clientWidth*dp, ch=c.clientHeight*dp;
var sizScale=ch*0.0055;
if(c.width==cw&&c.height==ch){
ctx.clearRect(0,0,cw,ch);
}else{
c.width=cw;
c.height=ch;
}
ctx.beginPath();
ctx.strokeStyle=bk;
ctx.lineWidth=12*sizScale;
ctx.arc(c.width/2,c.height-58*sizScale,c.height/1.8-ctx.lineWidth,-Math.PI*1.1,Math.PI*0.1);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle=fg;
ctx.lineWidth=12*sizScale;
ctx.arc(c.width/2,c.height-58*sizScale,c.height/1.8-ctx.lineWidth,-Math.PI*1.1,amount*Math.PI*1.2-Math.PI*1.1);
ctx.stroke();
if(typeof progress !== "undefined"){
ctx.fillStyle=prog;
ctx.fillRect(c.width*0.3,c.height-16*sizScale,c.width*0.4*progress,4*sizScale);
}
}
function mbpsToAmount(s){
return 1-(1/(Math.pow(1.3,Math.sqrt(s))));
}
function format(d){
d=Number(d);
if(d<10) return d.toFixed(2);
if(d<100) return d.toFixed(1);
return d.toFixed(0);
}
//UI CODE
var uiData=null;
function startStop(){
if(s.getState()==3){
//speedtest is running, abort
s.abort();
data=null;
I("startStopBtn").className="";
initUI();
}else{
//test is not running, begin
I("startStopBtn").className="running";
I("shareArea").style.display="none";
s.onupdate=function(data){
uiData=data;
};
s.onend=function(aborted){
I("startStopBtn").className="";
updateUI(true);
if(!aborted){
//if testId is present, show sharing panel, otherwise do nothing
try{
var testId=uiData.testId;
if(testId!=null){
var shareURL=window.location.href.substring(0,window.location.href.lastIndexOf("/"))+"/results/?id="+testId;
I("resultsImg").src=shareURL;
I("resultsURL").value=shareURL;
I("testId").innerHTML=testId;
I("shareArea").style.display="";
}
}catch(e){}
}
};
s.start();
}
}
//this function reads the data sent back by the test and updates the UI
function updateUI(forced){
if(!forced&&s.getState()!=3) return;
if(uiData==null) return;
var status=uiData.testState;
I("ip").textContent=uiData.clientIp;
I("dlText").textContent=(status==1&&uiData.dlStatus==0)?"...":format(uiData.dlStatus);
drawMeter(I("dlMeter"),mbpsToAmount(Number(uiData.dlStatus*(status==1?oscillate():1))),meterBk,dlColor,Number(uiData.dlProgress),progColor);
I("ulText").textContent=(status==3&&uiData.ulStatus==0)?"...":format(uiData.ulStatus);
drawMeter(I("ulMeter"),mbpsToAmount(Number(uiData.ulStatus*(status==3?oscillate():1))),meterBk,ulColor,Number(uiData.ulProgress),progColor);
I("pingText").textContent=format(uiData.pingStatus);
I("jitText").textContent=format(uiData.jitterStatus);
}
function oscillate(){
return 1+0.02*Math.sin(Date.now()/100);
}
//update the UI every frame
window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||(function(callback,element){setTimeout(callback,1000/60);});
function frame(){
requestAnimationFrame(frame);
updateUI();
}
frame(); //start frame loop
//function to (re)initialize UI
function initUI(){
drawMeter(I("dlMeter"),0,meterBk,dlColor,0);
drawMeter(I("ulMeter"),0,meterBk,ulColor,0);
I("dlText").textContent="";
I("ulText").textContent="";
I("pingText").textContent="";
I("jitText").textContent="";
I("ip").textContent="";
}
</script>
<style type="text/css">
html,body{
border:none; padding:0; margin:0;
background:#FFFFFF;
color:#202020;
}
body{
text-align:center;
font-family:"Roboto",sans-serif;
}
h1{
color:#404040;
}
#startStopBtn{
display:inline-block;
margin:0 auto;
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
width:8em; height:3em;
line-height:2.7em;
cursor:pointer;
box-shadow: 0 0 0 rgba(0,0,0,0.1), inset 0 0 0 rgba(0,0,0,0.1);
}
#startStopBtn:hover{
box-shadow: 0 0 2em rgba(0,0,0,0.1), inset 0 0 1em rgba(0,0,0,0.1);
}
#startStopBtn.running{
background-color:#FF3030;
border-color:#FF6060;
color:#FFFFFF;
}
#startStopBtn:before{
content:"Start";
}
#startStopBtn.running:before{
content:"Abort";
}
#test{
margin-top:2em;
margin-bottom:12em;
}
div.testArea{
display:inline-block;
width:16em;
height:12.5em;
position:relative;
box-sizing:border-box;
}
div.testArea2{
display:inline-block;
width:14em;
height:7em;
position:relative;
box-sizing:border-box;
text-align:center;
}
div.testArea div.testName{
position:absolute;
top:0.1em; left:0;
width:100%;
font-size:1.4em;
z-index:9;
}
div.testArea2 div.testName{
display:block;
text-align:center;
font-size:1.4em;
}
div.testArea div.meterText{
position:absolute;
bottom:1.55em; left:0;
width:100%;
font-size:2.5em;
z-index:9;
}
div.testArea2 div.meterText{
display:inline-block;
font-size:2.5em;
}
div.meterText:empty:before{
content:"0.00";
}
div.testArea div.unit{
position:absolute;
bottom:2em; left:0;
width:100%;
z-index:9;
}
div.testArea2 div.unit{
display:inline-block;
}
div.testArea canvas{
position:absolute;
top:0; left:0; width:100%; height:100%;
z-index:1;
}
div.testGroup{
display:block;
margin: 0 auto;
}
#shareArea{
width:95%;
max-width:40em;
margin:0 auto;
margin-top:2em;
}
#shareArea > *{
display:block;
width:100%;
height:auto;
margin: 0.25em 0;
}
#privacyPolicy{
position:fixed;
top:2em;
bottom:2em;
left:2em;
right:2em;
overflow-y:auto;
width:auto;
height:auto;
box-shadow:0 0 3em 1em #000000;
z-index:999999;
text-align:left;
background-color:#FFFFFF;
padding:1em;
}
a.privacy{
text-align:center;
font-size:0.8em;
color:#808080;
display:block;
}
@media all and (max-width:40em){
body{
font-size:0.8em;
}
}
</style>
<title>LibreSpeed Example</title>
</head>
<body>
<h1>LibreSpeed Example</h1>
<div id="testWrapper">
<div id="startStopBtn" onclick="startStop()"></div><br/>
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display=''">Privacy</a>
<div id="test">
<div class="testGroup">
<div class="testArea2">
<div class="testName">Ping</div>
<div id="pingText" class="meterText" style="color:#AA6060"></div>
<div class="unit">ms</div>
</div>
<div class="testArea2">
<div class="testName">Jitter</div>
<div id="jitText" class="meterText" style="color:#AA6060"></div>
<div class="unit">ms</div>
</div>
</div>
<div class="testGroup">
<div class="testArea">
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></div>
<div class="unit">Mbps</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>
</div>
<div id="ipArea">
<span id="ip"></span>
</div>
<div id="shareArea" style="display:none">
<h3>Share results</h3>
<p>Test ID: <span id="testId"></span></p>
<input type="text" value="" id="resultsURL" readonly="readonly" onclick="this.select();this.focus();this.select();document.execCommand('copy');alert('Link copied')"/>
<img src="" id="resultsImg" />
</div>
</div>
<a href="https://github.com/librespeed/speedtest">Source code</a>
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<p>This HTML5 Speedtest 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:
<ul>
<li>Test ID</li>
<li>Time of testing</li>
<li>Test results (download and upload speed, ping and jitter)</li>
<li>IP address</li>
<li>ISP information</li>
<li>Approximate location (inferred from IP address, not GPS)</li>
<li>User agent and browser locale</li>
<li>Test log (contains no personal information)</li>
</ul>
</p>
<h4>How we use the data</h4>
<p>
Data collected through this service is used to:
<ul>
<li>Allow sharing of test results (sharable image for forums, etc.)</li>
<li>To improve the service offered to you (for instance, to detect problems on our side)</li>
</ul>
No personal information is disclosed to third parties.
</p>
<h4>Your consent</h4>
<p>
By starting the test, you consent to the terms of this privacy policy.
</p>
<h4>Data removal</h4>
<p>
If you want to have your information deleted, you need to provide either the ID of the test or your IP address. This is the only way to identify your data, without this information we won't be able to comply with your request.<br/><br/>
Contact this email address for all deletion requests: <a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
</p>
<br/><br/>
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display='none'">Close</a><br/>
</div>
<script type="text/javascript">setTimeout(function(){initUI()},100);</script>
</body>
</html>

View file

@ -10,51 +10,70 @@ function I(i){return document.getElementById(i);}
//LIST OF TEST SERVERS. See documentation for details if needed
var SPEEDTEST_SERVERS=[
{ //this is my demo server, remove it
name:"Speedtest Demo Server (Helsinki)", //user friendly name for the server
server:"//fi.openspeed.org/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
{ //this server doesn't actually exist, remove it
name:"Example Server 1", //user friendly name for the server
server:"//test1.mydomain.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"backend/garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"backend/empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"backend/empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"backend/getIP.php" //path to getIP on this server (getIP.php or replacement)
},
{ //this server doesn't actually exist, remove it
name:"Example Server 2", //user friendly name for the server
server:"//test2.example.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"getIP.php" //path to getIP on this server (getIP.php or replacement)
},
{ //this is my demo server, remove it
name:"Old Speedtest Demo Server",
server:"//mpotdemo.fdossena.com/",
dlURL:"garbage.php",
ulURL:"empty.php",
pingURL:"empty.php",
getIpURL:"getIP.php"
}
//add other servers here, comma separated
];
//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
var s=new Speedtest(); //create speed test object
s.setParameter("telemetry_level","basic"); //enable telemetry
s.addTestPoints(SPEEDTEST_SERVERS); //add list of servers
//SERVER AUTO SELECTION
function initServers(){
s.selectServer(function(server){
if(server!=null){ //at least 1 server is available
I("loading").className="hidden"; //hide loading message
//populate server list for manual selection
for(var i=0;i<SPEEDTEST_SERVERS.length;i++){
if(SPEEDTEST_SERVERS[i].pingT==-1) continue;
var option=document.createElement("option");
option.value=i;
option.textContent=SPEEDTEST_SERVERS[i].name;
if(SPEEDTEST_SERVERS[i]===server) option.selected=true;
I("server").appendChild(option);
}
//show test UI
I("testWrapper").className="visible";
initUI();
}else{ //no servers are available, the test cannot proceed
I("message").innerHTML="No servers available";
}
});
var noServersAvailable=function(){
I("message").innerHTML="No servers available";
}
var runServerSelect=function(){
s.selectServer(function(server){
if(server!=null){ //at least 1 server is available
I("loading").className="hidden"; //hide loading message
//populate server list for manual selection
for(var i=0;i<SPEEDTEST_SERVERS.length;i++){
if(SPEEDTEST_SERVERS[i].pingT==-1) continue;
var option=document.createElement("option");
option.value=i;
option.textContent=SPEEDTEST_SERVERS[i].name;
if(SPEEDTEST_SERVERS[i]===server) option.selected=true;
I("server").appendChild(option);
}
//show test UI
I("testWrapper").className="visible";
initUI();
}else{ //no servers are available, the test cannot proceed
noServersAvailable();
}
});
}
if(typeof SPEEDTEST_SERVERS === "string"){
//need to fetch list of servers from specified URL
s.loadServerList(SPEEDTEST_SERVERS,function(servers){
if(servers==null){ //failed to load server list
noServersAvailable();
}else{ //server list loaded
SPEEDTEST_SERVERS=servers;
runServerSelect();
}
});
}else{
//hardcoded server list
s.addTestPoints(SPEEDTEST_SERVERS);
runServerSelect();
}
}
var meterBk=/Trident.*rv:(\d+\.\d+)/i.test(navigator.userAgent)?"#EAEAEA":"#80808040";
@ -103,15 +122,17 @@ 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="";
I("startStopBtn").setAttribute("aria-label","Start");
I("server").disabled=false;
initUI();
}else{
//test is not running, begin
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
I("shareArea").style.display="none";
I("server").disabled=true;
s.onupdate=function(data){
@ -119,6 +140,7 @@ function startStop(){
};
s.onend=function(aborted){
I("startStopBtn").className="";
I("startStopBtn").setAttribute("aria-label","Start");
I("server").disabled=false;
updateUI(true);
if(!aborted){
@ -128,6 +150,7 @@ function startStop(){
if(testId!=null){
var shareURL=window.location.href.substring(0,window.location.href.lastIndexOf("/"))+"/results/?id="+testId;
I("resultsImg").src=shareURL;
I("resultsImg").alt="Download: "+uiData.dlStatus+" Mbps, Upload: "+uiData.ulStatus+" Mbps, Ping: "+uiData.pingStatus+" ms, Jitter: "+uiData.jitterStatus+" ms";
I("resultsURL").value=shareURL;
I("testId").innerHTML=testId;
I("shareArea").style.display="";
@ -210,6 +233,8 @@ function initUI(){
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -333,8 +358,15 @@ function initUI(){
text-align:center;
font-size:0.8em;
color:#808080;
display:block;
padding: 0 3em;
}
div.closePrivacyPolicy {
width: 100%;
text-align: center;
}
div.closePrivacyPolicy a.privacy {
padding: 1em 3em;
}
@media all and (max-width:40em){
body{
font-size:0.8em;
@ -375,7 +407,7 @@ function initUI(){
<p id="message"><span class="loadCircle"></span>Selecting a server...</p>
</div>
<div id="testWrapper" class="hidden">
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button><br/>
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display=''">Privacy</a>
<div id="serverArea">
Server: <select id="server" onchange="s.setSelectedServer(SPEEDTEST_SERVERS[this.value])"></select>
@ -398,13 +430,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">
@ -421,7 +453,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:
@ -455,7 +487,10 @@ function initUI(){
Contact this email address for all deletion requests: <a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
</p>
<br/><br/>
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display='none'">Close</a><br/>
<div class="closePrivacyPolicy">
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display='none'">Close</a>
</div>
<br/>
</div>
</body>
</html>

View file

@ -10,21 +10,21 @@
//LIST OF TEST SERVERS. See documentation for details if needed
var SPEEDTEST_SERVERS=[
{ //this is my demo server, remove it
name:"Speedtest Demo Server (Helsinki)", //user friendly name for the server
server:"//fi.openspeed.org/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
{ //this server doesn't actually exist, remove it
name:"Example Server 1", //user friendly name for the server
server:"//test1.mydomain.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"backend/garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"backend/empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"backend/empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"backend/getIP.php" //path to getIP on this server (getIP.php or replacement)
},
{ //this server doesn't actually exist, remove it
name:"Example Server 2", //user friendly name for the server
server:"//test2.example.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"getIP.php" //path to getIP on this server (getIP.php or replacement)
},
{ //this is my demo server, remove it
name:"Old Speedtest Demo Server",
server:"//mpotdemo.fdossena.com/",
dlURL:"garbage.php",
ulURL:"empty.php",
pingURL:"empty.php",
getIpURL:"getIP.php"
}
//add other servers here, comma separated
];
@ -32,7 +32,7 @@ var SPEEDTEST_SERVERS=[
//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
s.addTestPoints(SPEEDTEST_SERVERS); //add list of servers
s.onupdate=function(data){ //callback to update data in UI
I("ip").textContent=data.clientIp;
I("dlText").textContent=(data.testState==1&&data.dlStatus==0)?"...":data.dlStatus;
@ -42,17 +42,38 @@ s.onupdate=function(data){ //callback to update data in UI
}
s.onend=function(aborted){ //callback for test ended/aborted
I("startStopBtn").className=""; //show start button again
I("startStopBtn").setAttribute("aria-label","Start");
if(aborted){ //if the test was aborted, clear the UI and prepare for new test
initUI();
}
}
function selectServer(){ //called when the page is fully loaded
I("startStopBtn").style.display="none"; //hide start/stop button during server selection
function selectServer(){ //called after loading server list
s.selectServer(function(server){ //run server selection. When the server has been selected, display it in the UI
I("startStopBtn").style.display=""; //show start/stop button again
I("serverId").textContent=server.name; //show name of test server
if(server==null){
I("serverId").textContent="No servers available";
}else{
I("startStopBtn").style.display=""; //show start/stop button again
I("serverId").textContent=server.name; //show name of test server
}
});
}
function loadServers(){ //called when the page is fully loaded
I("startStopBtn").style.display="none"; //hide start/stop button during server selection
if(typeof SPEEDTEST_SERVERS === "string"){
//load servers from url
s.loadServerList(SPEEDTEST_SERVERS,function(servers){
//list loaded
SPEEDTEST_SERVERS=servers;
selectServer();
});
}else{
//hardcoded list of servers, already loaded
s.addTestPoints(SPEEDTEST_SERVERS);
selectServer();
}
}
function startStop(){ //start/stop button pressed
@ -63,6 +84,7 @@ function startStop(){ //start/stop button pressed
//test is not running, begin
s.start();
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
}
}
@ -97,6 +119,8 @@ function I(id){return document.getElementById(id);}
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -185,19 +209,19 @@ function I(id){return document.getElementById(id);}
</head>
<body>
<h1>LibreSpeed Example</h1>
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="serverId">Selecting server...</div>
<div id="test">
<div class="testGroup">
<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">
@ -219,7 +243,7 @@ function I(id){return document.getElementById(id);}
<a href="https://github.com/librespeed/speedtest">Source code</a>
<script type="text/javascript">
initUI();
selectServer();
loadServers();
</script>
</body>
</html>

View file

@ -29,7 +29,7 @@
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>

View file

@ -250,7 +250,7 @@
<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>

View file

@ -22,6 +22,7 @@ s.onupdate=function(data){ //callback to update data in UI
}
s.onend=function(aborted){ //callback for test ended/aborted
I("startStopBtn").className=""; //show start button again
I("startStopBtn").setAttribute("aria-label","Start");
if(aborted){ //if the test was aborted, clear the UI and prepare for new test
initUI();
}
@ -35,6 +36,7 @@ function startStop(){ //start/stop button pressed
//test is not running, begin
s.start();
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
}
}
@ -66,6 +68,8 @@ function I(id){return document.getElementById(id);}
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -151,18 +155,18 @@ function I(id){return document.getElementById(id);}
</head>
<body>
<h1>LibreSpeed Example</h1>
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="test">
<div class="testGroup">
<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

@ -60,15 +60,18 @@ function startStop(){
s.abort();
data=null;
I("startStopBtn").className="";
I("startStopBtn").setAttribute("aria-label","Start");
initUI();
}else{
//test is not running, begin
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
s.onupdate=function(data){
uiData=data;
};
s.onend=function(aborted){
I("startStopBtn").className="";
I("startStopBtn").setAttribute("aria-label","Start");
updateUI(true);
};
s.start();
@ -127,6 +130,8 @@ function initUI(){
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -223,7 +228,7 @@ function initUI(){
<body>
<h1>LibreSpeed Example</h1>
<div id="testWrapper">
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="test">
<div class="testGroup">
<div class="testArea2">
@ -242,13 +247,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

@ -0,0 +1,232 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<title>LibreSpeed</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Open+Sans:wght@400;700&family=Noto+Color+Emoji&display=swap" rel="stylesheet">
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript">
//INITIALIZE SPEEDTEST
var s=new Speedtest(); //create speedtest object
s.setParameter("telemetry_level","basic"); //enable telemetry
s.onupdate=function(data){ //callback to update data in UI
I("ip").textContent=data.clientIp;
I("dlText").textContent=(data.testState==1&&data.dlStatus==0)?"...":data.dlStatus;
I("ulText").textContent=(data.testState==3&&data.ulStatus==0)?"...":data.ulStatus;
I("pingText").textContent=data.pingStatus;
I("jitText").textContent=data.jitterStatus;
}
s.onend=function(aborted){ //callback for test ended/aborted
I("startStopBtn").className=""; //show start button again
I("startStopBtn").setAttribute("aria-label","Start");
if(aborted){ //if the test was aborted, clear the UI and prepare for new test
initUI();
} else {
// Check if download speed is greater than 50 Mbit/s
var dlSpeed = parseFloat(I("dlText").textContent);
if (dlSpeed > 50) {
I("speedMessage").textContent = "📽️👍";
} else {
I("speedMessage").textContent = "🙄";
}
}
}
function startStop(){ //start/stop button pressed
if(s.getState()==3){
//speedtest is running, abort
s.abort();
}else{
//test is not running, begin
s.start();
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
}
}
//function to (re)initialize UI
function initUI(){
I("dlText").textContent="";
I("ulText").textContent="";
I("pingText").textContent="";
I("jitText").textContent="";
I("ip").textContent="";
}
function I(id){return document.getElementById(id);}
// Automatically start the test when the page loads
window.onload = function() {
startStop();
}
</script>
<style type="text/css">
html,body{
border:none; padding:0; margin:0;
background:#f4f4f9;
color:#333;
font-family:"Roboto",sans-serif;
}
body{
text-align:center;
}
h1{
color:#333;
margin-top:1em;
}
#startStopBtn{
display:inline-block;
margin:1em auto;
color:#fff;
background-color:#007bff;
border:none;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
width:10em; height:3em;
line-height:3em;
cursor:pointer;
box-shadow: 0 0 0 rgba(0,0,0,0.1), inset 0 0 0 rgba(0,0,0,0.1);
font-size:1em;
}
#startStopBtn:hover{
background-color:#0056b3;
}
#startStopBtn.running{
background-color:#dc3545;
}
#startStopBtn:before{
content:"Start";
}
#startStopBtn.running:before{
content:"Abort";
}
#test{
margin-top:2em;
margin-bottom:4em;
}
div.testArea{
display:inline-block;
width:14em;
height:9em;
position:relative;
box-sizing:border-box;
margin:1em;
background:#fff;
border-radius:0.5em;
box-shadow:0 0 10px rgba(0,0,0,0.1);
padding:1em;
}
div.testName{
position:absolute;
top:0.5em; left:0;
width:100%;
font-size:1.2em;
z-index:9;
color:#555;
}
div.meterText{
position:absolute;
bottom:1.5em; left:0;
width:100%;
font-size:2.5em;
z-index:9;
color:#007bff;
}
div.testConclusion{
position:absolute;
bottom:2em; left:0;
width:100%;
font-size:5em;
z-index:9;
color:#333;
text-shadow:0 0 10px #888;
}
#dlText{
color:#007bff;
}
#ulText{
color:#28a745;
}
#pingText,#jitText{
color:#dc3545;
}
div.meterText:empty:before{
color:#ccc !important;
content:"0.00";
}
div.unit{
position:absolute;
bottom:2em; left:0;
width:100%;
z-index:9;
color:#777;
}
div.testGroup{
display:inline-block;
}
@media all and (max-width:65em){
body{
font-size:1.5vw;
}
}
@media all and (max-width:40em){
body{
font-size:0.8em;
}
div.testGroup{
display:block;
margin: 0 auto;
}
}
</style>
</head>
<body>
<h1>LibreSpeed</h1>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="test">
<div class="testGroup">
<div class="testArea">
<div class="testName">Download</div>
<div id="dlText" class="meterText"></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">Mbit/s</div>
</div>
</div>
<div class="testGroup">
<div class="testArea">
<div class="testName">Ping</div>
<div id="pingText" class="meterText"></div>
<div class="unit">ms</div>
</div>
<div class="testArea">
<div class="testName">Jitter</div>
<div id="jitText" class="meterText"></div>
<div class="unit">ms</div>
</div>
</div>
<div id="speedMessage" class="testConclusion">
</div>
<div id="ipArea">
IP Address: <span id="ip"></span>
</div>
</div>
<a href="https://github.com/librespeed/speedtest">Source code</a>
<script type="text/javascript">
initUI();
</script>
</body>
</html>

View file

@ -19,6 +19,7 @@ s.onupdate=function(data){ //callback to update data in UI
}
s.onend=function(aborted){ //callback for test ended/aborted
I("startStopBtn").className=""; //show start button again
I("startStopBtn").setAttribute("aria-label","Start");
if(aborted){ //if the test was aborted, clear the UI and prepare for new test
initUI();
}
@ -32,6 +33,7 @@ function startStop(){ //start/stop button pressed
//test is not running, begin
s.start();
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
}
}
@ -66,6 +68,8 @@ function I(id){return document.getElementById(id);}
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -154,18 +158,18 @@ function I(id){return document.getElementById(id);}
</head>
<body>
<h1>LibreSpeed Example</h1>
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="test">
<div class="testGroup">
<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

@ -21,6 +21,7 @@ s.onupdate=function(data){ //callback to update data in UI
}
s.onend=function(aborted){ //callback for test ended/aborted
I("startStopBtn").className=""; //show start button again
I("startStopBtn").setAttribute("aria-label","Start");
if(aborted){ //if the test was aborted, clear the UI and prepare for new test
initUI();
}
@ -34,6 +35,7 @@ function startStop(){ //start/stop button pressed
//test is not running, begin
s.start();
I("startStopBtn").className="running";
I("startStopBtn").setAttribute("aria-label","Abort");
}
}
@ -68,6 +70,8 @@ function I(id){return document.getElementById(id);}
color:#6060AA;
background-color:rgba(0,0,0,0);
border:0.15em solid #6060FF;
padding:0;
font:inherit;
border-radius:0.3em;
transition:all 0.3s;
box-sizing:border-box;
@ -173,19 +177,19 @@ function I(id){return document.getElementById(id);}
</head>
<body>
<h1>LibreSpeed Example</h1>
<div id="startStopBtn" onclick="startStop()"></div>
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button>
<div id="test">
<div id="progressBar"><div id="progress"></div></div>
<div class="testGroup">
<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">

0
favicon.ico Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Before After
Before After

25
frontend/README.md Normal file
View file

@ -0,0 +1,25 @@
# LibreSpeed frontend
This directory contains the modern LibreSpeed UI assets.
## Deployment
For installation and deployment, follow the top-level [README.md](../README.md)
and [DESIGN_SWITCH.md](../DESIGN_SWITCH.md). This directory is copied as a
whole: `index-modern.html` loads its assets from `frontend/`, so the layout
here is the layout that gets served.
## Configuration
The two configuration files live at the top level rather than here, because the
page fetches them relative to itself:
- `../server-list.json` contains the default server list used by the modern UI.
- `../settings.json` overrides selected `speedtest_worker.js` settings.
- `index.html` and `../index-modern.html` show how the frontend is wired up.
## Notes
- The modern frontend expects modern browser features and does not support old
browsers.
- This directory does not contain the backend or results-sharing files.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View file

@ -0,0 +1,22 @@
<svg
width="32"
height="32"
viewBox="0 0 32 32"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clip-path="url(#clip0_373_537)">
<path
d="M26 12L16 22L6 12"
stroke="#625B6B"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
<defs>
<clipPath id="clip0_373_537">
<rect width="32" height="32" fill="white" />
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 500 B

View file

@ -0,0 +1,14 @@
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_373_731)">
<path d="M25 7L7 25" stroke="#F5F5F5" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<path d="M25 25L7 7" stroke="#F5F5F5" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
</g>
<defs>
<clipPath id="clip0_373_731">
<rect width="32" height="32" fill="white" />
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 544 B

View file

@ -0,0 +1,19 @@
<svg width="19" height="18" viewBox="0 0 19 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M16.0345 0.123047H3.20289C1.88703 0.123047 0.820312 1.18976 0.820312 2.50562V15.3373C0.820312 16.6531 1.88703 17.7198 3.20289 17.7198H16.0345C17.3504 17.7198 18.4171 16.6531 18.4171 15.3373V2.50562C18.4171 1.18976 17.3504 0.123047 16.0345 0.123047Z"
fill="#F5F5F5" />
<path
d="M17.1947 2.38135H3.55467L3.42638 9.32426L8.84467 9.49601L8.25888 9.99686L2.04297 15.4616L16.3914 15.3137V8.62233L10.1332 7.52898L17.1947 2.38135Z"
fill="url(#paint0_linear_373_542)" />
<defs>
<linearGradient id="paint0_linear_373_542" x1="2.04297" y1="8.92149" x2="17.1947"
y2="8.92149" gradientUnits="userSpaceOnUse">
<stop stop-color="#D63BC6" />
<stop offset="0.3478" stop-color="#7419B1" />
<stop offset="0.5389" stop-color="#3D06A5" />
<stop offset="0.7532" stop-color="#485DC4" />
<stop offset="1" stop-color="#5CF9FD" />
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

66
frontend/images/logo.svg Normal file
View file

@ -0,0 +1,66 @@
<svg
width="153"
height="18"
viewBox="0 0 153 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="logo"
>
<path
d="M87.0345 0.123047H74.2029C72.887 0.123047 71.8203 1.18976 71.8203 2.50562V15.3373C71.8203 16.6531 72.887 17.7198 74.2029 17.7198H87.0345C88.3504 17.7198 89.4171 16.6531 89.4171 15.3373V2.50562C89.4171 1.18976 88.3504 0.123047 87.0345 0.123047Z"
fill="#F5F5F5"
/>
<path
d="M88.1947 2.38135H74.5547L74.4264 9.32426L79.8447 9.49601L79.2589 9.99686L73.043 15.4616L87.3914 15.3137V8.62233L81.1332 7.52898L88.1947 2.38135Z"
fill="url(#paint0_linear_373_540)"
/>
<path
d="M0 17.4134V0H3.68171V14.378H11.1473V17.4134H0Z"
fill="#F5F5F5"
/>
<path d="M17.2686 0V17.4134H13.5869V0H17.2686Z" fill="#F5F5F5" />
<path
d="M20.3038 17.4134V0H27.2761C28.5572 0 29.6258 0.189989 30.4818 0.569601C31.3374 0.94958 31.9808 1.47506 32.4117 2.14682C32.8425 2.81857 33.058 3.59104 33.058 4.46387C33.058 5.14385 32.9218 5.74068 32.6497 6.25365C32.3776 6.76661 32.0048 7.18598 31.5317 7.51218C31.0582 7.83802 30.5183 8.06886 29.9118 8.20508V8.37499C30.5749 8.40366 31.1972 8.59042 31.7783 8.93633C32.3593 9.28225 32.8311 9.76544 33.1938 10.3859C33.5566 11.0068 33.7379 11.7452 33.7379 12.6008C33.7379 13.5249 33.51 14.3483 33.0536 15.0709C32.5973 15.7936 31.9242 16.365 31.0341 16.7844C30.144 17.2038 29.0475 17.4135 27.7438 17.4135L20.3038 17.4134ZM23.9855 7.28666H26.7148C27.2195 7.28666 27.6686 7.19739 28.0626 7.01889C28.4565 6.84039 28.7684 6.58661 28.9978 6.25791C29.2276 5.92921 29.3423 5.53524 29.3423 5.07609C29.3423 4.44666 29.1197 3.93942 28.6748 3.55408C28.2296 3.16874 27.5991 2.97589 26.7829 2.97589H23.9855V7.28666ZM23.9855 14.4034H26.9869C28.0127 14.4034 28.7612 14.2067 29.2319 13.8123C29.7021 13.4184 29.9373 12.8929 29.9373 12.2351C29.9373 11.7534 29.8212 11.3282 29.5889 10.9597C29.3563 10.5913 29.0261 10.3023 28.5981 10.0926C28.1701 9.88294 27.6615 9.77792 27.0722 9.77792H23.9855L23.9855 14.4034Z"
fill="#F5F5F5"
/>
<path
d="M36.127 17.4134V0H42.9971C44.3123 0 45.436 0.233706 46.3684 0.701485C47.3011 1.1689 48.0123 1.82953 48.5027 2.68232C48.993 3.5358 49.2382 4.53769 49.2382 5.68834C49.2382 6.84472 48.9887 7.83798 48.4901 8.66853C47.9911 9.4987 47.2699 10.135 46.3261 10.5773C45.3823 11.0193 44.2413 11.2404 42.9036 11.2404H38.3039V8.28139H42.3086C43.0115 8.28139 43.5955 8.18533 44.06 7.99248C44.5249 7.79963 44.8723 7.51071 45.1017 7.12501C45.3315 6.73967 45.4462 6.26077 45.4462 5.68831C45.4462 5.11011 45.3315 4.62262 45.1017 4.2258C44.8723 3.82897 44.5235 3.52717 44.0557 3.31997C43.5883 3.11313 43.0001 3.00992 42.2917 3.00992H39.8087V17.4134L36.127 17.4134ZM45.531 9.48901L49.859 17.4134H45.7945L41.5604 9.48901H45.531Z"
fill="#F5F5F5"
/>
<path
d="M51.8398 17.4134V0H63.5735V3.03539H55.5216V7.18451H62.9699V10.2203H55.5216V14.378H63.6076V17.4134L51.8398 17.4134Z"
fill="#F5F5F5"
/>
<path
d="M92.8662 17.4134V0H99.7364C101.058 0 102.182 0.250554 103.112 0.752396C104.042 1.25387 104.752 1.94857 105.242 2.83538C105.733 3.72256 105.978 4.74452 105.978 5.90091C105.978 7.05729 105.728 8.07745 105.229 8.96177C104.73 9.84609 104.009 10.5347 103.066 11.0279C102.122 11.5212 100.981 11.7677 99.6432 11.7677H95.2643V8.8173H99.0481C99.7564 8.8173 100.341 8.694 100.804 8.44737C101.266 8.20075 101.612 7.85773 101.841 7.41862C102.071 6.97914 102.185 6.47337 102.185 5.90091C102.185 5.32272 102.071 4.81658 101.841 4.38319C101.612 3.94948 101.264 3.61215 100.8 3.37129C100.335 3.13042 99.745 3.00995 99.0309 3.00995H96.5482V17.4134H92.8662Z"
fill="#F5F5F5"
/>
<path
d="M108.375 17.4134V0H120.109V3.03539H112.057V7.18451H119.505V10.2203H112.057V14.378H120.143V17.4134L108.375 17.4134Z"
fill="#F5F5F5"
/>
<path
d="M123.042 17.4134V0H134.776V3.03539H126.723V7.18451H134.172V10.2203H126.723V14.378H134.809V17.4134L123.042 17.4134Z"
fill="#F5F5F5"
/>
<path
d="M143.882 17.4134H137.709V0H143.933C145.685 0 147.192 0.34698 148.457 1.04131C149.721 1.736 150.694 2.73213 151.378 4.03012C152.06 5.32844 152.402 6.88165 152.402 8.68967C152.402 10.5035 152.06 12.0624 151.378 13.3661C150.694 14.6698 149.716 15.6702 148.444 16.3674C147.171 17.0647 145.651 17.4134 143.882 17.4134ZM141.391 14.259H143.729C144.817 14.259 145.734 14.0647 146.48 13.6765C147.225 13.2883 147.787 12.6847 148.163 11.8652C148.54 11.0465 148.729 9.98763 148.729 8.68963C148.729 7.40276 148.54 6.35143 148.163 5.53521C147.787 4.71865 147.227 4.11788 146.484 3.73254C145.741 3.34721 144.826 3.15435 143.737 3.15435H141.391L141.391 14.259Z"
fill="#F5F5F5"
/>
<defs>
<linearGradient
id="paint0_linear_373_540"
x1="73.043"
y1="8.92149"
x2="88.1947"
y2="8.92149"
gradientUnits="userSpaceOnUse"
>
<stop stop-color="#D63BC6" />
<stop offset="0.3478" stop-color="#7419B1" />
<stop offset="0.5389" stop-color="#3D06A5" />
<stop offset="0.7532" stop-color="#485DC4" />
<stop offset="1" stop-color="#5CF9FD" />
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

152
frontend/index.html Executable file
View file

@ -0,0 +1,152 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta
name="description"
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL."
/>
<link rel="shortcut icon" href="images/favicon.svg" />
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript" src="javascript/index.js"></script>
<link rel="stylesheet" type="text/css" href="styling/index.css" />
<title>LibreSpeed - Free and Open Source Speedtest</title>
</head>
<body>
<header>
<img src="images/logo.svg" alt="LibreSpeed" />
</header>
<main>
<h1>Free and Open Source Speedtest.</h1>
<p class="tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
<div class="server-selector">
<div class="chosen">
<div class="chevron">
<img src="images/chevron.svg" alt="select..." />
</div>
<p>current server</p>
<h2 id="selected-server">searching nearest server...</h2>
</div>
<ul class="servers"></ul>
<p class="sponsor" id="sponsor">&nbsp;</p>
</div>
<p id="privacy-warning" class="hidden">
by clicking the start button you agree to our privacy policy<br />
<a href="#" id="choose-privacy">or choose your privacy options</a>
</p>
<button class="disabled" id="start-button"></button>
<div class="gauge-layout">
<div class="ping hidden">
<span class="label">Ping</span>:&nbsp;
<span class="value" id="ping">00</span>ms
</div>
<div class="gauge download" id="download-gauge">
<div class="progress"></div>
<div class="speed"></div>
<h1><span id="download-speed">00</span> Mbps</h1>
<h2>Download</h2>
</div>
<div class="gauge upload" id="upload-gauge">
<div class="progress"></div>
<div class="speed"></div>
<h1><span id="upload-speed">00</span> Mbps</h1>
<h2>Upload</h2>
</div>
<div class="jitter hidden">
<span class="label">Jitter</span>:&nbsp;
<span class="value" id="jitter">00</span>ms
</div>
</div>
<button class="small inverted hidden" id="share-results">
Share results
</button>
</main>
<footer>
<p class="source">
<a href="stability.html">stability test</a> |
<a href="https://github.com/librespeed/speedtest">source code</a>
</p>
</footer>
<dialog id="share">
<div class="close-dialog">
<img src="images/close-button.svg" alt="Close" />
</div>
<img id="results" src="" alt="Test results in graphical form" />
<button id="copy-link">Copy link</button>
</dialog>
<dialog id="privacy">
<div class="close-dialog">
<img src="images/close-button.svg" alt="Close" />
</div>
<section>
<h1>Privacy Policy</h1>
<p>
This HTML5 speed test server is configured with telemetry enabled.
</p>
<h2>What data we collect</h2>
<p>
At the end of the test, the following data is collected and stored:
</p>
<ul>
<li>Test ID</li>
<li>Time of testing</li>
<li>Test results (download and upload speed, ping and jitter)</li>
<li>IP address</li>
<li>ISP information</li>
<li>Approximate location (inferred from IP address, not GPS)</li>
<li>User agent and browser locale</li>
<li>Test log (contains no personal information)</li>
</ul>
<h2>How we use the data</h2>
<p>Data collected through this service is used to:</p>
<ul>
<li>
Allow sharing of test results (sharable image for forums, etc.)
</li>
<li>
To improve the service offered to you (for instance, to detect
problems on our side)
</li>
</ul>
<p>No personal information is disclosed to third parties.</p>
<h2>Your consent</h2>
<p>
By starting the test, you consent to the terms of this privacy policy.
</p>
<h2>Data removal</h2>
<p>
If you want to have your information deleted, you need to provide
either the ID of the test or your IP address. This is the only way to
identify your data, without this information we won't be able to
comply with your request.
</p>
<p>
Contact this email address for all deletion requests:
<a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
</p>
</section>
<button id="close-privacy">Close</button>
</dialog>
</body>
</html>

View file

@ -0,0 +1,518 @@
/**
* Design by fromScratch Studio - 2022, 2023 (fromscratch.io)
* Implementation in HTML/CSS/JS by Timendus - 2024 (https://github.com/Timendus)
*
* See https://github.com/librespeed/speedtest/issues/585
*/
// States the UI can be in
const INITIALIZING = 0;
const READY = 1;
const RUNNING = 2;
const FINISHED = 3;
// Keep some global state here
const testState = {
state: INITIALIZING,
speedtest: null,
servers: [],
initialGaugeScrollPending: false,
initialGaugeScrollScheduled: false,
selectedServerDirty: false,
testData: null,
testDataDirty: false,
telemetryEnabled: false,
};
// Bootstrap the application when the DOM is ready
window.addEventListener("DOMContentLoaded", async () => {
createSpeedtest();
hookUpButtons();
startRenderingLoop();
applySettingsJSON();
applyServerListJSON();
});
/**
* Create a new Speedtest and hook it into the global state
*/
function createSpeedtest() {
testState.speedtest = new Speedtest();
testState.speedtest.onupdate = (data) => {
testState.testData = data;
testState.testDataDirty = true;
};
testState.speedtest.onend = (aborted) =>
(testState.state = aborted ? READY : FINISHED);
}
/**
* Make all the buttons respond to the right clicks
*/
function hookUpButtons() {
document
.querySelector("#start-button")
.addEventListener("click", startButtonClickHandler);
document
.querySelector("#choose-privacy")
.addEventListener("click", () =>
document.querySelector("#privacy").showModal()
);
document
.querySelector("#share-results")
.addEventListener("click", () =>
document.querySelector("#share").showModal()
);
document
.querySelector("#copy-link")
.addEventListener("click", copyLinkButtonClickHandler);
document
.querySelectorAll(".close-dialog, #close-privacy")
.forEach((element) => {
element.addEventListener("click", () =>
document.querySelectorAll("dialog").forEach((modal) => modal.close())
);
});
}
/**
* Event listener for clicks on the main start button
*/
function startButtonClickHandler() {
switch (testState.state) {
case READY:
case FINISHED:
testState.speedtest.start();
testState.initialGaugeScrollPending = true;
testState.state = RUNNING;
return;
case RUNNING:
testState.speedtest.abort();
// testState.state is updated by `onend` handler of speedtest
return;
default:
return;
}
}
/**
* Scroll the initial download gauge into view on narrow viewports when starting a test
*/
function scrollInitialDownloadGaugeIntoView() {
if (!window.matchMedia("(max-width: 800px)").matches) {
return;
}
const downloadGauge = document.querySelector("#download-gauge");
if (!downloadGauge) {
return;
}
const { top, bottom } = downloadGauge.getBoundingClientRect();
if (top >= 0 && bottom <= window.innerHeight) {
return;
}
downloadGauge.scrollIntoView({
block: "center",
inline: "nearest",
});
}
/**
* Event listener for clicks on the "Copy link" button in the modal
*/
async function copyLinkButtonClickHandler() {
const link = document.querySelector("img#results").src;
await navigator.clipboard.writeText(link);
const button = document.querySelector("#copy-link");
button.classList.add("active");
button.textContent = "Copied!";
setTimeout(() => {
button.classList.remove("active");
button.textContent = "Copy link";
}, 3000);
}
/**
* Load settings from settings.json on the server and apply them
*/
async function applySettingsJSON() {
try {
const response = await fetch("settings.json");
const settings = await response.json();
if (!settings || typeof settings !== "object") {
return console.error("Settings are empty or malformed");
}
for (let setting in settings) {
testState.speedtest.setParameter(setting, settings[setting]);
if (
setting == "telemetry_level" &&
settings[setting] &&
settings[setting] != "off" &&
settings[setting] != "disabled" &&
settings[setting] != "false"
) {
testState.telemetryEnabled = true;
document.querySelector("#privacy-warning").classList.remove("hidden");
}
}
} catch (error) {
console.error("Failed to fetch settings:", error);
}
}
/**
* Load server list from the configured source and populate the dropdown
*/
async function applyServerListJSON() {
try {
const serverSource =
typeof globalThis.SPEEDTEST_SERVERS !== "undefined"
? globalThis.SPEEDTEST_SERVERS
: "server-list.json";
const servers = Array.isArray(serverSource)
? serverSource
: await fetch(serverSource).then((response) => response.json());
if (!servers || !Array.isArray(servers) || servers.length === 0) {
return console.error("Server list is empty or malformed");
}
testState.servers = servers;
// If there's only one server, just show it. No reachability checks needed.
if (servers.length === 1) {
populateDropdown(servers);
return;
}
// For multiple servers: first run the built-in selection (which pings servers
// and annotates them with pingT). Only then populate the dropdown so that
// dead servers don't appear.
testState.speedtest.addTestPoints(servers);
testState.speedtest.selectServer((bestServer) => {
const aliveServers = testState.servers.filter((s) => {
// Keep servers that responded to ping (pingT !== -1).
if (s.pingT !== -1) return true;
// Also keep protocol-relative servers ("//...") as a defensive fallback.
// LibreSpeed normalizes them to the page protocol before pinging, so they
// are normally treated like any other server and get a real pingT value.
return typeof s.server === "string" && s.server.startsWith("//");
});
// Prefer to show only reachable servers, but if none are reachable,
// fall back to the full list so users can still pick a server manually.
if (aliveServers.length > 0) {
testState.servers = aliveServers;
}
populateDropdown(testState.servers);
if (bestServer) {
selectServer(bestServer);
} else {
alert(
"Can't reach any of the speedtest servers! But you're on this page. Something weird is going on with your network."
);
}
});
} catch (error) {
console.error("Failed to load server list:", error);
}
}
/**
* Add all the servers to the server selection dropdown and make it actually
* work.
* @param {Array} servers - an array of server objects
*/
function populateDropdown(servers) {
const serverSelector = document.querySelector("div.server-selector");
const serverList = serverSelector.querySelector("ul.servers");
// Reset previous state (populateDropdown can be called multiple times)
serverSelector.classList.remove("single-server");
serverSelector.classList.remove("active");
serverList.classList.remove("active");
serverList.innerHTML = "";
// If we have only a single server, just show it
if (servers.length === 1) {
serverSelector.classList.add("single-server");
selectServer(servers[0]);
return;
}
serverSelector.classList.add("active");
// Make the dropdown open and close (hook only once)
if (serverSelector.dataset.hooked !== "1") {
serverSelector.dataset.hooked = "1";
serverSelector.addEventListener("click", () => {
serverList.classList.toggle("active");
});
document.addEventListener("click", (e) => {
if (e.target.closest("div.server-selector") !== serverSelector)
serverList.classList.remove("active");
});
}
// Sort servers by country, then by city within the same country.
// Name formats: "City, Country", "City, Country (qualifier)", "City, Country, Provider", "Country"
const parseServerName = (name) => {
const parts = (name || "").split(",").map((s) => s.trim());
let country, city;
if (parts.length >= 3) {
// "City, Country, Provider" — use second part as country
country = parts[1];
city = parts[0];
} else if (parts.length === 2) {
country = parts[1];
city = parts[0];
} else {
country = parts[0];
city = "";
}
// Strip parenthetical qualifiers for sorting: "Germany (1) (Hetzner)" → "Germany"
country = country.replace(/\s*\([^)]*\)\s*/g, "").trim();
return { country, city };
};
const sorted = [...servers].sort((a, b) => {
const pa = parseServerName(a.name);
const pb = parseServerName(b.name);
return pa.country.localeCompare(pb.country) || pa.city.localeCompare(pb.city);
});
// Populate the list to choose from
sorted.forEach((server) => {
const item = document.createElement("li");
const link = document.createElement("a");
link.href = "#";
link.innerHTML = `${server.name}${
server.sponsorName ? ` <span>(${server.sponsorName})</span>` : ""
}`;
link.addEventListener("click", () => selectServer(server));
item.appendChild(link);
serverList.appendChild(item);
});
}
/**
* Set the given server as the selected server for the speedtest
* @param {Object} server - a server object
*/
function selectServer(server) {
testState.speedtest.setSelectedServer(server);
testState.selectedServerDirty = true;
testState.state = READY;
}
/**
* Start the requestAnimationFrame UI rendering loop
*/
function startRenderingLoop() {
// Do these queries once to speed up the rendering itself
const serverSelector = document.querySelector("div.server-selector");
const selectedServer = serverSelector.querySelector("#selected-server");
const sponsor = serverSelector.querySelector("#sponsor");
const startButton = document.querySelector("#start-button");
const privacyWarning = document.querySelector("#privacy-warning");
const gauges = document.querySelectorAll("#download-gauge, #upload-gauge");
const downloadProgress = document.querySelector("#download-gauge .progress");
const uploadProgress = document.querySelector("#upload-gauge .progress");
const downloadGauge = document.querySelector("#download-gauge .speed");
const uploadGauge = document.querySelector("#upload-gauge .speed");
const downloadText = document.querySelector("#download-gauge span");
const uploadText = document.querySelector("#upload-gauge span");
const pingAndJitter = document.querySelectorAll(".ping, .jitter");
const ping = document.querySelector("#ping");
const jitter = document.querySelector("#jitter");
const shareResults = document.querySelector("#share-results");
const copyLink = document.querySelector("#copy-link");
const resultsImage = document.querySelector("#results");
const buttonTexts = {
[INITIALIZING]: "Loading...",
[READY]: "Let's start",
[RUNNING]: "Abort",
[FINISHED]: "Restart",
};
// Show copy link button only if navigator.clipboard is available
copyLink.classList.toggle("hidden", !navigator.clipboard);
function renderUI() {
// Make the main button reflect the current state
startButton.textContent = buttonTexts[testState.state];
startButton.classList.toggle("disabled", testState.state === INITIALIZING);
startButton.classList.toggle("active", testState.state === RUNNING);
// Disable the server selector while test is running
serverSelector.classList.toggle("disabled", testState.state === RUNNING);
// Show selected server
if (testState.selectedServerDirty) {
const server = testState.speedtest.getSelectedServer();
selectedServer.textContent = server.name;
if (server.sponsorName) {
if (server.sponsorURL) {
sponsor.innerHTML = `Sponsor: <a href="${server.sponsorURL}">${server.sponsorName}</a>`;
} else {
sponsor.textContent = `Sponsor: ${server.sponsorName}`;
}
} else {
sponsor.innerHTML = "&nbsp;";
}
testState.selectedServerDirty = false;
}
// Activate the gauges when test running or finished
gauges.forEach((e) =>
e.classList.toggle(
"enabled",
testState.state === RUNNING || testState.state === FINISHED
)
);
if (
testState.state === RUNNING &&
testState.initialGaugeScrollPending &&
!testState.initialGaugeScrollScheduled
) {
testState.initialGaugeScrollScheduled = true;
requestAnimationFrame(() => {
if (testState.state === RUNNING) {
scrollInitialDownloadGaugeIntoView();
}
testState.initialGaugeScrollPending = false;
testState.initialGaugeScrollScheduled = false;
});
}
// Show ping and jitter if data is available
pingAndJitter.forEach((e) =>
e.classList.toggle(
"hidden",
!(
testState.testData &&
testState.testData.pingStatus &&
testState.testData.jitterStatus
)
)
);
// Show share button after test if server supports it
shareResults.classList.toggle(
"hidden",
!(
testState.state === FINISHED &&
testState.telemetryEnabled &&
testState.testData.testId
)
);
if (testState.testDataDirty) {
// Set gauge rotations
downloadProgress.style = `--progress-rotation: ${
testState.testData.dlProgress * 180
}deg`;
uploadProgress.style = `--progress-rotation: ${
testState.testData.ulProgress * 180
}deg`;
downloadGauge.style = `--speed-rotation: ${mbpsToRotation(
testState.testData.dlStatus,
testState.testData.testState === 1
)}deg`;
uploadGauge.style = `--speed-rotation: ${mbpsToRotation(
testState.testData.ulStatus,
testState.testData.testState === 3
)}deg`;
// Set numeric values
downloadText.textContent = numberToText(testState.testData.dlStatus);
uploadText.textContent = numberToText(testState.testData.ulStatus);
ping.textContent = numberToText(testState.testData.pingStatus);
jitter.textContent = numberToText(testState.testData.jitterStatus);
// Set user's IP and provider
if (testState.testData.clientIp) {
// Clear previous content
privacyWarning.innerHTML = '';
const connectedThrough = document.createElement('span');
connectedThrough.textContent = 'You are connected through:';
const ipAddress = document.createTextNode(testState.testData.clientIp);
privacyWarning.appendChild(connectedThrough);
privacyWarning.appendChild(document.createElement('br'));
privacyWarning.appendChild(ipAddress);
privacyWarning.classList.remove("hidden");
}
// Set image for sharing results
if (testState.testData.testId) {
resultsImage.src =
window.location.href.substring(
0,
window.location.href.lastIndexOf("/")
) +
"/results/?id=" +
testState.testData.testId +
// Ask for the design this frontend matches; the classic frontend
// links the same URL and gets the classic image without asking.
"&style=modern";
}
testState.testDataDirty = false;
}
requestAnimationFrame(renderUI);
}
renderUI();
}
/**
* Convert a speed in Mbits per second to a rotation for the gauge
* @param {string} speed Speed in Mbits
* @param {boolean} oscillate If the gauge should wiggle a bit
* @returns {number} Rotation for the gauge in degrees
*/
function mbpsToRotation(speed, oscillate) {
speed = Number(speed);
if (speed <= 0) return 0;
const minSpeed = 0;
const maxSpeed = 10000; // 10 Gbps maxes out the gauge
const minRotation = 0;
const maxRotation = 180;
// Can't do log10 of values less than one, +1 all to keep it fair
const logMinSpeed = Math.log10(minSpeed + 1);
const logMaxSpeed = Math.log10(maxSpeed + 1);
const logSpeed = Math.log10(speed + 1);
const power = (logSpeed - logMinSpeed) / (logMaxSpeed - logMinSpeed);
const oscillation = oscillate ? 1 + 0.01 * Math.sin(Date.now() / 100) : 1;
const rotation = power * oscillation * maxRotation;
// Make sure we stay within bounds at all times
return Math.max(Math.min(rotation, maxRotation), minRotation);
}
/**
* Convert a number to a user friendly version
* @param {string} value Speed, ping or jitter
* @returns {string} A text version with proper decimals
*/
function numberToText(value) {
if (!value) return "00";
value = Number(value);
if (value < 10) return value.toFixed(2);
if (value < 100) return value.toFixed(1);
return value.toFixed(0);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,000 KiB

View file

@ -0,0 +1,83 @@
/* The main "start the test" button and the share button */
button {
height: 6.8rem;
min-width: 26.4rem;
padding: 0 5rem;
margin: 2.5rem;
border-radius: 3.4rem;
border: 0;
font-family: "Inter", sans-serif;
font-size: 2rem;
font-weight: 700;
letter-spacing: -0.1rem;
color: var(--button-text-color);
text-transform: uppercase;
cursor: pointer;
box-shadow: 0 0.4rem 1.6rem 0 var(--button-shadow-color);
will-change: transform;
backface-visibility: hidden;
transform: scale(1) translate3d(0, 0, 0) perspective(1px);
background: var(--button-gradient-1-color-1);
transition: background-position 0.2s, transform 0.2s;
background-position: 0% 0%;
background: linear-gradient(
92.97deg,
var(--button-gradient-1-color-1) 0%,
var(--button-gradient-1-color-1) 33%,
var(--button-gradient-1-color-2) 40%,
var(--button-gradient-1-color-3) 66.71%,
var(--button-gradient-1-color-3) 100%
);
background-size: 300% 100%;
&.disabled {
cursor: default;
transform: scale(1) translate3d(0, 0, 0) perspective(1px);
background: var(--button-disabled-background-color);
}
&.small {
height: 4.7rem;
min-width: 20.2rem;
text-transform: lowercase;
}
&.inverted {
border: 1px solid var(--button-gradient-1-color-1);
color: transparent;
background-clip: text;
}
&.hidden {
opacity: 0;
pointer-events: none;
}
&:hover {
background-position: 60% 0%;
transform: scale(1.03) translate3d(0, 0, 0) perspective(1px);
}
&.active,
&:active {
background-position: 100% 0%;
animation: pulse 0.7s;
}
}
@keyframes pulse {
0% {
transform: scale(1.03) translate3d(0, 0, 0) perspective(1px);
}
20% {
transform: scale(1.2) translate3d(0, 0, 0) perspective(1px);
}
40% {
transform: scale(1) translate3d(0, 0, 0) perspective(1px);
}
60% {
transform: scale(1.1) translate3d(0, 0, 0) perspective(1px);
}
100% {
transform: scale(1) translate3d(0, 0, 0) perspective(1px);
}
}

View file

@ -0,0 +1,36 @@
:root {
--theme-green: #5cf9fd;
--theme-pink: #d63bc6;
--background-backup-color: #0e0720;
--background-overlay-color: rgb(41 26 70 / 71%);
--primary-text-color: #ffffff;
--tagline-text-color: var(--theme-green);
--secondary-text-color: #898591;
--primary-text-disabled-color: #888888;
--secondary-text-disabled-color: #2e7d7f;
--button-text-color: #3e2f50;
--button-gradient-1-color-1: #f5f5f5;
--button-gradient-1-color-2: var(--theme-green);
--button-gradient-1-color-3: var(--theme-pink);
--button-shadow-color: #5cf9fd47;
--button-disabled-background-color: #a2a2a2;
--server-selector-border-color: #625b6b;
--server-selector-hover-border-color: var(--theme-green);
--server-selector-background-color: #251b32;
--server-selector-hover-background-color: var(--server-selector-border-color);
--gauge-background-color: #3e2f50;
--gauge-progress-color: #726c7a;
--gauge-pointer-green: #e2fbfc;
--gauge-pointer-pink: #d091ca;
--ping-and-jitter-primary-text-color: #f5f5f5;
--ping-and-jitter-secondary-text-color: #7b7b7b;
--popup-background-color: #251b32;
--popup-shadow-color: #000000;
}

139
frontend/styling/dialog.css Normal file
View file

@ -0,0 +1,139 @@
/* Styling for the popups */
dialog {
flex-direction: column;
align-items: center;
justify-content: center;
width: 70vw;
height: 70vh;
margin: auto;
margin-top: 23rem;
background: var(--popup-background-color);
border: none;
border-radius: 0.8rem;
@media screen and (max-width: 800px) {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
max-width: 100vw; /* We need these overrides of browser defaults*/
max-height: 100vh;
width: auto;
height: auto;
margin: 0;
}
animation: fade-out 0.3s ease-out;
&[open] {
display: flex;
animation: fade-in 0.3s ease-out;
}
& > #results {
max-width: 100%;
max-height: calc(100% - 8rem);
height: auto;
object-fit: contain;
}
& > .close-dialog {
display: flex;
align-items: center;
justify-content: center;
width: 4rem;
height: 4rem;
position: absolute;
top: 3rem;
right: 3rem;
cursor: pointer;
}
& > section {
max-width: 800px;
overflow-y: auto;
margin: 4rem 2rem 2rem 4rem;
padding: 0 2rem 0 0;
& h1,
& h2 {
margin: 3rem 0 2rem 0;
font-size: 3.6rem;
font-weight: 400;
letter-spacing: -0.2rem;
color: var(--primary-text-color);
}
& h2 {
margin: 2rem 0 1rem 0;
font-size: 2.5rem;
}
& p,
& li {
margin: 1rem 0 1rem 0;
font-size: 1.6rem;
line-height: 2.5rem;
font-weight: 400;
letter-spacing: -0.1rem;
color: var(--secondary-text-color);
}
& ul {
list-style-position: inside;
margin: 1rem;
& li {
margin: 0.1rem 0;
}
}
& a {
font-size: 1.6rem;
font-weight: 700;
letter-spacing: -0.1rem;
color: var(--secondary-text-color);
text-underline-offset: 0.3rem;
transition: text-underline-offset 0.2s;
&:hover {
color: var(--theme-green);
text-underline-offset: 0.5rem;
}
}
}
}
@keyframes fade-in {
0% {
opacity: 0;
transform: scale(0.6);
display: none;
}
0.1% {
display: flex;
}
100% {
opacity: 1;
transform: scale(1);
display: flex;
}
}
@keyframes fade-out {
0% {
opacity: 1;
transform: scale(1);
display: flex;
}
99.9% {
display: flex;
}
100% {
opacity: 0;
transform: scale(0.6);
display: none;
}
}

View file

@ -0,0 +1,22 @@
/* latin-ext */
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url(../fonts/Inter-latin-ext.woff2) format("woff2");
unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF,
U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: "Inter";
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url(../fonts/Inter-latin.woff2) format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

View file

@ -0,0 +1,85 @@
/**
* Design by fromScratch Studio - 2022, 2023 (fromscratch.io)
* Implementation in HTML/CSS/JS by Timendus - 2024 (https://github.com/Timendus)
*
* See https://github.com/librespeed/speedtest/issues/585
*/
@import url("colors.css");
@import url("fonts.css");
@import url("main.css");
@import url("server-selector.css");
@import url("button.css");
@import url("results.css");
@import url("dialog.css");
/* Setting up the basic structure */
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
min-height: 100vh;
width: 100vw;
}
html {
background-color: var(--background-backup-color);
background-image: url("../images/background.jpeg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
font-size: 10px;
@media screen and (max-width: 800px) {
font-size: 8px;
}
}
body {
font-family: "Inter", sans-serif;
background-color: var(--background-overlay-color);
color: var(--primary-text-color);
display: flex;
flex-direction: column;
}
/* Position the logo */
header {
padding: 4rem 7rem;
@media screen and (max-width: 800px) {
padding: 7rem 2rem;
text-align: center;
}
}
/* Position the source code link */
footer {
margin: auto auto 0 auto;
padding: 5rem;
& > p.source a {
font-size: 1.6rem;
font-weight: 700;
letter-spacing: -0.1rem;
color: var(--theme-green);
text-underline-offset: 0.3rem;
transition: text-underline-offset 0.2s;
&:hover {
color: var(--theme-pink);
text-underline-offset: 0.5rem;
}
}
@media screen and (max-width: 800px) {
padding: 4rem;
}
}

58
frontend/styling/main.css Normal file
View file

@ -0,0 +1,58 @@
/* Texts on the front page */
main {
text-align: center;
padding: 0 2rem;
flex: 1;
& > h1 {
margin: 0.2rem;
font-size: 3.6rem;
font-weight: 400;
letter-spacing: -0.2rem;
color: var(--primary-text-color);
}
& p {
margin-top: 8rem;
font-size: 1.6rem;
line-height: 2.5rem;
font-weight: 400;
letter-spacing: -0.1rem;
color: var(--secondary-text-color);
&#privacy-warning {
min-height: 5.3rem;
& > span {
font-weight: 700;
color: var(--theme-green);
}
&.hidden {
opacity: 0;
pointer-events: none;
}
}
}
& > p.tagline {
margin-top: 0;
margin-bottom: 6rem;
font-size: 2rem;
color: var(--tagline-text-color);
}
& a {
font-size: 1.6rem;
font-weight: 700;
letter-spacing: -0.1rem;
color: var(--secondary-text-color);
text-underline-offset: 0.3rem;
transition: text-underline-offset 0.2s;
&:hover {
color: var(--theme-green);
text-underline-offset: 0.5rem;
}
}
}

View file

@ -0,0 +1,260 @@
/* Variables */
:root {
--gauge-width: 32rem;
--gauge-height: 22rem;
--progress-width: 0.6rem;
--speed-width: 3rem;
}
/* Layout for the gauges */
.gauge-layout {
display: flex;
flex-direction: row;
align-items: start;
justify-content: center;
gap: 5rem;
margin: 5rem auto 3rem auto;
@media screen and (max-width: 1100px) {
display: grid;
grid-template-areas:
"download upload"
"ping jitter";
justify-items: center;
justify-content: center;
--gauge-width: min(40vw, 32rem);
--gauge-height: min(28vw, 22rem);
--progress-width: min(1.2vw, 0.6rem);
--speed-width: min(4vw, 3rem);
}
@media screen and (max-width: 500px) {
gap: 5rem 2rem;
}
}
/* The download/upload speed gauges */
/**
* One thing I should really document here is the weird `transform: scale(1);`
* and `position: fixed` in this code. This is a nasty little trick to allow the
* gauge pointer to break out of the `overflow: hidden` of the .speed element.
* We need the `overflow: hidden` to hide the arc that's rotating into view when
* the value goes up. But we do want to see the full pointer, even when it's at
* zero. This degrades fairly gracefully into showing half of the pointer when
* browsers don't understand this.
*
* Trick taken from this article:
* https://medium.com/@thomas.ryu/css-overriding-the-parents-overflow-hidden-90c75a0e7296
*/
div.gauge {
position: relative;
transform: scale(1);
width: var(--gauge-width);
height: var(--gauge-height);
&.download {
grid-area: download;
}
&.upload {
grid-area: upload;
}
& > .progress,
& > .speed {
position: absolute;
top: 0;
left: 0;
width: var(--gauge-width);
height: calc(var(--gauge-width) / 2);
overflow: hidden;
&:after,
&:before {
content: "";
position: absolute;
box-sizing: border-box;
}
}
& > .progress {
&:before,
&:after {
top: 0;
left: 0;
width: var(--gauge-width);
height: calc(var(--gauge-width) / 2);
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
border: var(--progress-width) solid var(--gauge-background-color);
border-bottom: 0;
transform-origin: bottom center;
transform: rotate(var(--progress-rotation));
transition: transform 0.2s linear;
}
&:after {
top: calc(var(--gauge-width) / 2);
border-radius: 0 0 50% 50% / 0 0 100% 100%;
border: var(--progress-width) solid var(--gauge-background-color);
border-top: 0;
transform-origin: top center;
}
}
& > .speed {
&:before,
&:after {
transform: rotate(var(--speed-rotation));
transition: transform 0.2s ease;
transition-timing-function: cubic-bezier(0.56, 0.04, 0.59, 0.91);
}
&:before {
position: fixed;
top: calc(var(--gauge-width) / 2 - var(--speed-width) / 3);
left: var(--progress-width);
width: 0;
height: 0;
border-top: calc(var(--speed-width) / 3) solid transparent;
border-bottom: calc(var(--speed-width) / 3) solid transparent;
border-right: calc(var(--speed-width) * 0.97) solid
var(--gauge-background-color);
z-index: 1;
transform-origin: calc(var(--gauge-width) / 2 - var(--progress-width))
calc(var(--speed-width) / 3);
}
&:after {
top: calc(var(--gauge-width) / 2);
left: calc(var(--progress-width) - 0.1rem);
width: calc(var(--gauge-width) - var(--progress-width) * 2 + 0.2rem);
height: calc(var(--gauge-width) / 2 - var(--progress-width) + 0.1rem);
border-radius: 0 0 50% 50% / 0 0 100% 100%;
border: var(--speed-width) solid var(--gauge-background-color);
border-top: 0;
transform-origin: top center;
}
}
&.enabled {
&.download {
& > .progress:after {
border-color: var(--theme-pink);
}
& > .speed {
&:before {
border-right-color: var(--gauge-pointer-pink);
}
&:after {
border-color: var(--theme-pink);
}
}
}
&.upload {
& > .progress:after {
border-color: var(--theme-green);
}
& > .speed {
&:before {
border-right-color: var(--gauge-pointer-green);
}
&:after {
border-color: var(--theme-green);
}
}
}
& > h1 > span {
color: var(--primary-text-color);
}
}
& > h1,
& > h2 {
display: block;
position: absolute;
width: 100%;
font-family: "Inter", sans-serif;
font-size: 2.1rem;
letter-spacing: -0.1rem;
color: var(--secondary-text-color);
}
& > h1 {
bottom: calc(var(--gauge-height) - var(--gauge-width) / 2);
font-weight: 300;
& > span {
font-size: 5.5rem;
font-weight: 200;
display: block;
color: var(--secondary-text-color);
letter-spacing: -0.3rem;
}
}
& > h2 {
bottom: 0;
font-weight: 700;
text-transform: uppercase;
}
@media screen and (max-width: 500px) {
& > h1 {
font-size: 3vw;
& > span {
font-size: 8vw;
}
}
& > h2 {
font-size: 3vw;
}
}
}
/* Styling for Ping and Jitter */
.ping,
.jitter {
grid-area: jitter;
display: flex;
align-items: end;
height: calc(var(--gauge-width) / 2);
width: 13rem;
font-size: 2.1rem;
letter-spacing: -0.1rem;
font-weight: 300;
color: var(--ping-and-jitter-secondary-text-color);
& > .label {
font-weight: 700;
}
& > .value {
color: var(--ping-and-jitter-primary-text-color);
}
&.hidden {
display: none;
}
@media screen and (max-width: 1100px) {
width: 100%;
height: auto;
justify-content: center !important;
}
@media screen and (max-width: 500px) {
font-size: 1.8rem;
}
}
.ping {
grid-area: ping;
justify-content: end;
}

View file

@ -0,0 +1,171 @@
/* The server selector fake dropdown */
.server-selector {
position: relative;
width: 50rem;
margin: 0rem auto;
display: none;
&.active {
display: block;
}
@media screen and (max-width: 500px) {
width: 100%;
}
& > .chosen {
position: relative;
height: 8.8rem;
border: 1px solid var(--server-selector-border-color);
border-radius: 0.8rem;
background-color: var(--server-selector-background-color);
cursor: pointer;
transition: border-color 0.2s;
&:hover {
border-color: var(--server-selector-hover-border-color);
}
& > div.chevron {
content: "";
position: absolute;
display: block;
width: 32px;
height: 32px;
right: 1.8rem;
top: 1rem;
}
& > p {
margin: 0;
position: absolute;
left: 2.4rem;
top: 1.5rem;
font-size: 1.6rem;
font-weight: 400;
letter-spacing: -0.1rem;
color: var(--theme-green);
}
& > h2 {
position: absolute;
left: 2.4rem;
right: 2.4rem;
bottom: 1rem;
font-size: 2.4rem;
font-weight: 700;
letter-spacing: -0.2rem;
color: var(--primary-text-color);
text-align: left;
text-transform: uppercase;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
& span {
font-weight: 400;
}
}
}
/* Special case for when we have only one server */
&.single-server {
& > .chosen {
cursor: default;
&:hover {
border-color: var(--server-selector-border-color);
}
& > div.chevron {
display: none;
}
}
}
/* Overrides for when the test is running and the selector is disabled */
&.disabled {
pointer-events: none;
& > .chosen {
cursor: default;
&:hover {
border-color: var(--server-selector-border-color);
}
& > p {
color: var(--secondary-text-disabled-color);
}
& > h2 {
color: var(--primary-text-disabled-color);
}
}
}
/* Styling for the list of servers that pops out */
& > ul.servers {
position: absolute;
width: 50rem;
max-height: 70vh;
overflow-y: auto;
z-index: 1;
border: 1px solid var(--server-selector-border-color);
border-radius: 0.8rem;
background-color: var(--server-selector-background-color);
list-style: none;
transform: scaleY(0);
transform-origin: top;
transition: transform 0.1s;
&.active {
transform: scaleY(1);
}
@media screen and (max-width: 800px) {
width: 100%;
}
& > li {
&:first-child a {
padding-top: 1.5rem;
}
&:last-child a {
padding-bottom: 1.5rem;
}
& a {
display: block;
padding: 0.7rem 2.4rem;
font-size: 2.4rem;
font-weight: 700;
letter-spacing: -0.2rem;
color: var(--sprint-text-color);
text-transform: uppercase;
text-decoration: none;
text-align: left;
cursor: pointer;
transition: background-color 0.2s;
& span {
font-weight: 400;
}
&:hover {
background-color: var(--server-selector-hover-background-color);
}
}
}
}
/* Styling for the sponsor text under the dropdown */
& > p.sponsor {
margin: 1rem 0 5rem 0;
& a {
font-weight: 400;
}
}
}

BIN
images/icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

621
index-classic.html Normal file
View file

@ -0,0 +1,621 @@
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="favicon.ico">
<link rel="manifest" href="manifest.webmanifest">
<link rel="apple-touch-icon" href="images/icon-192.png">
<meta name="theme-color" content="#000000">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<meta charset="UTF-8" />
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript">
function I(i) { return document.getElementById(i); }
//LIST OF TEST SERVERS. Leave empty if you're doing a standalone installation. See documentation for details
var SPEEDTEST_SERVERS = [
/*{ //this server doesn't actually exist, remove it
name:"Example Server 1", //user friendly name for the server
server:"//test1.mydomain.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"backend/garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"backend/empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"backend/empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"backend/getIP.php" //path to getIP on this server (getIP.php or replacement)
},
{ //this server doesn't actually exist, remove it
name:"Example Server 2", //user friendly name for the server
server:"//test2.example.com/", //URL to the server. // at the beginning will be replaced with http:// or https:// automatically
dlURL:"garbage.php", //path to download test on this server (garbage.php or replacement)
ulURL:"empty.php", //path to upload test on this server (empty.php or replacement)
pingURL:"empty.php", //path to ping/jitter test on this server (empty.php or replacement)
getIpURL:"getIP.php" //path to getIP on this server (getIP.php or replacement)
}*/
//add other servers here, comma separated
];
//INITIALIZE SPEEDTEST
var s = new Speedtest(); //create speed test object
s.setParameter("telemetry_level", "basic"); //enable basic telemetry (for results sharing)
//SERVER AUTO SELECTION
function initServers() {
if (SPEEDTEST_SERVERS.length == 0) { //standalone installation
//just make the UI visible
I("loading").className = "hidden";
I("serverArea").style.display = "none";
I("testWrapper").className = "visible";
initUI();
} else { //multiple servers
var noServersAvailable = function () {
I("message").innerHTML = "No servers available";
}
var runServerSelect = function () {
s.selectServer(function (server) {
if (server != null) { //at least 1 server is available
I("loading").className = "hidden"; //hide loading message
//sort servers by country, then by city
//name formats: "City, Country", "City, Country (qualifier)", "City, Country, Provider", "Country"
function parseServerName(name) {
var parts = (name || "").split(",");
for (var p = 0; p < parts.length; p++) parts[p] = parts[p].trim();
var country, city;
if (parts.length >= 3) {
country = parts[1];
city = parts[0];
} else if (parts.length === 2) {
country = parts[1];
city = parts[0];
} else {
country = parts[0];
city = "";
}
country = country.replace(/\s*\([^)]*\)\s*/g, "").trim();
return { country: country, city: city };
}
var indexed = [];
for (var j = 0; j < SPEEDTEST_SERVERS.length; j++) {
indexed.push({ idx: j, server: SPEEDTEST_SERVERS[j] });
}
indexed.sort(function (a, b) {
var pa = parseServerName(a.server.name);
var pb = parseServerName(b.server.name);
return pa.country.localeCompare(pb.country) || pa.city.localeCompare(pb.city);
});
//populate server list for manual selection
for (var i = 0; i < indexed.length; i++) {
if (indexed[i].server.pingT == -1) continue;
var option = document.createElement("option");
option.value = indexed[i].idx;
option.textContent = indexed[i].server.name;
if (indexed[i].server === server) option.selected = true;
I("server").appendChild(option);
}
//show test UI
I("testWrapper").className = "visible";
initUI();
} else { //no servers are available, the test cannot proceed
noServersAvailable();
}
});
}
if (typeof SPEEDTEST_SERVERS === "string") {
//need to fetch list of servers from specified URL
s.loadServerList(SPEEDTEST_SERVERS, function (servers) {
if (servers == null) { //failed to load server list
noServersAvailable();
} else { //server list loaded
SPEEDTEST_SERVERS = servers;
runServerSelect();
}
});
} else {
//hardcoded server list
s.addTestPoints(SPEEDTEST_SERVERS);
runServerSelect();
}
}
}
var meterBk = /Trident.*rv:(\d+\.\d+)/i.test(navigator.userAgent) ? "#EAEAEA" : "#80808040";
var dlColor = "#6060AA",
ulColor = "#616161";
var progColor = meterBk;
//CODE FOR GAUGES
function drawMeter(c, amount, bk, fg, progress, prog) {
var ctx = c.getContext("2d");
var dp = window.devicePixelRatio || 1;
var cw = c.clientWidth * dp, ch = c.clientHeight * dp;
var sizScale = ch * 0.0055;
if (c.width == cw && c.height == ch) {
ctx.clearRect(0, 0, cw, ch);
} else {
c.width = cw;
c.height = ch;
}
ctx.beginPath();
ctx.strokeStyle = bk;
ctx.lineWidth = 12 * sizScale;
ctx.arc(c.width / 2, c.height - 58 * sizScale, c.height / 1.8 - ctx.lineWidth, -Math.PI * 1.1, Math.PI * 0.1);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = fg;
ctx.lineWidth = 12 * sizScale;
ctx.arc(c.width / 2, c.height - 58 * sizScale, c.height / 1.8 - ctx.lineWidth, -Math.PI * 1.1, amount * Math.PI * 1.2 - Math.PI * 1.1);
ctx.stroke();
if (typeof progress !== "undefined") {
ctx.fillStyle = prog;
ctx.fillRect(c.width * 0.3, c.height - 16 * sizScale, c.width * 0.4 * progress, 4 * sizScale);
}
}
function mbpsToAmount(s) {
return 1 - (1 / (Math.pow(1.3, Math.sqrt(s))));
}
function format(d) {
d = Number(d);
if (d < 10) return d.toFixed(2);
if (d < 100) return d.toFixed(1);
return d.toFixed(0);
}
//UI CODE
var uiData = null;
function startStop() {
if (s.getState() == 3) {
//speed test is running, abort
s.abort();
data = null;
I("startStopBtn").className = "";
I("startStopBtn").setAttribute("aria-label", "Start");
I("server").disabled = false;
initUI();
} else {
//test is not running, begin
I("startStopBtn").className = "running";
I("startStopBtn").setAttribute("aria-label", "Abort");
I("shareArea").style.display = "none";
I("server").disabled = true;
s.onupdate = function (data) {
uiData = data;
};
s.onend = function (aborted) {
I("startStopBtn").className = "";
I("startStopBtn").setAttribute("aria-label", "Start");
I("server").disabled = false;
updateUI(true);
if (!aborted) {
//if testId is present, show sharing panel, otherwise do nothing
try {
var testId = uiData.testId;
if (testId != null) {
var shareURL = window.location.href.substring(0, window.location.href.lastIndexOf("/")) + "/results/?id=" + testId + "&style=classic";
I("resultsImg").src = shareURL;
I("resultsURL").value = shareURL;
I("testId").innerHTML = testId;
I("shareArea").style.display = "";
}
} catch (e) { }
}
};
s.start();
}
}
//this function reads the data sent back by the test and updates the UI
function updateUI(forced) {
if (!forced && s.getState() != 3) return;
if (uiData == null) return;
var status = uiData.testState;
I("ip").textContent = uiData.clientIp;
I("dlText").textContent = (status == 1 && uiData.dlStatus == 0) ? "..." : format(uiData.dlStatus);
drawMeter(I("dlMeter"), mbpsToAmount(Number(uiData.dlStatus * (status == 1 ? oscillate() : 1))), meterBk, dlColor, Number(uiData.dlProgress), progColor);
I("ulText").textContent = (status == 3 && uiData.ulStatus == 0) ? "..." : format(uiData.ulStatus);
drawMeter(I("ulMeter"), mbpsToAmount(Number(uiData.ulStatus * (status == 3 ? oscillate() : 1))), meterBk, ulColor, Number(uiData.ulProgress), progColor);
I("pingText").textContent = format(uiData.pingStatus);
I("jitText").textContent = format(uiData.jitterStatus);
}
function oscillate() {
return 1 + 0.02 * Math.sin(Date.now() / 100);
}
//update the UI every frame
window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || (function (callback, element) { setTimeout(callback, 1000 / 60); });
function frame() {
requestAnimationFrame(frame);
updateUI();
}
frame(); //start frame loop
//function to (re)initialize UI
function initUI() {
drawMeter(I("dlMeter"), 0, meterBk, dlColor, 0);
drawMeter(I("ulMeter"), 0, meterBk, ulColor, 0);
I("dlText").textContent = "";
I("ulText").textContent = "";
I("pingText").textContent = "";
I("jitText").textContent = "";
I("ip").textContent = "";
}
</script>
<style type="text/css">
html,
body {
border: none;
padding: 0;
margin: 0;
background: #FFFFFF;
color: #202020;
}
body {
text-align: center;
font-family: "Roboto", sans-serif;
}
h1 {
color: #404040;
}
#loading {
background-color: #FFFFFF;
color: #404040;
text-align: center;
}
span.loadCircle {
display: inline-block;
width: 2em;
height: 2em;
vertical-align: middle;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAAP1BMVEUAAAB2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZyFzwnAAAAFHRSTlMAEvRFvX406baecwbf0casimhSHyiwmqgAAADpSURBVHja7dbJbQMxAENRahnN5lkc//5rDRAkDeRgHszXgACJoKiIiIiIiIiIiIiIiIiIiIj4HHspsrpAVhdVVguzrA4OWc10WcEqpwKbnBo0OU1Q5NSpsoJFTgOecrrdEag85DRgktNqfoEdTjnd7hrEHMEJvmRUYJbTYk5Agy6nau6Abp5Cm7mDBtRdPi9gyKdU7w4p1fsLvyqs8hl4z9/w3n/Hmr9WoQ65lAU4d7lMYOz//QboRR5jBZibLMZdAR6O/Vfa1PlxNr3XdS3HzK/HVPRu/KnLs8iAOh993VpRRERERMT/fAN60wwWaVyWwAAAAABJRU5ErkJggg==');
background-size: 2em 2em;
margin-right: 0.5em;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
#startStopBtn {
display: inline-block;
margin: 0 auto;
color: #6060AA;
background-color: rgba(0, 0, 0, 0);
border: 0.15em solid #6060FF;
padding: 0;
font: inherit;
border-radius: 0.3em;
transition: all 0.3s;
box-sizing: border-box;
width: 8em;
height: 3em;
line-height: 2.7em;
cursor: pointer;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.1), inset 0 0 0 rgba(0, 0, 0, 0.1);
}
#startStopBtn:hover {
box-shadow: 0 0 2em rgba(0, 0, 0, 0.1), inset 0 0 1em rgba(0, 0, 0, 0.1);
}
#startStopBtn.running {
background-color: #FF3030;
border-color: #FF6060;
color: #FFFFFF;
}
#startStopBtn:before {
content: "Start";
}
#startStopBtn.running:before {
content: "Abort";
}
#serverArea {
margin-top: 1em;
}
#server {
font-size: 1em;
padding: 0.2em;
}
#test {
margin-top: 2em;
margin-bottom: 12em;
}
div.testArea {
display: inline-block;
width: 16em;
height: 12.5em;
position: relative;
box-sizing: border-box;
}
div.testArea2 {
display: inline-block;
width: 14em;
height: 7em;
position: relative;
box-sizing: border-box;
text-align: center;
}
div.testArea div.testName {
position: absolute;
top: 0.1em;
left: 0;
width: 100%;
font-size: 1.4em;
z-index: 9;
}
div.testArea2 div.testName {
display: block;
text-align: center;
font-size: 1.4em;
}
div.testArea div.meterText {
position: absolute;
bottom: 1.55em;
left: 0;
width: 100%;
font-size: 2.5em;
z-index: 9;
}
div.testArea2 div.meterText {
display: inline-block;
font-size: 2.5em;
}
div.meterText:empty:before {
content: "0.00";
}
div.testArea div.unit {
position: absolute;
bottom: 2em;
left: 0;
width: 100%;
z-index: 9;
}
div.testArea2 div.unit {
display: inline-block;
}
div.testArea canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
div.testGroup {
display: block;
margin: 0 auto;
}
#shareArea {
width: 95%;
max-width: 40em;
margin: 0 auto;
margin-top: 2em;
}
#shareArea>* {
display: block;
width: 100%;
height: auto;
margin: 0.25em 0;
}
#privacyPolicy {
position: fixed;
top: 2em;
bottom: 2em;
left: 2em;
right: 2em;
overflow-y: auto;
width: auto;
height: auto;
box-shadow: 0 0 3em 1em #000000;
z-index: 999999;
text-align: left;
background-color: #FFFFFF;
padding: 1em;
}
a.privacy {
text-align: center;
font-size: 0.8em;
color: #808080;
padding: 0 3em;
}
div.closePrivacyPolicy {
width: 100%;
text-align: center;
}
div.closePrivacyPolicy a.privacy {
padding: 1em 3em;
}
@media all and (max-width:40em) {
body {
font-size: 0.8em;
}
}
div.visible {
animation: fadeIn 0.4s;
display: block;
}
div.hidden {
animation: fadeOut 0.4s;
display: none;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fadeOut {
0% {
display: block;
opacity: 1;
}
100% {
display: block;
opacity: 0;
}
}
@media all and (prefers-color-scheme: dark) {
html,
body,
#loading {
background: #202020;
color: #F4F4F4;
color-scheme: dark;
}
h1 {
color: #E0E0E0;
}
a {
color: #9090FF;
}
#privacyPolicy {
background: #000000;
}
#resultsImg {
filter: invert(1);
}
}
</style>
<title>LibreSpeed</title>
</head>
<body onload="initServers()">
<h1>LibreSpeed</h1>
<div id="loading" class="visible">
<p id="message"><span class="loadCircle"></span>Selecting a server...</p>
</div>
<div id="testWrapper" class="hidden">
<button id="startStopBtn" onclick="startStop()" aria-label="Start"></button><br />
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display=''">Privacy</a>
<div id="serverArea">
Server: <select id="server" onchange="s.setSelectedServer(SPEEDTEST_SERVERS[this.value])"></select>
</div>
<div id="test">
<div class="testGroup">
<div class="testArea2">
<div class="testName">Ping</div>
<div id="pingText" class="meterText" style="color:#AA6060"></div>
<div class="unit">ms</div>
</div>
<div class="testArea2">
<div class="testName">Jitter</div>
<div id="jitText" class="meterText" style="color:#AA6060"></div>
<div class="unit">ms</div>
</div>
</div>
<div class="testGroup">
<div class="testArea">
<div class="testName">Download</div>
<canvas id="dlMeter" class="meter"></canvas>
<div id="dlText" class="meterText"></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">Mbit/s</div>
</div>
</div>
<div id="ipArea">
<span id="ip"></span>
</div>
<div id="shareArea" style="display:none">
<h3>Share results</h3>
<p>Test ID: <span id="testId"></span></p>
<input type="text" value="" id="resultsURL" readonly="readonly"
onclick="this.select();this.focus();this.select();document.execCommand('copy');alert('Link copied')" />
<img src="" id="resultsImg" />
</div>
</div>
<a href="index.html?design=new">Try the modern design</a><br>
<a href="stability.html">Stability Test</a> | <a href="https://github.com/librespeed/speedtest">Source code</a>
</div>
<div id="privacyPolicy" style="display:none">
<h2>Privacy Policy</h2>
<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:
<ul>
<li>Test ID</li>
<li>Time of testing</li>
<li>Test results (download and upload speed, ping and jitter)</li>
<li>IP address</li>
<li>ISP information</li>
<li>Approximate location (inferred from IP address, not GPS)</li>
<li>User agent and browser locale</li>
<li>Test log (contains no personal information)</li>
</ul>
</p>
<h4>How we use the data</h4>
<p>
Data collected through this service is used to:
<ul>
<li>Allow sharing of test results (sharable image for forums, etc.)</li>
<li>To improve the service offered to you (for instance, to detect problems on our side)</li>
</ul>
No personal information is disclosed to third parties.
</p>
<h4>Your consent</h4>
<p>
By starting the test, you consent to the terms of this privacy policy.
</p>
<h4>Data removal</h4>
<p>
If you want to have your information deleted, you need to provide either the ID of the test or your IP
address. This is the only way to identify your data, without this information we won't be able to comply
with your request.<br /><br />
Contact this email address for all deletion requests:
<a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
</p>
<br /><br />
<div class="closePrivacyPolicy">
<a class="privacy" href="#" onclick="I('privacyPolicy').style.display='none'">Close</a>
</div>
<br />
</div>
</body>
</html>

155
index-modern.html Normal file
View file

@ -0,0 +1,155 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description"
content="Free and Open Source Speedtest. Run it right now in your browser, or self-host on a PHP, Golang, Rust or Node server. License: LGPL." />
<link rel="shortcut icon" href="frontend/images/favicon.svg" />
<link rel="manifest" href="manifest.webmanifest" />
<link rel="apple-touch-icon" href="images/icon-192.png" />
<meta name="theme-color" content="#000000" />
<script type="text/javascript" src="speedtest.js"></script>
<script type="text/javascript">
// Set this to a different URL to load the server list from another location.
var SPEEDTEST_SERVERS = "server-list.json";
</script>
<script type="text/javascript" src="frontend/javascript/index.js"></script>
<link rel="stylesheet" type="text/css" href="frontend/styling/index.css" />
<title>LibreSpeed - Free and Open Source Speedtest</title>
</head>
<body>
<header>
<img src="frontend/images/logo.svg" alt="LibreSpeed" />
</header>
<main>
<h1>Free and Open Source Speedtest.</h1>
<p class="tagline">No Flash, No Java, No Websockets, No Bullsh*t</p>
<div class="server-selector">
<div class="chosen">
<div class="chevron">
<img src="frontend/images/chevron.svg" alt="select..." />
</div>
<p>current server</p>
<h2 id="selected-server">searching nearest server...</h2>
</div>
<ul class="servers"></ul>
<p class="sponsor" id="sponsor">&nbsp;</p>
</div>
<p id="privacy-warning" class="hidden">
by clicking the start button you agree to our privacy policy<br />
<a href="#" id="choose-privacy">or choose your privacy options</a>
</p>
<button class="disabled" id="start-button"></button>
<div class="gauge-layout">
<div class="ping hidden">
<span class="label">Ping</span>:&nbsp;
<span class="value" id="ping">00</span>ms
</div>
<div class="gauge download" id="download-gauge">
<div class="progress"></div>
<div class="speed"></div>
<h1><span id="download-speed">00</span> Mbps</h1>
<h2>Download</h2>
</div>
<div class="gauge upload" id="upload-gauge">
<div class="progress"></div>
<div class="speed"></div>
<h1><span id="upload-speed">00</span> Mbps</h1>
<h2>Upload</h2>
</div>
<div class="jitter hidden">
<span class="label">Jitter</span>:&nbsp;
<span class="value" id="jitter">00</span>ms
</div>
</div>
<button class="small inverted hidden" id="share-results">
Share results
</button>
</main>
<footer>
<p class="source">
<a href="stability.html">stability test</a> | <a href="https://github.com/librespeed/speedtest">source code</a>
</p>
</footer>
<dialog id="share">
<div class="close-dialog">
<img src="frontend/images/close-button.svg" alt="Close" />
</div>
<img id="results" src="" alt="Test results in graphical form" />
<button id="copy-link">Copy link</button>
</dialog>
<dialog id="privacy">
<div class="close-dialog">
<img src="frontend/images/close-button.svg" alt="Close" />
</div>
<section>
<h1>Privacy Policy</h1>
<p>
This HTML5 speed test server is configured with telemetry enabled.
</p>
<h2>What data we collect</h2>
<p>
At the end of the test, the following data is collected and stored:
</p>
<ul>
<li>Test ID</li>
<li>Time of testing</li>
<li>Test results (download and upload speed, ping and jitter)</li>
<li>IP address</li>
<li>ISP information</li>
<li>Approximate location (inferred from IP address, not GPS)</li>
<li>User agent and browser locale</li>
<li>Test log (contains no personal information)</li>
</ul>
<h2>How we use the data</h2>
<p>Data collected through this service is used to:</p>
<ul>
<li>
Allow sharing of test results (sharable image for forums, etc.)
</li>
<li>
To improve the service offered to you (for instance, to detect
problems on our side)
</li>
</ul>
<p>No personal information is disclosed to third parties.</p>
<h2>Your consent</h2>
<p>
By starting the test, you consent to the terms of this privacy policy.
</p>
<h2>Data removal</h2>
<p>
If you want to have your information deleted, you need to provide
either the ID of the test or your IP address. This is the only way to
identify your data, without this information we won't be able to
comply with your request.
</p>
<p>
Contact this email address for all deletion requests:
<a href="mailto:PUT@YOUR_EMAIL.HERE">TO BE FILLED BY DEVELOPER</a>.
</p>
</section>
<button id="close-privacy">Close</button>
</dialog>
</body>
</html>

19
index.html Executable file
View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<link rel="shortcut icon" href="favicon.ico">
<link rel="manifest" href="manifest.webmanifest">
<link rel="apple-touch-icon" href="images/icon-192.png">
<meta name="theme-color" content="#000000">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no" />
<meta charset="UTF-8" />
<script type="text/javascript" src="design-switch.js"></script>
<title>LibreSpeed</title>
</head>
<body>
<p>Loading...</p>
</body>
</html>

20
manifest.webmanifest Normal file
View file

@ -0,0 +1,20 @@
{
"name": "LibreSpeed",
"short_name": "LibreSpeed",
"start_url": "./",
"display": "standalone",
"background_color": "#000000",
"theme_color": "#000000",
"icons": [
{
"src": "images/icon-192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/icon-512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

1337
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

62
package.json Normal file
View file

@ -0,0 +1,62 @@
{
"name": "librespeed-speedtest",
"version": "6.3.1",
"description": "LibreSpeed - A Free and Open Source speed test that you can host on your server(s)",
"main": "speedtest.js",
"scripts": {
"test": "echo \"No automated tests configured yet\" && exit 0",
"test:e2e": "playwright test",
"test:e2e:headed": "playwright test --headed",
"lint": "eslint speedtest.js speedtest_worker.js stability_worker.js",
"lint:fix": "eslint --fix speedtest.js speedtest_worker.js stability_worker.js",
"format": "prettier --write \"*.js\"",
"format:check": "prettier --check \"*.js\"",
"validate": "npm run format:check && npm run lint",
"docker:build": "docker build -t librespeed-speedtest .",
"docker:build-alpine": "docker build -t librespeed-speedtest:alpine -f Dockerfile.alpine ."
},
"repository": {
"type": "git",
"url": "git+https://github.com/librespeed/speedtest.git"
},
"keywords": [
"speedtest",
"speed-test",
"internet-speed",
"bandwidth",
"network",
"performance",
"librespeed",
"download",
"upload",
"ping",
"latency"
],
"author": "Federico Dossena",
"license": "LGPL-3.0-or-later",
"bugs": {
"url": "https://github.com/librespeed/speedtest/issues"
},
"homepage": "https://github.com/librespeed/speedtest#readme",
"devDependencies": {
"@playwright/test": "^1.55.0",
"eslint": "^8.57.0",
"prettier": "^3.1.1"
},
"files": [
"speedtest.js",
"speedtest_worker.js",
"stability_worker.js",
"stability.html",
"index.html",
"favicon.ico",
"manifest.webmanifest",
"images/",
"backend/",
"examples/",
"results/"
],
"engines": {
"node": ">=14.0.0"
}
}

32
playwright.config.js Normal file
View file

@ -0,0 +1,32 @@
const { defineConfig, devices } = require('@playwright/test');
module.exports = defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 2 : undefined,
timeout: 30_000,
expect: {
timeout: 7_500,
},
reporter: process.env.CI ? [['github'], ['html', { open: 'never' }]] : [['list']],
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'off',
},
globalSetup: require.resolve('./tests/e2e/global-setup.js'),
globalTeardown: require.resolve('./tests/e2e/global-teardown.js'),
webServer: {
command: 'node tests/e2e/static-server.js',
url: 'http://127.0.0.1:18184',
reuseExistingServer: !process.env.CI,
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});

0
results/OpenSans-Light.ttf Normal file → Executable file
View file

0
results/OpenSans-Semibold.ttf Normal file → Executable file
View file

109
results/idObfuscation.php Normal file → Executable file
View file

@ -1,43 +1,72 @@
<?php
function getObfuscationSalt(){
$saltFile=dirname(__FILE__)."/idObfuscation_salt.php";
if(file_exists($saltFile)){
require $saltFile;
}else{
$bytes=openssl_random_pseudo_bytes(4);
$sf=fopen($saltFile,"w");
fwrite($sf,chr(60)."?php\n");
fwrite($sf,'$OBFUSCATION_SALT=0x'.bin2hex($bytes).";\n");
fwrite($sf,"?".chr(62));
fclose($sf);
require $saltFile;
}
return isset($OBFUSCATION_SALT)?$OBFUSCATION_SALT:0;
}
/*
This is a simple reversible hash function I made for encoding and decoding test IDs.
It is not cryptographically secure, don't use it to hash passwords or something!
*/
function obfdeobf($id,$dec){
$salt=getObfuscationSalt()&0xFFFFFFFF;
$id=$id&0xFFFFFFFF;
if($dec){
$id=$id^$salt;
$id=(($id&0xAAAAAAAA)>>1)|($id&0x55555555)<<1;
$id=(($id&0x0000FFFF)<<16)|(($id&0xFFFF0000)>>16);
return $id;
}else{
$id=(($id&0x0000FFFF)<<16)|(($id&0xFFFF0000)>>16);
$id=(($id&0xAAAAAAAA)>>1)|($id&0x55555555)<<1;
return $id^$salt;
}
}
function obfuscateId($id){
return str_pad(base_convert(obfdeobf($id+1,false),10,36),7,0,STR_PAD_LEFT);
}
function deobfuscateId($id){
return obfdeobf(base_convert($id,36,10),true)-1;
define('ID_OBFUSCATION_SALT_FILE', __DIR__.'/idObfuscation_salt.php');
/**
* @return string|int
*/
function getObfuscationSalt()
{
if (!file_exists(ID_OBFUSCATION_SALT_FILE)) {
$bytes = openssl_random_pseudo_bytes(4);
$saltData = "<?php\n\n\$OBFUSCATION_SALT = 0x".bin2hex($bytes).";\n";
file_put_contents(ID_OBFUSCATION_SALT_FILE, $saltData);
}
if (
file_exists(ID_OBFUSCATION_SALT_FILE)
&& is_readable(ID_OBFUSCATION_SALT_FILE)
) {
require ID_OBFUSCATION_SALT_FILE;
}
return isset($OBFUSCATION_SALT) ? $OBFUSCATION_SALT : 0;
}
//IMPORTANT: DO NOT ADD ANYTHING BELOW THE PHP CLOSING TAG, NOT EVEN EMPTY LINES!
?>
/**
* This is a simple reversible hash function I made for encoding and decoding test IDs.
* It is not cryptographically secure, don't use it to hash passwords or something!
*
* @param int|string $id
* @param bool $dec
*
* @return int|string
*/
function obfdeobf($id, $dec)
{
$salt = getObfuscationSalt() & 0xFFFFFFFF;
$id &= 0xFFFFFFFF;
if ($dec) {
$id ^= $salt;
$id = (($id & 0xAAAAAAAA) >> 1) | ($id & 0x55555555) << 1;
$id = (($id & 0x0000FFFF) << 16) | (($id & 0xFFFF0000) >> 16);
return $id;
}
$id = (($id & 0x0000FFFF) << 16) | (($id & 0xFFFF0000) >> 16);
$id = (($id & 0xAAAAAAAA) >> 1) | ($id & 0x55555555) << 1;
return $id ^ $salt;
}
/**
* @param int $id
*
* @return string
*/
function obfuscateId($id)
{
return str_pad(base_convert(obfdeobf($id + 1, false), 10, 36), 7, 0, STR_PAD_LEFT);
}
/**
* @param string $id
*
* @return int
*/
function deobfuscateId($id)
{
return obfdeobf(base_convert($id, 36, 10), true) - 1;
}

928
results/index.php Normal file → Executable file
View file

@ -1,164 +1,786 @@
<?php
$WATERMARK_TEXT="LibreSpeed";
require_once 'telemetry_db.php';
error_reporting(0);
putenv('GDFONTPATH=' . realpath('.'));
function tryFont($name){
$rp=realpath('.');
if(imageftbbox(12,0,$name,"M")[5]==0){
$name=$rp."/".$name.".ttf";
if(imageftbbox(12,0,$name,"M")[5]==0){
return null;
}
}
return $name;
}
function format($d){
if($d<10) return number_format($d,2,".","");
if($d<100) return number_format($d,1,".","");
return number_format($d,0,".","");
putenv('GDFONTPATH='.realpath('.'));
/**
* Everything is drawn at SS times the final size and scaled down at the end.
* GD has no antialiasing for filled shapes, so circles, rounded corners and
* arcs would otherwise come out stepped; oversampling gives all of them smooth
* edges from one mechanism.
*/
const SS = 3;
const WIDTH = 800;
const HEIGHT = 480;
// Palette taken from frontend/styling/colors.css, so the image matches the
// modern frontend rather than inventing a second look for the same project.
const C_CARD = [14, 7, 32]; // --background-backup-color
const C_PANEL = [23, 16, 42];
const C_PANEL_EDGE = [42, 32, 64];
const C_TEXT = [255, 255, 255]; // --primary-text-color
const C_TEXT_DIM = [137, 133, 145]; // --secondary-text-color
const C_DOWNLOAD = [92, 249, 253]; // --theme-green
const C_UPLOAD = [214, 59, 198]; // --theme-pink
/**
* @param string $name
*
* @return string|null
*/
function tryFont($name)
{
if (is_array(imageftbbox(12, 0, $name, 'M'))) {
return $name;
}
$fullPathToFont = realpath('.').'/'.$name.'.ttf';
if (is_array(imageftbbox(12, 0, $fullPathToFont, 'M'))) {
return $fullPathToFont;
}
return null;
}
$SCALE=1.25;
$WIDTH=400*$SCALE;
$HEIGHT=229*$SCALE;
$im=imagecreatetruecolor($WIDTH,$HEIGHT);
$BACKGROUND_COLOR=imagecolorallocate($im,255,255,255);
$FONT_LABEL=tryFont("OpenSans-Semibold");
$FONT_LABEL_SIZE=14*$SCALE;
$FONT_LABEL_SIZE_BIG=16*$SCALE;
$FONT_METER=tryFont("OpenSans-Light");
$FONT_METER_SIZE=20*$SCALE;
$FONT_METER_SIZE_BIG=22*$SCALE;
$FONT_MEASURE=tryFont("OpenSans-Semibold");
$FONT_MEASURE_SIZE=12*$SCALE;
$FONT_MEASURE_SIZE_BIG=12*$SCALE;
$FONT_ISP=tryFont("OpenSans-Semibold");
$FONT_ISP_SIZE=9*$SCALE;
$FONT_WATERMARK=tryFont("OpenSans-Light");
$FONT_WATERMARK_SIZE=8*$SCALE;
$TEXT_COLOR_LABEL=imagecolorallocate($im,40,40,40);
$TEXT_COLOR_DL_METER=imagecolorallocate($im,96,96,170);
$TEXT_COLOR_UL_METER=imagecolorallocate($im,96,96,96);
$TEXT_COLOR_PING_METER=imagecolorallocate($im,170,96,96);
$TEXT_COLOR_JIT_METER=imagecolorallocate($im,170,96,96);
$TEXT_COLOR_MEASURE=imagecolorallocate($im,40,40,40);
$TEXT_COLOR_ISP=imagecolorallocate($im,40,40,40);
$TEXT_COLOR_WATERMARK=imagecolorallocate($im,160,160,160);
$POSITION_Y_DL_LABEL=105*$SCALE;
$POSITION_Y_UL_LABEL=105*$SCALE;
$POSITION_Y_PING_LABEL=24*$SCALE;
$POSITION_Y_JIT_LABEL=24*$SCALE;
$POSITION_Y_DL_METER=143*$SCALE;
$POSITION_Y_UL_METER=143*$SCALE;
$POSITION_Y_PING_METER=60*$SCALE;
$POSITION_Y_JIT_METER=60*$SCALE;
$POSITION_Y_DL_MEASURE=169*$SCALE;
$POSITION_Y_UL_MEASURE=169*$SCALE;
$POSITION_Y_PING_MEASURE=60*$SCALE;
$POSITION_Y_JIT_MEASURE=60*$SCALE;
$POSITION_Y_ISP=205*$SCALE;
$POSITION_X_DL=120*$SCALE;
$POSITION_X_UL=280*$SCALE;
$POSITION_X_PING=125*$SCALE;
$POSITION_X_JIT=275*$SCALE;
$POSITION_X_ISP=4*$SCALE;
$SMALL_SEP=8*$SCALE;
$SEPARATOR_Y=211*$SCALE;
$SEPARATOR_COLOR=imagecolorallocate($im,192,192,192);
$POSITION_Y_WATERMARK=223*$SCALE;
$DL_TEXT="Download";
$UL_TEXT="Upload";
$PING_TEXT="Ping";
$JIT_TEXT="Jitter";
$MBPS_TEXT="Mbps";
$MS_TEXT="ms";
/**
* @param int|float $d
*
* @return string
*/
function format($d)
{
if ($d < 10) {
return number_format($d, 2, '.', '');
}
if ($d < 100) {
return number_format($d, 1, '.', '');
}
$id=$_GET["id"];
include_once('telemetry_settings.php');
require 'idObfuscation.php';
if($enable_id_obfuscation) $id=deobfuscateId($id);
$conn=null; $q=null;
$ispinfo=null; $dl=null; $ul=null; $ping=null; $jit=null;
if($db_type=="mysql"){
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename);
$q = $conn->prepare("select ispinfo,dl,ul,ping,jitter from speedtest_users where id=?");
$q->bind_param("i",$id);
$q->execute();
$q->bind_result($ispinfo,$dl,$ul,$ping,$jit);
$q->fetch();
}else if($db_type=="sqlite"){
$conn = new PDO("sqlite:$Sqlite_db_file") or die();
$q=$conn->prepare("select ispinfo,dl,ul,ping,jitter from speedtest_users where id=?") or die();
$q->execute(array($id)) or die();
$row=$q->fetch() or die();
$ispinfo=$row["ispinfo"];
$dl=$row["dl"];
$ul=$row["ul"];
$ping=$row["ping"];
$jit=$row["jitter"];
$conn=null;
}else if($db_type=="postgresql"){
$conn_host = "host=$PostgreSql_hostname";
$conn_db = "dbname=$PostgreSql_databasename";
$conn_user = "user=$PostgreSql_username";
$conn_password = "password=$PostgreSql_password";
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die();
$q=$conn->prepare("select ispinfo,dl,ul,ping,jitter from speedtest_users where id=?") or die();
$q->execute(array($id)) or die();
$row=$q->fetch() or die();
$ispinfo=$row["ispinfo"];
$dl=$row["dl"];
$ul=$row["ul"];
$ping=$row["ping"];
$jit=$row["jitter"];
$conn=null;
}else die();
return number_format($d, 0, '.', '');
}
$dl=format($dl);
$ul=format($ul);
$ping=format($ping);
$jit=format($jit);
/**
* Drops the fractional seconds a database may keep on the timestamp column.
*
* How much precision that column carries is decided by the backend, and the
* three schemas shipped here disagree: MySQL declares `timestamp`, which keeps
* none, PostgreSQL uses `timestamp without time zone DEFAULT now()`, which
* keeps microseconds, and MSSQL uses `datetime`, which keeps milliseconds.
*
* The fraction is matched against the seconds field it belongs to rather than
* the end of the string, so a value carrying a zone offset after it, such as
* "2026-08-10 02:04:13.957789+00", is handled as well.
*
* @param string $timestamp
*
* @return string
*/
function formatTimestamp($timestamp)
{
return preg_replace('/(:\d{2})\.\d+/', '$1', (string) $timestamp);
}
$ispinfo=json_decode($ispinfo,true)["processedString"];
$dash=strpos($ispinfo,"-");
if(!($dash===FALSE)){
$ispinfo=substr($ispinfo,$dash+2);
$par=strrpos($ispinfo,"(");
if(!($par===FALSE)) $ispinfo=substr($ispinfo,0,$par);
}else $ispinfo="";
/**
* Splits a timestamp into a date and a time meant to be read rather than
* parsed.
*
* The whole value is returned as the date with an empty time when it cannot be
* parsed, which keeps a backend nobody here has seen legible rather than blank.
*
* @param string $timestamp
*
* @return array{0: string, 1: string}
*/
function splitTimestamp($timestamp)
{
$timestamp = formatTimestamp($timestamp);
$t = strtotime($timestamp);
if (false === $t) {
return [$timestamp, ''];
}
$dlBbox=imageftbbox($FONT_LABEL_SIZE_BIG,0,$FONT_LABEL,$DL_TEXT);
$ulBbox=imageftbbox($FONT_LABEL_SIZE_BIG,0,$FONT_LABEL,$UL_TEXT);
$pingBbox=imageftbbox($FONT_LABEL_SIZE,0,$FONT_LABEL,$PING_TEXT);
$jitBbox=imageftbbox($FONT_LABEL_SIZE,0,$FONT_LABEL,$JIT_TEXT);
$dlMeterBbox=imageftbbox($FONT_METER_SIZE_BIG,0,$FONT_METER,$dl);
$ulMeterBbox=imageftbbox($FONT_METER_SIZE_BIG,0,$FONT_METER,$ul);
$pingMeterBbox=imageftbbox($FONT_METER_SIZE,0,$FONT_METER,$ping);
$jitMeterBbox=imageftbbox($FONT_METER_SIZE,0,$FONT_METER,$jit);
$mbpsBbox=imageftbbox($FONT_MEASURE_SIZE_BIG,0,$FONT_MEASURE,$MBPS_TEXT);
$msBbox=imageftbbox($FONT_MEASURE_SIZE,0,$FONT_MEASURE,$MS_TEXT);
$watermarkBbox=imageftbbox($FONT_WATERMARK_SIZE,0,$FONT_WATERMARK,$WATERMARK_TEXT);
$POSITION_X_WATERMARK=$WIDTH-$watermarkBbox[4]-4*$SCALE;
return [date('j M Y', $t), date('H:i', $t)];
}
imagefilledrectangle($im, 0, 0, $WIDTH, $HEIGHT, $BACKGROUND_COLOR);
imagefttext($im,$FONT_LABEL_SIZE_BIG,0,$POSITION_X_DL-$dlBbox[4]/2,$POSITION_Y_DL_LABEL,$TEXT_COLOR_LABEL,$FONT_LABEL,$DL_TEXT);
imagefttext($im,$FONT_LABEL_SIZE_BIG,0,$POSITION_X_UL-$ulBbox[4]/2,$POSITION_Y_UL_LABEL,$TEXT_COLOR_LABEL,$FONT_LABEL,$UL_TEXT);
imagefttext($im,$FONT_LABEL_SIZE,0,$POSITION_X_PING-$pingBbox[4]/2,$POSITION_Y_PING_LABEL,$TEXT_COLOR_LABEL,$FONT_LABEL,$PING_TEXT);
imagefttext($im,$FONT_LABEL_SIZE,0,$POSITION_X_JIT-$jitBbox[4]/2,$POSITION_Y_JIT_LABEL,$TEXT_COLOR_LABEL,$FONT_LABEL,$JIT_TEXT);
imagefttext($im,$FONT_METER_SIZE_BIG,0,$POSITION_X_DL-$dlMeterBbox[4]/2,$POSITION_Y_DL_METER,$TEXT_COLOR_DL_METER,$FONT_METER,$dl);
imagefttext($im,$FONT_METER_SIZE_BIG,0,$POSITION_X_UL-$ulMeterBbox[4]/2,$POSITION_Y_UL_METER,$TEXT_COLOR_UL_METER,$FONT_METER,$ul);
imagefttext($im,$FONT_METER_SIZE,0,$POSITION_X_PING-$pingMeterBbox[4]/2-$msBbox[4]/2-$SMALL_SEP/2,$POSITION_Y_PING_METER,$TEXT_COLOR_PING_METER,$FONT_METER,$ping);
imagefttext($im,$FONT_METER_SIZE,0,$POSITION_X_JIT-$jitMeterBbox[4]/2-$msBbox[4]/2-$SMALL_SEP/2,$POSITION_Y_JIT_METER,$TEXT_COLOR_JIT_METER,$FONT_METER,$jit);
imagefttext($im,$FONT_MEASURE_SIZE_BIG,0,$POSITION_X_DL-$mbpsBbox[4]/2,$POSITION_Y_DL_MEASURE,$TEXT_COLOR_MEASURE,$FONT_MEASURE,$MBPS_TEXT);
imagefttext($im,$FONT_MEASURE_SIZE_BIG,0,$POSITION_X_UL-$mbpsBbox[4]/2,$POSITION_Y_UL_MEASURE,$TEXT_COLOR_MEASURE,$FONT_MEASURE,$MBPS_TEXT);
imagefttext($im,$FONT_MEASURE_SIZE,0,$POSITION_X_PING+$pingMeterBbox[4]/2+$SMALL_SEP/2-$msBbox[4]/2,$POSITION_Y_PING_MEASURE,$TEXT_COLOR_MEASURE,$FONT_MEASURE,$MS_TEXT);
imagefttext($im,$FONT_MEASURE_SIZE,0,$POSITION_X_JIT+$jitMeterBbox[4]/2+$SMALL_SEP/2-$msBbox[4]/2,$POSITION_Y_JIT_MEASURE,$TEXT_COLOR_MEASURE,$FONT_MEASURE,$MS_TEXT);
imagefttext($im,$FONT_ISP_SIZE,0,$POSITION_X_ISP,$POSITION_Y_ISP,$TEXT_COLOR_ISP,$FONT_ISP,$ispinfo);
imagefttext($im,$FONT_WATERMARK_SIZE,0,$POSITION_X_WATERMARK,$POSITION_Y_WATERMARK,$TEXT_COLOR_WATERMARK,$FONT_WATERMARK,$WATERMARK_TEXT);
imagefilledrectangle($im, 0, $SEPARATOR_Y, $WIDTH, $SEPARATOR_Y, $SEPARATOR_COLOR);
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
/**
* Names the address family a result was measured over, without disclosing the
* address itself.
*
* Returns an empty string when the deployment redacts client addresses, since
* the placeholder it stores would otherwise be reported as IPv4.
*
* @param string $ip
*
* @return string
*/
function addressFamily($ip)
{
if ('' === $ip || '0.0.0.0' === $ip) {
return '';
}
?>
return false === strpos($ip, ':') ? 'IPv4' : 'IPv6';
}
/**
* @param resource|GdImage $im
* @param int[] $rgb
* @param int $alpha 0 opaque, 127 transparent
*
* @return int
*/
function col($im, $rgb, $alpha = 0)
{
return imagecolorallocatealpha($im, $rgb[0], $rgb[1], $rgb[2], $alpha);
}
/**
* The horizontal span of a rounded rectangle on a given row.
*
* Filling and shading both need to respect the same corners, so both ask this
* rather than each approximating the curve on its own.
*
* @return array{0: float, 1: float}|null
*/
function roundedSpan($y, $x1, $y1, $x2, $y2, $r)
{
if ($y < $y1 || $y > $y2) {
return null;
}
$inset = 0;
if ($y < $y1 + $r) {
$dy = $r - ($y - $y1);
$inset = $r - sqrt(max(0, $r * $r - $dy * $dy));
} elseif ($y > $y2 - $r) {
$dy = $r - ($y2 - $y);
$inset = $r - sqrt(max(0, $r * $r - $dy * $dy));
}
return [$x1 + $inset, $x2 - $inset];
}
/**
* @param resource|GdImage $im
*
* @return void
*/
function roundedRect($im, $x1, $y1, $x2, $y2, $r, $color)
{
for ($y = (int) $y1; $y <= (int) $y2; ++$y) {
$span = roundedSpan($y, $x1, $y1, $x2, $y2, $r);
if (null !== $span) {
imageline($im, (int) round($span[0]), $y, (int) round($span[1]), $y, $color);
}
}
}
/**
* A panel: a one-pixel edge with a darker fill inside it.
*
* @param resource|GdImage $im
*
* @return void
*/
function panel($im, $x1, $y1, $x2, $y2, $r, $fill, $edge)
{
roundedRect($im, $x1, $y1, $x2, $y2, $r, $edge);
roundedRect($im, $x1 + SS, $y1 + SS, $x2 - SS, $y2 - SS, $r - SS, $fill);
}
/**
* Washes an accent colour into the bottom of a panel.
*
* This is deliberately a plain gradient and not a line chart. A curve inside a
* speed test result reads as measured data, and no per-second samples are
* stored for a shared result, so any curve drawn here would be invented.
*
* @param resource|GdImage $im
* @param int[] $rgb
*
* @return void
*/
function wash($im, $x1, $y1, $x2, $y2, $r, $rgb, $height, $maxAlpha = 88)
{
$start = $y2 - $height;
for ($y = (int) $start; $y <= (int) $y2; ++$y) {
$span = roundedSpan($y, $x1, $y1, $x2, $y2, $r);
if (null === $span) {
continue;
}
$t = ($y - $start) / max(1, $height);
$alpha = (int) round(127 - (127 - $maxAlpha) * ($t * $t));
imageline($im, (int) round($span[0]), $y, (int) round($span[1]), $y, col($im, $rgb, $alpha));
}
}
/**
* @param string $text
*
* @return float
*/
function textWidth($text, $font, $size)
{
$bbox = imageftbbox($size, 0, $font, $text);
return is_array($bbox) ? $bbox[2] - $bbox[0] : 0;
}
/**
* Draws text, anchored left, centre or right on x.
*
* @param resource|GdImage $im
*
* @return float the width drawn
*/
function text($im, $x, $y, $size, $font, $color, $string, $align = 'left')
{
$w = textWidth($string, $font, $size);
if ('center' === $align) {
$x -= $w / 2;
} elseif ('right' === $align) {
$x -= $w;
}
imagefttext($im, $size, 0, (int) round($x), (int) round($y), $color, $font, $string);
return $w;
}
/**
* The width trackedText() would draw.
*
* @return float
*/
function trackedWidth($string, $font, $size, $tracking)
{
$total = -$tracking;
foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $ch) {
$total += textWidth($ch, $font, $size) + $tracking;
}
return $total;
}
/**
* The same as text(), with the letters spaced apart.
*
* GD has no notion of tracking, so each character is placed on its own. The
* small uppercase labels are unreadable without it at this size.
*
* @param resource|GdImage $im
*
* @return float
*/
function trackedText($im, $x, $y, $size, $font, $color, $string, $tracking, $align = 'left')
{
$chars = preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY);
$total = trackedWidth($string, $font, $size, $tracking);
if ('center' === $align) {
$x -= $total / 2;
} elseif ('right' === $align) {
$x -= $total;
}
foreach ($chars as $ch) {
imagefttext($im, $size, 0, (int) round($x), (int) round($y), $color, $font, $ch);
$x += textWidth($ch, $font, $size) + $tracking;
}
return $total;
}
/**
* Fills a polygon on both supported PHP majors.
*
* imagefilledpolygon() took a point count until PHP 8.0, which deprecated it
* and made the parameter optional. The backend already relies on the null
* coalescing operator, so PHP 7 is the floor to keep working here.
*
* @param resource|GdImage $im
* @param int[] $points
*
* @return void
*/
function filledPolygon($im, $points, $color)
{
if (PHP_VERSION_ID >= 80000) {
imagefilledpolygon($im, $points, $color);
return;
}
imagefilledpolygon($im, $points, count($points) / 2, $color);
}
/**
* A ring with an arrow in it, marking which direction a panel measures.
*
* @param resource|GdImage $im
* @param int[] $rgb
*
* @return void
*/
function directionBadge($im, $cx, $cy, $r, $rgb, $pointsDown)
{
// ring
imagefilledellipse($im, (int) $cx, (int) $cy, (int) (2 * $r), (int) (2 * $r), col($im, $rgb, 108));
imagefilledellipse($im, (int) $cx, (int) $cy, (int) (2 * $r - 2 * SS), (int) (2 * $r - 2 * SS), col($im, C_PANEL));
$color = col($im, $rgb);
$shaft = $r * 0.52;
$head = $r * 0.34;
$dir = $pointsDown ? 1 : -1;
imagesetthickness($im, (int) max(1, SS * 0.7));
imageline($im, (int) $cx, (int) ($cy - $dir * $shaft), (int) $cx, (int) ($cy + $dir * $shaft), $color);
imagesetthickness($im, 1);
$tipY = $cy + $dir * $shaft;
filledPolygon($im, [
(int) $cx, (int) ($tipY + $dir * $head * 0.5),
(int) ($cx - $head), (int) ($tipY - $dir * $head * 0.55),
(int) ($cx + $head), (int) ($tipY - $dir * $head * 0.55),
], $color);
}
/**
* A ring with a trace in it: a spike for ping, a wave for jitter.
*
* @param resource|GdImage $im
* @param int[] $rgb
*
* @return void
*/
function traceBadge($im, $cx, $cy, $r, $rgb, $wave)
{
imagefilledellipse($im, (int) $cx, (int) $cy, (int) (2 * $r), (int) (2 * $r), col($im, $rgb, 112));
imagefilledellipse($im, (int) $cx, (int) $cy, (int) (2 * $r - 2 * SS), (int) (2 * $r - 2 * SS), col($im, C_PANEL));
$color = col($im, $rgb);
imagesetthickness($im, (int) max(1, SS * 0.8));
$w = $r * 1.05;
$prev = null;
for ($i = 0; $i <= 48; ++$i) {
$t = $i / 48;
$x = $cx - $w + 2 * $w * $t;
if ($wave) {
$y = $cy - sin($t * 2 * M_PI) * $r * 0.42;
} else {
// a flat line with one spike in the middle
$d = abs($t - 0.5);
$y = $cy - ($d < 0.16 ? (0.16 - $d) / 0.16 * $r * 0.62 : 0) + ($d > 0.16 && $d < 0.26 ? $r * 0.2 : 0);
}
if (null !== $prev) {
imageline($im, (int) $prev[0], (int) $prev[1], (int) $x, (int) $y, $color);
}
$prev = [$x, $y];
}
imagesetthickness($im, 1);
}
/**
* Shortens text until it fits, marking it as shortened.
*
* User agents in particular are unbounded: a browser sends a far longer string
* than a command line client, and drawn as-is it would run off the panel.
*
* Characters are dropped rather than bytes. A provider name or user agent may
* well carry multibyte characters, and cutting one in half leaves a sequence
* that renders as a replacement glyph rather than shortened text. The input is
* capped first so that the measuring below is bounded no matter what is stored.
*
* @return string
*/
function fitText($text, $font, $size, $maxWidth)
{
if (textWidth($text, $font, $size) <= $maxWidth) {
return $text;
}
$chars = preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY);
if (!is_array($chars)) {
return '…';
}
$chars = array_slice($chars, 0, 256);
while (count($chars) > 0 && textWidth(implode('', $chars).'…', $font, $size) > $maxWidth) {
array_pop($chars);
}
return implode('', $chars).'…';
}
/**
* @param array $speedtest
*
* @return array
*/
function formatSpeedtestDataForImage($speedtest)
{
$speedtest['dl'] = format($speedtest['dl']);
$speedtest['ul'] = format($speedtest['ul']);
$speedtest['ping'] = format($speedtest['ping']);
$speedtest['jitter'] = format($speedtest['jitter']);
$speedtest['family'] = addressFamily($speedtest['ip']);
list($speedtest['date'], $speedtest['time']) = splitTimestamp($speedtest['timestamp']);
// The classic design prints the timestamp whole rather than split in two.
$speedtest['timestamp'] = formatTimestamp($speedtest['timestamp']);
$ispinfo = json_decode($speedtest['ispinfo'], true)['processedString'];
$dash = strpos($ispinfo, '-');
if ($dash !== false) {
$ispinfo = substr($ispinfo, $dash + 2);
$par = strrpos($ispinfo, '(');
if ($par !== false) {
$ispinfo = substr($ispinfo, 0, $par);
}
} else {
$ispinfo = '';
}
$speedtest['ispinfo'] = trim($ispinfo);
return $speedtest;
}
/**
* Draws the result in the modern dark design, matching index-modern.html.
*
* @param array $speedtest
*
* @return void
*/
function drawModernImage($speedtest)
{
$data = formatSpeedtestDataForImage($speedtest);
$W = WIDTH * SS;
$H = HEIGHT * SS;
$im = imagecreatetruecolor($W, $H);
imagealphablending($im, false);
imagesavealpha($im, true);
imagefilledrectangle($im, 0, 0, $W, $H, imagecolorallocatealpha($im, 0, 0, 0, 127));
imagealphablending($im, true);
$FONT_BOLD = tryFont('OpenSans-Semibold');
$FONT_LIGHT = tryFont('OpenSans-Light');
$card = col($im, C_CARD);
$panelFill = col($im, C_PANEL);
$panelEdge = col($im, C_PANEL_EDGE);
$white = col($im, C_TEXT);
$dim = col($im, C_TEXT_DIM);
// the whole canvas is the card, with rounded corners over transparency so
// it sits on any page background
roundedRect($im, 0, 0, $W - 1, $H - 1, 18 * SS, $card);
$M = 24 * SS;
// ---- header -------------------------------------------------------
$headerBaseline = 46 * SS;
text($im, $M, $headerBaseline, 21 * SS, $FONT_BOLD, $white, 'LibreSpeed');
trackedText($im, $W / 2, $headerBaseline - 4 * SS, 10 * SS, $FONT_BOLD, $dim, 'INTERNET SPEED TEST', 3 * SS, 'center');
$family = $data['family'];
if ('' !== $family) {
$fw = textWidth($family, $FONT_BOLD, 11 * SS);
$chipW = $fw + 22 * SS;
$chipH = 26 * SS;
$chipX = $W - $M - $chipW;
$chipY = $headerBaseline - 19 * SS;
roundedRect($im, $chipX, $chipY, $chipX + $chipW, $chipY + $chipH, $chipH / 2, col($im, C_DOWNLOAD, 100));
roundedRect($im, $chipX + SS, $chipY + SS, $chipX + $chipW - SS, $chipY + $chipH - SS, $chipH / 2 - SS, $card);
text($im, $chipX + $chipW / 2, $chipY + 18 * SS, 11 * SS, $FONT_BOLD, col($im, C_DOWNLOAD), $family, 'center');
}
// ---- download and upload -----------------------------------------
$panelTop = 72 * SS;
$panelBottom = 286 * SS;
$gap = 16 * SS;
$panelW = ($W - 2 * $M - $gap) / 2;
$radius = 14 * SS;
$columns = [
[$M, $data['dl'], 'DOWNLOAD', C_DOWNLOAD, true],
[$M + $panelW + $gap, $data['ul'], 'UPLOAD', C_UPLOAD, false],
];
foreach ($columns as list($x1, $value, $label, $rgb, $down)) {
$x2 = $x1 + $panelW;
panel($im, $x1, $panelTop, $x2, $panelBottom, $radius, $panelFill, $panelEdge);
wash($im, $x1 + SS, $panelTop + SS, $x2 - SS, $panelBottom - SS, $radius - SS, $rgb, 78 * SS);
$badgeR = 19 * SS;
$labelW = trackedWidth($label, $FONT_BOLD, 13 * SS, 2.5 * SS);
$groupW = 2 * $badgeR + 14 * SS + $labelW;
$groupX = $x1 + ($panelW - $groupW) / 2;
directionBadge($im, $groupX + $badgeR, $panelTop + 46 * SS, $badgeR, $rgb, $down);
trackedText($im, $groupX + 2 * $badgeR + 14 * SS, $panelTop + 52 * SS, 13 * SS, $FONT_BOLD, col($im, $rgb), $label, 2.5 * SS);
text($im, $x1 + $panelW / 2, $panelTop + 140 * SS, 58 * SS, $FONT_LIGHT, $white, $value, 'center');
text($im, $x1 + $panelW / 2, $panelTop + 178 * SS, 19 * SS, $FONT_LIGHT, $dim, 'Mbps', 'center');
}
// ---- ping and jitter ----------------------------------------------
$pjTop = 298 * SS;
$pjBottom = 376 * SS;
panel($im, $M, $pjTop, $W - $M, $pjBottom, $radius, $panelFill, $panelEdge);
$mid = $W / 2;
imageline($im, (int) $mid, (int) ($pjTop + 18 * SS), (int) $mid, (int) ($pjBottom - 18 * SS), $panelEdge);
$metrics = [
[$M, $data['ping'], 'PING', C_DOWNLOAD, false],
[$mid, $data['jitter'], 'JITTER', C_UPLOAD, true],
];
foreach ($metrics as list($half, $value, $label, $rgb, $wave)) {
$badgeR = 19 * SS;
$cx = $half + 58 * SS;
$cy = ($pjTop + $pjBottom) / 2;
traceBadge($im, $cx, $cy, $badgeR, $rgb, $wave);
$tx = $cx + $badgeR + 18 * SS;
trackedText($im, $tx, $cy - 12 * SS, 11 * SS, $FONT_BOLD, col($im, $rgb), $label, 2.5 * SS);
$vw = text($im, $tx, $cy + 25 * SS, 29 * SS, $FONT_LIGHT, $white, $value);
text($im, $tx + $vw + 7 * SS, $cy + 25 * SS, 14 * SS, $FONT_LIGHT, $dim, 'ms');
}
// ---- footer --------------------------------------------------------
$fTop = 390 * SS;
$fBottom = 456 * SS;
panel($im, $M, $fTop, $W - $M, $fBottom, $radius, $panelFill, $panelEdge);
$fx = $M + 22 * SS;
$wmW = textWidth('LibreSpeed', $FONT_BOLD, 15 * SS);
$wmX = $W - $M - 22 * SS;
$isp = fitText($data['ispinfo'], $FONT_BOLD, 15 * SS, $wmX - $wmW - $fx - 20 * SS);
text($im, $fx, $fTop + 30 * SS, 15 * SS, $FONT_BOLD, $white, $isp);
$stamp = trim($data['date'].('' === $data['time'] ? '' : ' '.$data['time']));
$sw = text($im, $fx, $fTop + 56 * SS, 12 * SS, $FONT_LIGHT, $dim, $stamp);
$client = trim((string) $data['ua']);
if ('' !== $client) {
$cx = $fx + $sw + 18 * SS;
$client = fitText($client, $FONT_LIGHT, 12 * SS, $wmX - $wmW - $cx - 20 * SS);
text($im, $cx, $fTop + 56 * SS, 12 * SS, $FONT_LIGHT, $dim, $client);
}
text($im, $wmX, $fTop + 48 * SS, 15 * SS, $FONT_BOLD, col($im, C_TEXT_DIM), 'LibreSpeed', 'right');
// ---- scale down ----------------------------------------------------
$out = imagecreatetruecolor(WIDTH, HEIGHT);
imagealphablending($out, false);
imagesavealpha($out, true);
imagefilledrectangle($out, 0, 0, WIDTH, HEIGHT, imagecolorallocatealpha($out, 0, 0, 0, 127));
imagecopyresampled($out, $im, 0, 0, 0, 0, WIDTH, HEIGHT, $W, $H);
imagedestroy($im);
header('Content-Type: image/png');
imagepng($out);
}
/**
* Draws the result in the classic light design, as index-classic.html uses.
*
* Kept as it was drawn before the modern design existed: a deployment serving
* the classic frontend would otherwise get an image that matches nothing on
* its own page.
*
* @param array $speedtest
*
* @return void
*/
function drawClassicImage($speedtest)
{
// format values for the image
$data = formatSpeedtestDataForImage($speedtest);
$dl = $data['dl'];
$ul = $data['ul'];
$ping = $data['ping'];
$jit = $data['jitter'];
$ispinfo = $data['ispinfo'];
$timestamp = $data['timestamp'];
// initialize the image
$SCALE = 1.25;
$SMALL_SEP = 8 * $SCALE;
$WIDTH = 400 * $SCALE;
$HEIGHT = 229 * $SCALE;
$im = imagecreatetruecolor($WIDTH, $HEIGHT);
$BACKGROUND_COLOR = imagecolorallocate($im, 255, 255, 255);
// configure fonts
$FONT_LABEL = tryFont('OpenSans-Semibold');
$FONT_LABEL_SIZE = 14 * $SCALE;
$FONT_LABEL_SIZE_BIG = 16 * $SCALE;
$FONT_METER = tryFont('OpenSans-Light');
$FONT_METER_SIZE = 20 * $SCALE;
$FONT_METER_SIZE_BIG = 22 * $SCALE;
$FONT_MEASURE = tryFont('OpenSans-Semibold');
$FONT_MEASURE_SIZE = 12 * $SCALE;
$FONT_MEASURE_SIZE_BIG = 12 * $SCALE;
$FONT_ISP = tryFont('OpenSans-Semibold');
$FONT_ISP_SIZE = 9 * $SCALE;
$FONT_TIMESTAMP = tryFont("OpenSans-Light");
$FONT_TIMESTAMP_SIZE = 8 * $SCALE;
$FONT_WATERMARK = tryFont('OpenSans-Light');
$FONT_WATERMARK_SIZE = 8 * $SCALE;
// configure text colors
$TEXT_COLOR_LABEL = imagecolorallocate($im, 40, 40, 40);
$TEXT_COLOR_PING_METER = imagecolorallocate($im, 170, 96, 96);
$TEXT_COLOR_JIT_METER = imagecolorallocate($im, 170, 96, 96);
$TEXT_COLOR_DL_METER = imagecolorallocate($im, 96, 96, 170);
$TEXT_COLOR_UL_METER = imagecolorallocate($im, 96, 96, 96);
$TEXT_COLOR_MEASURE = imagecolorallocate($im, 40, 40, 40);
$TEXT_COLOR_ISP = imagecolorallocate($im, 40, 40, 40);
$SEPARATOR_COLOR = imagecolorallocate($im, 192, 192, 192);
$TEXT_COLOR_TIMESTAMP = imagecolorallocate($im, 160, 160, 160);
$TEXT_COLOR_WATERMARK = imagecolorallocate($im, 160, 160, 160);
// configure positioning or the different parts on the image
$POSITION_X_PING = 125 * $SCALE;
$POSITION_Y_PING_LABEL = 24 * $SCALE;
$POSITION_Y_PING_METER = 60 * $SCALE;
$POSITION_Y_PING_MEASURE = 60 * $SCALE;
$POSITION_X_JIT = 275 * $SCALE;
$POSITION_Y_JIT_LABEL = 24 * $SCALE;
$POSITION_Y_JIT_METER = 60 * $SCALE;
$POSITION_Y_JIT_MEASURE = 60 * $SCALE;
$POSITION_X_DL = 120 * $SCALE;
$POSITION_Y_DL_LABEL = 105 * $SCALE;
$POSITION_Y_DL_METER = 143 * $SCALE;
$POSITION_Y_DL_MEASURE = 169 * $SCALE;
$POSITION_X_UL = 280 * $SCALE;
$POSITION_Y_UL_LABEL = 105 * $SCALE;
$POSITION_Y_UL_METER = 143 * $SCALE;
$POSITION_Y_UL_MEASURE = 169 * $SCALE;
$POSITION_X_ISP = 4 * $SCALE;
$POSITION_Y_ISP = 205 * $SCALE;
$SEPARATOR_Y = 211 * $SCALE;
$POSITION_X_TIMESTAMP= 4 * $SCALE;
$POSITION_Y_TIMESTAMP = 223 * $SCALE;
$POSITION_Y_WATERMARK = 223 * $SCALE;
// configure labels
$MBPS_TEXT = 'Mbit/s';
$MS_TEXT = 'ms';
$PING_TEXT = 'Ping';
$JIT_TEXT = 'Jitter';
$DL_TEXT = 'Download';
$UL_TEXT = 'Upload';
$WATERMARK_TEXT = 'LibreSpeed';
// create text boxes for each part of the image
$mbpsBbox = imageftbbox($FONT_MEASURE_SIZE_BIG, 0, $FONT_MEASURE, $MBPS_TEXT);
$msBbox = imageftbbox($FONT_MEASURE_SIZE, 0, $FONT_MEASURE, $MS_TEXT);
$pingBbox = imageftbbox($FONT_LABEL_SIZE, 0, $FONT_LABEL, $PING_TEXT);
$pingMeterBbox = imageftbbox($FONT_METER_SIZE, 0, $FONT_METER, $ping);
$jitBbox = imageftbbox($FONT_LABEL_SIZE, 0, $FONT_LABEL, $JIT_TEXT);
$jitMeterBbox = imageftbbox($FONT_METER_SIZE, 0, $FONT_METER, $jit);
$dlBbox = imageftbbox($FONT_LABEL_SIZE_BIG, 0, $FONT_LABEL, $DL_TEXT);
$dlMeterBbox = imageftbbox($FONT_METER_SIZE_BIG, 0, $FONT_METER, $dl);
$ulBbox = imageftbbox($FONT_LABEL_SIZE_BIG, 0, $FONT_LABEL, $UL_TEXT);
$ulMeterBbox = imageftbbox($FONT_METER_SIZE_BIG, 0, $FONT_METER, $ul);
$watermarkBbox = imageftbbox($FONT_WATERMARK_SIZE, 0, $FONT_WATERMARK, $WATERMARK_TEXT);
$POSITION_X_WATERMARK = $WIDTH - $watermarkBbox[4] - 4 * $SCALE;
// put the parts together to draw the image
imagefilledrectangle($im, 0, 0, $WIDTH, $HEIGHT, $BACKGROUND_COLOR);
// ping
imagefttext($im, $FONT_LABEL_SIZE, 0, $POSITION_X_PING - $pingBbox[4] / 2, $POSITION_Y_PING_LABEL, $TEXT_COLOR_LABEL, $FONT_LABEL, $PING_TEXT);
imagefttext($im, $FONT_METER_SIZE, 0, $POSITION_X_PING - $pingMeterBbox[4] / 2 - $msBbox[4] / 2 - $SMALL_SEP / 2, $POSITION_Y_PING_METER, $TEXT_COLOR_PING_METER, $FONT_METER, $ping);
imagefttext($im, $FONT_MEASURE_SIZE, 0, $POSITION_X_PING + $pingMeterBbox[4] / 2 + $SMALL_SEP / 2 - $msBbox[4] / 2, $POSITION_Y_PING_MEASURE, $TEXT_COLOR_MEASURE, $FONT_MEASURE, $MS_TEXT);
// jitter
imagefttext($im, $FONT_LABEL_SIZE, 0, $POSITION_X_JIT - $jitBbox[4] / 2, $POSITION_Y_JIT_LABEL, $TEXT_COLOR_LABEL, $FONT_LABEL, $JIT_TEXT);
imagefttext($im, $FONT_METER_SIZE, 0, $POSITION_X_JIT - $jitMeterBbox[4] / 2 - $msBbox[4] / 2 - $SMALL_SEP / 2, $POSITION_Y_JIT_METER, $TEXT_COLOR_JIT_METER, $FONT_METER, $jit);
imagefttext($im, $FONT_MEASURE_SIZE, 0, $POSITION_X_JIT + $jitMeterBbox[4] / 2 + $SMALL_SEP / 2 - $msBbox[4] / 2, $POSITION_Y_JIT_MEASURE, $TEXT_COLOR_MEASURE, $FONT_MEASURE, $MS_TEXT);
// dl
imagefttext($im, $FONT_LABEL_SIZE_BIG, 0, $POSITION_X_DL - $dlBbox[4] / 2, $POSITION_Y_DL_LABEL, $TEXT_COLOR_LABEL, $FONT_LABEL, $DL_TEXT);
imagefttext($im, $FONT_METER_SIZE_BIG, 0, $POSITION_X_DL - $dlMeterBbox[4] / 2, $POSITION_Y_DL_METER, $TEXT_COLOR_DL_METER, $FONT_METER, $dl);
imagefttext($im, $FONT_MEASURE_SIZE_BIG, 0, $POSITION_X_DL - $mbpsBbox[4] / 2, $POSITION_Y_DL_MEASURE, $TEXT_COLOR_MEASURE, $FONT_MEASURE, $MBPS_TEXT);
// ul
imagefttext($im, $FONT_LABEL_SIZE_BIG, 0, $POSITION_X_UL - $ulBbox[4] / 2, $POSITION_Y_UL_LABEL, $TEXT_COLOR_LABEL, $FONT_LABEL, $UL_TEXT);
imagefttext($im, $FONT_METER_SIZE_BIG, 0, $POSITION_X_UL - $ulMeterBbox[4] / 2, $POSITION_Y_UL_METER, $TEXT_COLOR_UL_METER, $FONT_METER, $ul);
imagefttext($im, $FONT_MEASURE_SIZE_BIG, 0, $POSITION_X_UL - $mbpsBbox[4] / 2, $POSITION_Y_UL_MEASURE, $TEXT_COLOR_MEASURE, $FONT_MEASURE, $MBPS_TEXT);
// isp
imagefttext($im, $FONT_ISP_SIZE, 0, $POSITION_X_ISP, $POSITION_Y_ISP, $TEXT_COLOR_ISP, $FONT_ISP, $ispinfo);
// separator
imagefilledrectangle($im, 0, $SEPARATOR_Y, $WIDTH, $SEPARATOR_Y, $SEPARATOR_COLOR);
// timestamp
imagefttext($im, $FONT_TIMESTAMP_SIZE, 0, $POSITION_X_TIMESTAMP, $POSITION_Y_TIMESTAMP, $TEXT_COLOR_TIMESTAMP, $FONT_TIMESTAMP, $timestamp);
// watermark
imagefttext($im, $FONT_WATERMARK_SIZE, 0, $POSITION_X_WATERMARK, $POSITION_Y_WATERMARK, $TEXT_COLOR_WATERMARK, $FONT_WATERMARK, $WATERMARK_TEXT);
// send the image to the browser
header('Content-Type: image/png');
imagepng($im);
}
/**
* Which of the two designs to draw.
*
* The frontends both link the same URL, so the image cannot tell which page a
* result came from. An explicit style parameter decides, which is what lets the
* modern frontend ask for the design it matches and what makes an existing
* share link render either way on demand.
*
* Without one the image follows useNewDesign, the same switch the frontend
* already reads, so a deployment has one setting rather than two that can
* disagree. A missing or unreadable config.json means classic, which is what
* design-switch.js falls back to as well.
*
* @return string
*/
function resultImageStyle()
{
if (isset($_GET['style'])) {
$style = strtolower(trim((string) $_GET['style']));
if ('modern' === $style) {
return 'modern';
}
if ('classic' === $style) {
return 'classic';
}
}
$config = json_decode((string) @file_get_contents(__DIR__.'/../config.json'), true);
if (is_array($config) && isset($config['useNewDesign']) && true === $config['useNewDesign']) {
return 'modern';
}
return 'classic';
}
$speedtest = getSpeedtestUserById($_GET['id']);
if (!is_array($speedtest)) {
exit(1);
}
if ('modern' === resultImageStyle()) {
drawModernImage($speedtest);
} else {
drawClassicImage($speedtest);
}

62
results/json.php Executable file
View file

@ -0,0 +1,62 @@
<?php
error_reporting(0);
header('Content-Type: application/json; charset=utf-8');
require_once 'telemetry_db.php';
/**
* @param int|float $d
*
* @return string
*/
function format($d)
{
if ($d < 10) {
return number_format($d, 2, '.', '');
}
if ($d < 100) {
return number_format($d, 1, '.', '');
}
return number_format($d, 0, '.', '');
}
/**
* @param array $speedtest
*
* @return array
*/
function formatSpeedtestData($speedtest)
{
// format values for the image
$speedtest['dl'] = format($speedtest['dl']);
$speedtest['ul'] = format($speedtest['ul']);
$speedtest['ping'] = format($speedtest['ping']);
$speedtest['jitter'] = format($speedtest['jitter']);
$speedtest['timestamp'] = $speedtest['timestamp'];
$ispinfo = json_decode($speedtest['ispinfo'], true)['processedString'];
$dash = strpos($ispinfo, '-');
if ($dash !== false) {
$ispinfo = substr($ispinfo, $dash + 2);
$par = strrpos($ispinfo, '(');
if ($par !== false) {
$ispinfo = substr($ispinfo, 0, $par);
}
} else {
$ispinfo = '';
}
$speedtest['ispinfo'] = $ispinfo;
return $speedtest;
}
$speedtest = getSpeedtestUserById($_GET['id']);
if (!is_array($speedtest)) {
echo '{}';
} else {
$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']));
}

189
results/sanitycheck.php Executable file
View file

@ -0,0 +1,189 @@
<?php
require_once 'telemetry_settings.php';
require_once 'telemetry_db.php';
require_once '../backend/getIP_util.php';
error_reporting(E_ALL);
$pass="<span class='Pass'>Pass</span>";
$failed="<span class='Failed'>failed</span>";
$na="<span class='na'>N/A</span>";
?>
<html>
<head>
<title>Speed Test installation sanity check</title>
<style>
table,th,td { border: 1px solid;}
.Pass { color:green;}
.Failed { color:red;}
.na { color:orange;}
.SectionHeading { font-style: italic;}
</style>
</head>
<body>
<table><tr><th>Item</th><th>Status</th><th>Comment</th></tr>
<tr><td colspan="3" class='SectionHeading'>PHP extensions</td></tr>
<tr><td>gd</td><td>
<?php
if(extension_loaded('gd')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td>Used to render result images.</td></tr>
<tr><td>openssl</td><td>
<?php
if(extension_loaded('openssl')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td></td></tr>
<tr><td>pdo_sqlsrv</td><td>
<?php
if(!isset($db_type) || $db_type != 'mssql'){
echo $na;
}elseif(extension_loaded('pdo_sqlsrv')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td>Only required if using MS SQL.</td></tr>
<tr><td>pdo_mysql</td><td>
<?php
if(!isset($db_type) || $db_type != 'mysql'){
echo $na;
}elseif(extension_loaded('pdo_mysql')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td>Only required if using mysql.</td></tr>
<tr><td>pdo_sqlite</td><td>
<?php
if(!isset($db_type) || $db_type != 'sqlite'){
echo $na;
}elseif(extension_loaded('pdo_sqlite')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td>Only required if using sqlite.</td></tr>
<tr><td>pdo_pgsql</td><td>
<?php
if(!isset($db_type) || $db_type != 'postgresql'){
echo $na;
}elseif(extension_loaded('pdo_pgsql')){
echo $pass;
} else {
echo $failed;
}
?>
</td><td>Only required if using postgresql.</td></tr>
<tr><td colspan="3" class='SectionHeading'>Database check</td></tr>
<tr><td>Connecting to DB</td><td>
<?php
$pdo = getPdo(true);
if (($pdo instanceof PDO)) {
echo $pass;
echo "</td><td></td>";
} else {
echo $failed;
echo "</td><td>". htmlspecialchars($pdo) . "</td>";
}
?>
</tr>
<tr><td>Insert into DB</td><td>
<?php
$ip = getClientIp();
$ispinfo="";
$extra='{"DBTest":"This is a simple test of the database. No speed test was done."}';
$ua = $_SERVER['HTTP_USER_AGENT'];
$lang = '';
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
$dl=$ul=$ping=$jitter="";
$log="";
$insertResult = insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log, true);
if(($insertResult instanceof Exception)){
echo $failed;
echo "</td><td>";
echo htmlspecialchars($insertResult->getMessage()) . "</td>";
} else {
echo $pass;
echo "</td><td></td>";
}
?>
</tr>
<tr><td>Read from DB</td><td>
<?php
if(!($insertResult instanceof Exception)){
$QueryResult = getSpeedtestUserById($insertResult,true);
if(($QueryResult instanceof Exception)){
echo $failed;
echo "</td><td>";
echo htmlspecialchars($insertResult->getMessage()) . "</td>";
} elseif(!is_array($QueryResult)) {
echo $failed;
echo "</td><td>Test result not retrieved from database.</td>";
} else {
echo $pass;
echo "</td><td></td>";
}
} else {
echo "</td><td>Insert failed so can't test reading inserted data</td>";
}
?>
</tr>
</table>
</body>
</html>
<?php
/*
$speedtests = getLatestSpeedtestUsers();
print_r ($speedtests);
echo ' ';
print_r($pdo);
if(!isset($pdo)){
echo 'got nothing';
}
if($pdo == false){
echo 'got a false';
}
if (!($pdo instanceof PDO)) {
echo 'not a PDO';
}
if (($pdo instanceof PDO)) {
echo 'is PDO';
}
$speedtest = getSpeedtestUserById(1);
print_r ($speedtest);
*/
?>

317
results/stats.php Normal file → Executable file
View file

@ -1,6 +1,10 @@
<?php
session_start();
error_reporting(0);
require 'telemetry_settings.php';
require_once 'telemetry_db.php';
header('Content-Type: text/html; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
@ -8,163 +12,158 @@ header('Pragma: no-cache');
?>
<!DOCTYPE html>
<html>
<head>
<title>LibreSpeed - Stats</title>
<style type="text/css">
html,body{
margin:0;
padding:0;
border:none;
width:100%; min-height:100%;
}
html{
background-color: hsl(198,72%,35%);
font-family: "Segoe UI","Roboto",sans-serif;
}
body{
background-color:#FFFFFF;
box-sizing:border-box;
width:100%;
max-width:70em;
margin:4em auto;
box-shadow:0 1em 6em #00000080;
padding:1em 1em 4em 1em;
border-radius:0.4em;
}
h1,h2,h3,h4,h5,h6{
font-weight:300;
margin-bottom: 0.1em;
}
h1{
text-align:center;
}
table{
margin:2em 0;
width:100%;
}
table, tr, th, td {
border: 1px solid #AAAAAA;
}
th {
width: 6em;
}
td {
word-break: break-all;
}
</style>
</head>
<body>
<h1>LibreSpeed - Stats</h1>
<?php
include_once("telemetry_settings.php");
require "idObfuscation.php";
if($stats_password=="PASSWORD"){
?>
Please set $stats_password in telemetry_settings.php to enable access.
<?php
}else if($_SESSION["logged"]===true){
if($_GET["op"]=="logout"){
$_SESSION["logged"]=false;
?><script type="text/javascript">window.location=location.protocol+"//"+location.host+location.pathname;</script><?php
}else{
$conn=null;
if($db_type=="mysql"){
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename);
}else if($db_type=="sqlite"){
$conn = new PDO("sqlite:$Sqlite_db_file");
} else if($db_type=="postgresql"){
$conn_host = "host=$PostgreSql_hostname";
$conn_db = "dbname=$PostgreSql_databasename";
$conn_user = "user=$PostgreSql_username";
$conn_password = "password=$PostgreSql_password";
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password");
}else die();
?>
<form action="stats.php" method="GET"><input type="hidden" name="op" value="logout" /><input type="submit" value="Logout" /></form>
<form action="stats.php" method="GET">
<h3>Search test results</h6>
<input type="hidden" name="op" value="id" />
<input type="text" name="id" id="id" placeholder="Test ID" value=""/>
<input type="submit" value="Find" />
<input type="submit" onclick="document.getElementById('id').value=''" value="Show last 100 tests" />
</form>
<?php
$q=null;
if($_GET["op"]=="id"&&!empty($_GET["id"])){
$id=$_GET["id"];
if($enable_id_obfuscation) $id=deobfuscateId($id);
if($db_type=="mysql"){
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users where id=?");
$q->bind_param("i",$id);
$q->execute();
$q->store_result();
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log,$extra);
} else if($db_type=="sqlite"||$db_type=="postgresql"){
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users where id=?");
$q->execute(array($id));
} else die();
}else{
if($db_type=="mysql"){
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users order by timestamp desc limit 0,100");
$q->execute();
$q->store_result();
$q->bind_result($id,$timestamp,$ip,$ispinfo,$ua,$lang,$dl,$ul,$ping,$jitter,$log,$extra);
} else if($db_type=="sqlite"||$db_type=="postgresql"){
$q=$conn->prepare("select id,timestamp,ip,ispinfo,ua,lang,dl,ul,ping,jitter,log,extra from speedtest_users order by timestamp desc limit 0,100");
$q->execute();
}else die();
}
while(true){
$id=null; $timestamp=null; $ip=null; $ispinfo=null; $ua=null; $lang=null; $dl=null; $ul=null; $ping=null; $jitter=null; $log=null; $extra=null;
if($db_type=="mysql"){
if(!$q->fetch()) break;
} else if($db_type=="sqlite"||$db_type=="postgresql"){
if(!($row=$q->fetch())) break;
$id=$row["id"];
$timestamp=$row["timestamp"];
$ip=$row["ip"];
$ispinfo=$row["ispinfo"];
$ua=$row["ua"];
$lang=$row["lang"];
$dl=$row["dl"];
$ul=$row["ul"];
$ping=$row["ping"];
$jitter=$row["jitter"];
$log=$row["log"];
$extra=$row["extra"];
}else die();
?>
<table>
<tr><th>Test ID</th><td><?=htmlspecialchars(($enable_id_obfuscation?(obfuscateId($id)." (deobfuscated: ".$id.")"):$id), ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Date and time</th><td><?=htmlspecialchars($timestamp, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>IP and ISP Info</th><td><?=$ip ?><br/><?=htmlspecialchars($ispinfo, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>User agent and locale</th><td><?=$ua ?><br/><?=htmlspecialchars($lang, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Download speed</th><td><?=htmlspecialchars($dl, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Upload speed</th><td><?=htmlspecialchars($ul, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Ping</th><td><?=htmlspecialchars($ping, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Jitter</th><td><?=htmlspecialchars($jitter, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Log</th><td><?=htmlspecialchars($log, ENT_HTML5, 'UTF-8') ?></td></tr>
<tr><th>Extra info</th><td><?=htmlspecialchars($extra, ENT_HTML5, 'UTF-8') ?></td></tr>
</table>
<?php
}
?>
<?php
}
}else{
if($_GET["op"]=="login"&&$_POST["password"]===$stats_password){
$_SESSION["logged"]=true;
?><script type="text/javascript">window.location=location.protocol+"//"+location.host+location.pathname;</script><?php
}else{
?>
<form action="stats.php?op=login" method="POST">
<h3>Login</h3>
<input type="password" name="password" placeholder="Password" value=""/>
<input type="submit" value="Login" />
</form>
<?php
}
}
?>
</body>
<head>
<title>LibreSpeed - Stats</title>
<style type="text/css">
html,body{
margin:0;
padding:0;
border:none;
width:100%; min-height:100%;
}
html{
background-color: hsl(198,72%,35%);
font-family: "Segoe UI","Roboto",sans-serif;
}
body{
background-color:#FFFFFF;
box-sizing:border-box;
width:100%;
max-width:70em;
margin:4em auto;
box-shadow:0 1em 6em #00000080;
padding:1em 1em 4em 1em;
border-radius:0.4em;
}
h1,h2,h3,h4,h5,h6{
font-weight:300;
margin-bottom: 0.1em;
}
h1{
text-align:center;
}
table{
margin:2em 0;
width:100%;
}
table, tr, th, td {
border: 1px solid #AAAAAA;
}
th {
width: 6em;
}
td {
word-break: break-all;
}
div {
margin: 1em 0;
}
</style>
</head>
<body>
<h1>LibreSpeed - Stats</h1>
<?php
if (!isset($stats_password) || $stats_password === 'PASSWORD') {
?>
Please set $stats_password in telemetry_settings.php to enable access.
<?php
} elseif ($_SESSION['logged'] === true) {
if ($_GET['op'] === 'logout') {
$_SESSION['logged'] = false;
?><script type="text/javascript">window.location=location.protocol+"//"+location.host+location.pathname;</script><?php
} else {
?>
<form action="stats.php" method="GET"><input type="hidden" name="op" value="logout" /><input type="submit" value="Logout" /></form>
<form action="stats.php" method="GET">
<h3>Search test results</h3>
<input type="hidden" name="op" value="id" />
<input type="text" name="id" id="id" placeholder="Test ID" value=""/>
<input type="submit" value="Find" />
<input type="submit" onclick="document.getElementById('id').value=''" value="Show last 100 tests" />
</form>
<?php
if ($_GET['op'] === 'id' && !empty($_GET['id'])) {
$speedtest = getSpeedtestUserById($_GET['id']);
$speedtests = [];
if (false === $speedtest) {
echo '<div>There was an error trying to fetch the test result for ID "'.htmlspecialchars($_GET['id'], ENT_HTML5, 'UTF-8').'".</div>';
} elseif (null === $speedtest) {
echo '<div>Could not find a test result for ID "'.htmlspecialchars($_GET['id'], ENT_HTML5, 'UTF-8').'".</div>';
} else {
$speedtests = [$speedtest];
}
} else {
$speedtests = getLatestSpeedtestUsers();
if (false === $speedtests) {
echo '<div>There was an error trying to fetch latest test results.</div>';
} elseif (empty($speedtests)) {
echo '<div>Could not find any test results in database.</div>';
}
}
foreach ($speedtests as $speedtest) {
?>
<table>
<tr>
<th>Test ID</th>
<td><?= htmlspecialchars($speedtest['id_formatted'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Date and time</th>
<td><?= htmlspecialchars($speedtest['timestamp'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>IP and ISP Info</th>
<td>
<?= htmlspecialchars($speedtest['ip'], ENT_HTML5, 'UTF-8') ?><br/>
<?= htmlspecialchars($speedtest['ispinfo'], ENT_HTML5, 'UTF-8') ?>
</td>
</tr>
<tr>
<th>User agent and locale</th>
<td><?= htmlspecialchars($speedtest['ua'], ENT_HTML5, 'UTF-8') ?><br/>
<?= htmlspecialchars($speedtest['lang'], ENT_HTML5, 'UTF-8') ?>
</td>
</tr>
<tr>
<th>Download speed</th>
<td><?= htmlspecialchars($speedtest['dl'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Upload speed</th>
<td><?= htmlspecialchars($speedtest['ul'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Ping</th>
<td><?= htmlspecialchars($speedtest['ping'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Jitter</th>
<td><?= htmlspecialchars($speedtest['jitter'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Log</th>
<td><?= htmlspecialchars($speedtest['log'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
<tr>
<th>Extra info</th>
<td><?= htmlspecialchars($speedtest['extra'], ENT_HTML5, 'UTF-8') ?></td>
</tr>
</table>
<?php
}
}
} elseif ($_GET['op'] === 'login' && $_POST['password'] === $stats_password) {
$_SESSION['logged'] = true;
?><script type="text/javascript">window.location=location.protocol+"//"+location.host+location.pathname;</script><?php
} else {
?>
<form action="stats.php?op=login" method="POST">
<h3>Login</h3>
<input type="password" name="password" placeholder="Password" value=""/>
<input type="submit" value="Login" />
</form>
<?php
}
?>
</body>
</html>

95
results/telemetry.php Normal file → Executable file
View file

@ -1,68 +1,43 @@
<?php
include_once('telemetry_settings.php');
require 'idObfuscation.php';
$ip=($_SERVER['REMOTE_ADDR']);
$ispinfo=($_POST["ispinfo"]);
$extra=($_POST["extra"]);
$ua=($_SERVER['HTTP_USER_AGENT']);
$lang=""; if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $lang=($_SERVER['HTTP_ACCEPT_LANGUAGE']);
$dl=($_POST["dl"]);
$ul=($_POST["ul"]);
$ping=($_POST["ping"]);
$jitter=($_POST["jitter"]);
$log=($_POST["log"]);
require 'telemetry_settings.php';
require_once 'telemetry_db.php';
require_once '../backend/getIP_util.php';
$ip = getClientIp();
$ispinfo = $_POST['ispinfo'];
$extra = $_POST['extra'];
$ua = $_SERVER['HTTP_USER_AGENT'];
$lang = '';
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
}
$dl = $_POST['dl'];
$ul = $_POST['ul'];
$ping = $_POST['ping'];
$jitter = $_POST['jitter'];
$log = $_POST['log'];
if (isset($redact_ip_addresses) && true === $redact_ip_addresses) {
$ip = '0.0.0.0';
$ipv4_regex = '/(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/';
$ipv6_regex = '/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/';
$hostname_regex = '/"hostname":"([^\\\\"]|\\\\")*"/';
$ispinfo = preg_replace($ipv4_regex, '0.0.0.0', $ispinfo);
$ispinfo = preg_replace($ipv6_regex, '0.0.0.0', $ispinfo);
$ispinfo = preg_replace($hostname_regex, '"hostname":"REDACTED"', $ispinfo);
$log = preg_replace($ipv4_regex, '0.0.0.0', $log);
$log = preg_replace($ipv6_regex, '0.0.0.0', $log);
$log = preg_replace($hostname_regex, '"hostname":"REDACTED"', $log);
}
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0, s-maxage=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
if($db_type=="mysql"){
$conn = new mysqli($MySql_hostname, $MySql_username, $MySql_password, $MySql_databasename) or die("1");
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
$stmt->bind_param("ssssssssss",$ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log) or die("3");
$stmt->execute() or die("4");
$stmt->close() or die("5");
$id=$conn->insert_id;
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
$conn->close() or die("6");
}elseif($db_type=="sqlite"){
$conn = new PDO("sqlite:$Sqlite_db_file") or die("1");
$conn->exec("
CREATE TABLE IF NOT EXISTS `speedtest_users` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`ispinfo` text,
`extra` text,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` text NOT NULL,
`ua` text NOT NULL,
`lang` text NOT NULL,
`dl` text,
`ul` text,
`ping` text,
`jitter` text,
`log` longtext
);
");
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
$id=$conn->lastInsertId();
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
$conn = null;
}elseif($db_type=="postgresql"){
// Prepare connection parameters for db connection
$conn_host = "host=$PostgreSql_hostname";
$conn_db = "dbname=$PostgreSql_databasename";
$conn_user = "user=$PostgreSql_username";
$conn_password = "password=$PostgreSql_password";
// Create db connection
$conn = new PDO("pgsql:$conn_host;$conn_db;$conn_user;$conn_password") or die("1");
$stmt = $conn->prepare("INSERT INTO speedtest_users (ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log) VALUES (?,?,?,?,?,?,?,?,?,?)") or die("2");
$stmt->execute(array($ip,$ispinfo,$extra,$ua,$lang,$dl,$ul,$ping,$jitter,$log)) or die("3");
$id=$conn->lastInsertId();
echo "id ".($enable_id_obfuscation?obfuscateId($id):$id);
$conn = null;
$id = insertSpeedtestUser($ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log);
if (false === $id) {
exit(1);
}
else die("-1");
?>
echo 'id '.$id;

316
results/telemetry_db.php Executable file
View file

@ -0,0 +1,316 @@
<?php
require_once 'idObfuscation.php';
define('TELEMETRY_SETTINGS_FILE', 'telemetry_settings.php');
/**
* @return PDO|false
*/
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;
}
$pdoOptions = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
];
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, $MsSql_username, $MsSql_password, $pdoOptions);
}
}
if ('mysql' === $db_type) {
if (!isset(
$MySql_hostname,
$MySql_port,
$MySql_databasename,
$MySql_username,
$MySql_password
)) {
if($returnErrorMessage){
return "Required mysql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
return false;
}
$dsn = 'mysql:'
.'host='.$MySql_hostname
.';port='.$MySql_port
.';dbname='.$MySql_databasename;
return new PDO($dsn, $MySql_username, $MySql_password, $pdoOptions);
}
if ('sqlite' === $db_type) {
if (!isset($Sqlite_db_file)) {
if($returnErrorMessage){
return "Required sqlite database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
return false;
}
// Check if directory exists and is writable
$db_dir = dirname($Sqlite_db_file);
if (!is_dir($db_dir)) {
if ($returnErrorMessage) {
return "SQLite database directory does not exist: " . $db_dir . ". Please create it and ensure it's writable by the web server.";
}
return false;
}
if (!is_writable($db_dir)) {
if ($returnErrorMessage) {
return "SQLite database directory is not writable: " . $db_dir . ". Please ensure the web server has write permissions (e.g., chmod 755 or 775).";
}
return false;
}
$pdo = new PDO('sqlite:'.$Sqlite_db_file, null, null, $pdoOptions);
# TODO: Why create table only in sqlite mode?
$pdo->exec('
CREATE TABLE IF NOT EXISTS `speedtest_users` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`ispinfo` text,
`extra` text,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`ip` text NOT NULL,
`ua` text NOT NULL,
`lang` text NOT NULL,
`dl` text,
`ul` text,
`ping` text,
`jitter` text,
`log` longtext
);
');
return $pdo;
}
if ('postgresql' === $db_type) {
if (!isset(
$PostgreSql_hostname,
$PostgreSql_databasename,
$PostgreSql_username,
$PostgreSql_password
)) {
if($returnErrorMessage){
return "Required postgresql database settings missing in '" . TELEMETRY_SETTINGS_FILE . "'";
}
return false;
}
$dsn = 'pgsql:'
.'host='.$PostgreSql_hostname
.';dbname='.$PostgreSql_databasename;
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;
}
/**
* @return bool
*/
function isObfuscationEnabled()
{
require TELEMETRY_SETTINGS_FILE;
return
isset($enable_id_obfuscation)
&& true === $enable_id_obfuscation;
}
/**
* @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, $returnExceptionOnError = false)
{
$pdo = getPdo();
if (!($pdo instanceof PDO)) {
if($returnExceptionOnError){
return new Exception("Failed to get database connection object");
}
return false;
}
try {
$stmt = $pdo->prepare(
'INSERT INTO speedtest_users
(ip,ispinfo,extra,ua,lang,dl,ul,ping,jitter,log)
VALUES (?,?,?,?,?,?,?,?,?,?)'
);
$stmt->execute([
$ip, $ispinfo, $extra, $ua, $lang, $dl, $ul, $ping, $jitter, $log
]);
$id = $pdo->lastInsertId();
} catch (Exception $e) {
if($returnExceptionOnError){
return $e;
}
return false;
}
if (isObfuscationEnabled()) {
return obfuscateId($id);
}
return $id;
}
/**
* @param int|string $id
*
* @return array|null|false|exception returns the speedtest data as array, null
* if no data is found for the given id or
* false or an exception if there was an error (based on returnExceptionOnError)
*
* @throws RuntimeException
*/
function getSpeedtestUserById($id,$returnExceptionOnError = false)
{
$pdo = getPdo();
if (!($pdo instanceof PDO)) {
if($returnExceptionOnError){
return new Exception("Failed to get database connection object");
}
return false;
}
if (isObfuscationEnabled()) {
$id = deobfuscateId($id);
}
try {
$stmt = $pdo->prepare(
'SELECT
id, timestamp, ip, ispinfo, ua, lang, dl, ul, ping, jitter, log, extra
FROM speedtest_users
WHERE id = :id'
);
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
} catch (Exception $e) {
if($returnExceptionOnError){
return $e;
}
return false;
}
if (!is_array($row)) {
return null;
}
$row['id_formatted'] = $row['id'];
if (isObfuscationEnabled()) {
$row['id_formatted'] = obfuscateId($row['id']).' (deobfuscated: '.$row['id'].')';
}
return $row;
}
/**
* @return array|false
*/
function getLatestSpeedtestUsers()
{
$pdo = getPdo();
if (!($pdo instanceof PDO)) {
return false;
}
require TELEMETRY_SETTINGS_FILE;
try {
$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 ';
if('mssql' !== $db_type) {$sql .= ' LIMIT 100 ';}
$stmt = $pdo->query($sql);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $i => $row) {
$rows[$i]['id_formatted'] = $row['id'];
if (isObfuscationEnabled()) {
$rows[$i]['id_formatted'] = obfuscateId($row['id']).' (deobfuscated: '.$row['id'].')';
}
}
} catch (Exception $e) {
return false;
}
return $rows;
}

36
results/telemetry_mssql.sql Executable file
View file

@ -0,0 +1,36 @@
CREATE DATABASE librespeed;
GO
USE librespeed;
GO
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

2
results/telemetry_mysql.sql Normal file → Executable file
View file

@ -32,7 +32,7 @@ CREATE TABLE `speedtest_users` (
`ping` text,
`jitter` text,
`log` longtext
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
--
-- Indexes for dumped tables

6
results/telemetry_postgresql.sql Normal file → Executable file
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

43
results/telemetry_settings.php Normal file → Executable file
View file

@ -1,24 +1,35 @@
<?php
$db_type="mysql"; //Type of db: "mysql", "sqlite" or "postgresql"
$stats_password="PASSWORD"; //password to login to stats.php. Change this!!!
$enable_id_obfuscation=false; //if set to true, test IDs will be obfuscated to prevent users from guessing URLs of other tests
// Type of db: "mssql", "mysql", "sqlite" or "postgresql"
$db_type = 'sqlite';
// Password to login to stats.php. Change this!!!
$stats_password = 'PASSWORD';
// If set to true, test IDs will be obfuscated to prevent users from guessing URLs of other tests
$enable_id_obfuscation = false;
// If set to true, IP addresses will be redacted from IP and ISP info fields, as well as the log
$redact_ip_addresses = false;
// Sqlite3 settings
$Sqlite_db_file = "../../speedtest_telemetry.sql";
$Sqlite_db_file = __DIR__ . '/../../speedtest_telemetry.db';
// mssql settings
$MsSql_server = 'DB_HOSTNAME';
$MsSql_databasename = 'DB_NAME';
$MsSql_WindowsAuthentication = true; //true or false
$MsSql_username = 'USERNAME'; //not used if MsSql_WindowsAuthentication is true
$MsSql_password = 'PASSWORD'; //not used if MsSql_WindowsAuthentication is true
$MsSql_TrustServerCertificate = true; //true, false or comment out for driver default
//Download driver from https://docs.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server?view=sql-server-ver16
// Mysql settings
$MySql_username="USERNAME";
$MySql_password="PASSWORD";
$MySql_hostname="DB_HOSTNAME";
$MySql_databasename="DB_NAME";
$MySql_username = 'USERNAME';
$MySql_password = 'PASSWORD';
$MySql_hostname = 'DB_HOSTNAME';
$MySql_databasename = 'DB_NAME';
$MySql_port = '3306';
// Postgresql settings
$PostgreSql_username="USERNAME";
$PostgreSql_password="PASSWORD";
$PostgreSql_hostname="DB_HOSTNAME";
$PostgreSql_databasename="DB_NAME";
//IMPORTANT: DO NOT ADD ANYTHING BELOW THIS PHP CLOSING TAG, NOT EVEN EMPTY LINES!
?>
$PostgreSql_username = 'USERNAME';
$PostgreSql_password = 'PASSWORD';
$PostgreSql_hostname = 'DB_HOSTNAME';
$PostgreSql_databasename = 'DB_NAME';

409
server-list.json Normal file
View file

@ -0,0 +1,409 @@
[
{
"name": "Amsterdam, Netherlands",
"server": "//ams.speedtest.clouvider.net/backend",
"id": 51,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Amsterdam, Netherlands (Rust backend)",
"server": "https://librespeed-rs.ir/",
"id": 95,
"dlURL": "backend/garbage",
"ulURL": "backend/empty",
"pingURL": "backend/empty",
"getIpURL": "backend/getIP",
"sponsorName": "Sudo Dios",
"sponsorURL": "https://github.com/SudoDios"
},
{
"name": "Amsterdam, Netherlands",
"server": "https://amsspeed.sharktech.net",
"id": 94,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Atlanta, United States",
"server": "//atl.speedtest.clouvider.net/backend",
"id": 53,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Bangalore, India",
"server": "//in1.backend.librespeed.org/",
"id": 75,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "DigitalOcean",
"sponsorURL": "https://www.digitalocean.com"
},
{
"name": "Bari, Italy",
"server": "https://st-be-ba1.infra.garr.it",
"id": 33,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Bologna, Italy",
"server": "https://st-be-bo1.infra.garr.it",
"id": 34,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Chicago, USA",
"server": "https://chispeed.sharktech.net",
"id": 93,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Denver, USA",
"server": "https://denspeed.sharktech.net",
"id": 92,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "Frankfurt, Germany",
"server": "//fra.speedtest.clouvider.net/backend",
"id": 50,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Frankfurt, Germany (FRA01)",
"server": "https://speedtest.lumischvps.cloud/",
"id": 86,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "LumischVPS",
"sponsorURL": "https://discord.gg/GxYzPwJmA2"
},
{
"name": "Ghom, Iran (Amin IDC)",
"server": "https://fastme.ir/",
"id": 77,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech/"
},
{
"name": "Helsinki, Finland (3) (Hetzner)",
"server": "//finew.openspeed.org/",
"id": 22,
"dlURL": "backend437/garbage.php",
"ulURL": "backend437/empty.php",
"pingURL": "backend437/empty.php",
"getIpURL": "backend437/getIP.php",
"sponsorName": "Daily Health Insurance Group",
"sponsorURL": "//dhig.net/"
},
{
"name": "Helsinki, Finland (5) (Hetzner)",
"server": "//fast.kabi.tk/",
"id": 24,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "KABI.tk",
"sponsorURL": "//kabi.tk"
},
{
"name": "Johannesburg, South Africa",
"server": "//za1.backend.librespeed.org/",
"id": 70,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "HOSTAFRICA",
"sponsorURL": "https://www.hostafrica.co.za"
},
{
"name": "Las Vegas, USA",
"server": "https://lasspeed.sharktech.net",
"id": 90,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "London, England",
"server": "//lon.speedtest.clouvider.net/backend",
"id": 49,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Los Angeles, United States (1)",
"server": "//la.speedtest.clouvider.net/backend",
"id": 54,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Los Angeles, USA",
"server": "https://laxspeed.sharktech.net",
"id": 91,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Sharktech",
"sponsorURL": "https://sharktech.net"
},
{
"name": "New York, United States (2)",
"server": "//nyc.speedtest.clouvider.net/backend",
"id": 52,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Clouvider",
"sponsorURL": "https://www.clouvider.co.uk/"
},
{
"name": "Nottingham, England (LayerIP)",
"server": "https://uk1.backend.librespeed.org",
"id": 43,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "fosshost.org",
"sponsorURL": "https://fosshost.org"
},
{
"name": "Nuremberg, Germany (1) (Hetzner)",
"server": "//de1.backend.librespeed.org",
"id": 28,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Snopyta",
"sponsorURL": "https://snopyta.org"
},
{
"name": "Nuremberg, Germany (2) (Hetzner)",
"server": "//de4.backend.librespeed.org",
"id": 27,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (3) (Hetzner)",
"server": "//de3.backend.librespeed.org",
"id": 30,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (4) (Hetzner)",
"server": "//de5.backend.librespeed.org",
"id": 31,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "LibreSpeed",
"sponsorURL": "https://librespeed.org"
},
{
"name": "Nuremberg, Germany (6) (Hetzner)",
"server": "//librespeed.lukas-heinrich.com/",
"id": 46,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "luki9100",
"sponsorURL": "https://lukas-heinrich.com/"
},
{
"name": "Poznan, Poland (INEA)",
"server": "https://speedtest.kamilszczepanski.com",
"id": 74,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Kamil Szczepa\u0144ski",
"sponsorURL": "https://kamilszczepanski.com"
},
{
"name": "Prague, Czech Republic",
"server": "//speedtest.cesnet.cz",
"id": 79,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "CESNET",
"sponsorURL": "https://www.cesnet.cz"
},
{
"name": "Prague, Czech Republic",
"server": "//librespeed.turris.cz",
"id": 85,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Turris",
"sponsorURL": "https://www.turris.com"
},
{
"name": "Roma, Italy",
"server": "https://st-be-rm2.infra.garr.it",
"id": 35,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Consortium GARR",
"sponsorURL": "//garr.it"
},
{
"name": "Serbia",
"server": "https://speedtest2.sox.rs",
"id": 87,
"dlURL": "libre/backend/garbage.php",
"ulURL": "libre/backend/empty.php",
"pingURL": "libre/backend/empty.php",
"getIpURL": "libre/backend/getIP.php",
"sponsorName": "Serbian Open eXchange",
"sponsorURL": "https://sox.rs"
},
{
"name": "Singapore",
"server": "https://speedtest.dsgroupmedia.com",
"id": 68,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Salvatore Cahyo",
"sponsorURL": "https://salvatorecahyo.my.id"
},
{
"name": "Tehran, Iran (Fanava)",
"server": "https://speedme.ir/",
"id": 76,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech"
},
{
"name": "Tehran, Iran (Faraso)",
"server": "https://st.bardia.tech",
"id": 80,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "Bardia Moshiri",
"sponsorURL": "https://bardia.tech/"
},
{
"name": "Tokyo, Japan",
"server": "https://librespeed.a573.net/",
"id": 82,
"dlURL": "backend/garbage.php",
"ulURL": "backend/empty.php",
"pingURL": "backend/empty.php",
"getIpURL": "backend/getIP.php",
"sponsorName": "A573",
"sponsorURL": "https://mirror.a573.net/"
},
{
"name": "Vilnius, Lithuania (RackRay)",
"server": "//lt1.backend.librespeed.org/",
"id": 69,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Time4VPS",
"sponsorURL": "https://www.time4vps.com"
},
{
"name": "Virginia, United States, OVH",
"server": "https://speed.riverside.rocks/",
"id": 78,
"dlURL": "garbage.php",
"ulURL": "empty.php",
"pingURL": "empty.php",
"getIpURL": "getIP.php",
"sponsorName": "Riverside Rocks",
"sponsorURL": "https://riverside.rocks"
}
]

9
settings.json Normal file
View file

@ -0,0 +1,9 @@
{
"telemetry_level": "off",
"test_order": "ID_U_P",
"time_dl_max": 12,
"time_ul_max": 12,
"time_dlGraceTime": 0,
"time_ulGraceTime": 0,
"time_auto": false
}

230
speedtest.js Normal file → Executable file
View file

@ -6,15 +6,15 @@
*/
/*
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.
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();
let s=new Speedtest();
Now 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) method. 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) method. 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:
{
@ -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
@ -46,10 +46,13 @@
function Speedtest() {
this._serverList = []; //when using multiple points of test, this is a list of test points
this._selectedServer = null; //when using multiple points of test, this is the selected server
this._settings = {}; //settings for the speedtest worker
this._settings = {}; //settings for the speed test worker
this._state = 0; //0=adding settings, 1=adding servers, 2=server selection done, 3=test running, 4=done
this.worker = null;
this.updater = null;
this._activeRun = null;
console.log(
"LibreSpeed by Federico Dossena v5.1 - https://github.com/librespeed/speedtest"
"LibreSpeed by Federico Dossena v6.3.1 - https://github.com/librespeed/speedtest"
);
}
@ -66,13 +69,13 @@ Speedtest.prototype = {
* - 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 nonexistent parameters will be ignored by the speed test worker.
*/
setParameter: function(parameter, value) {
if (this._state != 0)
throw "You cannot change the test settings after adding server or starting the test";
if (this._state == 3)
throw "You cannot change the test settings while running the test";
this._settings[parameter] = value;
if(parameter === "temeletry_extra"){
if(parameter === "telemetry_extra"){
this._originalExtra=this._settings.telemetry_extra;
}
},
@ -125,7 +128,41 @@ Speedtest.prototype = {
* Same as addTestPoint, but you can pass an array of servers
*/
addTestPoints: function(list) {
for (var i = 0; i < list.length; i++) this.addTestPoint(list[i]);
for (let i = 0; i < list.length; i++) this.addTestPoint(list[i]);
},
/**
* Load a JSON server list from URL (multiple points of test)
* url: the url where the server list can be fetched. Must be an array with objects containing the following elements:
* {
* "name": "User friendly name",
* "server":"http://yourBackend.com/", URL to your server. You can specify http:// or https://. If your server supports both, just write // without the protocol
* "dlURL":"garbage.php" path to garbage.php or its replacement on the server
* "ulURL":"empty.php" path to empty.php or its replacement on the server
* "pingURL":"empty.php" path to empty.php or its replacement on the server. This is used to ping the server by this selector
* "getIpURL":"getIP.php" path to getIP.php or its replacement on the server
* }
* result: callback to be called when the list is loaded correctly. An array with the loaded servers will be passed to this function, or null if it failed
*/
loadServerList: function(url,result) {
if (this._state == 0) this._state = 1;
if (this._state != 1) throw "You can't add a server after server selection";
this._settings.mpot = true;
let xhr = new XMLHttpRequest();
xhr.onload = function(){
try{
const servers=JSON.parse(xhr.responseText);
for(let i=0;i<servers.length;i++){
this._checkServerDefinition(servers[i]);
}
this.addTestPoints(servers);
result(servers);
}catch(e){
result(null);
}
}.bind(this);
xhr.onerror = function(){result(null);}
xhr.open("GET",url);
xhr.send();
},
/**
* Returns the selected server (multiple points of test)
@ -157,37 +194,37 @@ Speedtest.prototype = {
throw "You can't select a server while the test is running";
}
if (this._selectServerCalled) throw "selectServer already called"; else this._selectServerCalled=true;
/*this function goes through a list of servers. For each server, the ping is measured, then the server with the function result is called with the best server, or null if all the servers were down.
/*this function goes through a list of servers. For each server, the ping is measured, then the server with the function selected is called with the best server, or null if all the servers were down.
*/
var select = function(serverList, result) {
const select = function(serverList, selected) {
//pings the specified URL, then calls the function result. Result will receive a parameter which is either the time it took to ping the URL, or -1 if something went wrong.
var PING_TIMEOUT = 2000;
var USE_PING_TIMEOUT = true; //will be disabled on unsupported browsers
const PING_TIMEOUT = 2000;
let USE_PING_TIMEOUT = true; //will be disabled on unsupported browsers
if (/MSIE.(\d+\.\d+)/i.test(navigator.userAgent)) {
//IE11 doesn't support XHR timeout
USE_PING_TIMEOUT = false;
}
var ping = function(url, result) {
const ping = function(url, rtt) {
url += (url.match(/\?/) ? "&" : "?") + "cors=true";
var xhr = new XMLHttpRequest();
var t = new Date().getTime();
let xhr = new XMLHttpRequest();
let t = new Date().getTime();
xhr.onload = function() {
if (xhr.responseText.length == 0) {
//we expect an empty response
var instspd = new Date().getTime() - t; //rough timing estimate
let instspd = new Date().getTime() - t; //rough timing estimate
try {
//try to get more accurate timing using performance API
var p = performance.getEntriesByName(url);
let p = performance.getEntriesByName(url);
p = p[p.length - 1];
var d = p.responseStart - p.requestStart;
let d = p.responseStart - p.requestStart;
if (d <= 0) d = p.duration;
if (d > 0 && d < instspd) instspd = d;
} catch (e) {}
result(instspd);
} else result(-1);
rtt(instspd);
} else rtt(-1);
}.bind(this);
xhr.onerror = function() {
result(-1);
rtt(-1);
}.bind(this);
xhr.open("GET", url);
if (USE_PING_TIMEOUT) {
@ -200,14 +237,18 @@ Speedtest.prototype = {
}.bind(this);
//this function repeatedly pings a server to get a good estimate of the ping. When it's done, it calls the done function without parameters. At the end of the execution, the server will have a new parameter called pingT, which is either the best ping we got from the server or -1 if something went wrong.
var PINGS = 3, //up to 3 pings are performed, unless the server is down...
const PINGS = 3, //up to 3 pings are performed, unless the server is down...
SLOW_THRESHOLD = 500; //...or one of the pings is above this threshold
var checkServer = function(server, done) {
var i = 0;
const checkServer = function(server, done) {
let i = 0;
server.pingT = -1;
if (server.server.indexOf(location.protocol) == -1) done();
if (
location.protocol === "https:" &&
server.server.substring(0, 7).toLowerCase() === "http://"
)
done();
else {
var nextPing = function() {
const nextPing = function() {
if (i++ == PINGS) {
done();
return;
@ -227,19 +268,19 @@ Speedtest.prototype = {
}
}.bind(this);
//check servers in list, one by one
var i = 0;
var done = function() {
var bestServer = null;
for (var i = 0; i < serverList.length; i++) {
let i = 0;
const done = function() {
let bestServer = null;
for (let i = 0; i < serverList.length; i++) {
if (
serverList[i].pingT != -1 &&
(bestServer == null || serverList[i].pingT < bestServer.pingT)
)
bestServer = serverList[i];
}
result(bestServer);
selected(bestServer);
}.bind(this);
var nextServer = function() {
const nextServer = function() {
if (i == serverList.length) {
done();
return;
@ -250,17 +291,17 @@ Speedtest.prototype = {
}.bind(this);
//parallel server selection
var CONCURRENCY = 6;
var serverLists = [];
for (var i = 0; i < CONCURRENCY; i++) {
const CONCURRENCY = 6;
let serverLists = [];
for (let i = 0; i < CONCURRENCY; i++) {
serverLists[i] = [];
}
for (var i = 0; i < this._serverList.length; i++) {
for (let i = 0; i < this._serverList.length; i++) {
serverLists[i % CONCURRENCY].push(this._serverList[i]);
}
var completed = 0;
var bestServer = null;
for (var i = 0; i < CONCURRENCY; i++) {
let completed = 0;
let bestServer = null;
for (let i = 0; i < CONCURRENCY; i++) {
select(
serverLists[i],
function(server) {
@ -285,34 +326,79 @@ Speedtest.prototype = {
*/
start: function() {
if (this._state == 3) throw "Test already running";
this.worker = new Worker("speedtest_worker.js?r=" + Math.random());
this.worker.onmessage = function(e) {
if (e.data === this._prevData) return;
else this._prevData = e.data;
var data = JSON.parse(e.data);
if (this._state == 1)
throw "When using multiple points of test, you must call selectServer before starting the test";
const worker = new Worker("speedtest_worker.js?r=" + Math.random());
const run = {
worker: worker,
updater: null,
abortTimeout: null,
ended: false,
prevData: null
};
const isCurrentRun = function() {
return this._activeRun === run && this.worker === worker;
}.bind(this);
const armAbortTimeout = function() {
if (run.abortTimeout !== null) clearTimeout(run.abortTimeout);
run.abortTimeout = setTimeout(function() {
if (this._activeRun === run && this.worker === run.worker)
run.finish(true);
}.bind(this), 1000);
}.bind(this);
const finish = function(aborted) {
if (run.ended) return;
run.ended = true;
if (run.updater !== null) {
clearInterval(run.updater);
run.updater = null;
}
if (run.abortTimeout !== null) {
clearTimeout(run.abortTimeout);
run.abortTimeout = null;
}
worker.terminate();
// A callback may synchronously start another run, so clean up this run first.
if (!isCurrentRun()) return;
this._activeRun = null;
this.worker = null;
this.updater = null;
this._state = 4;
try {
if (this.onend) this.onend(aborted);
} catch (e) {
console.error("Speedtest onend event threw exception: " + e);
}
}.bind(this);
run.armAbortTimeout = armAbortTimeout;
run.finish = finish;
this._activeRun = run;
this.worker = worker;
worker.onmessage = function(e) {
if (!isCurrentRun() || run.ended) return;
const data = JSON.parse(e.data);
// While an aborted run is submitting telemetry, each status response
// proves that the worker is still responsive, so keep its watchdog alive.
if (data.abortPending && run.abortTimeout !== null) armAbortTimeout();
if (e.data === run.prevData) return;
else run.prevData = e.data;
try {
if (this.onupdate) this.onupdate(data);
} catch (e) {
console.error("Speedtest onupdate event threw exception: " + e);
}
if (data.testState >= 4) {
try {
if (this.onend) this.onend(data.testState == 5);
} catch (e) {
console.error("Speedtest onend event threw exception: " + e);
}
clearInterval(this.updater);
this._state = 4;
}
if (data.testState >= 4) finish(data.testState == 5);
}.bind(this);
this.updater = setInterval(
run.updater = setInterval(
function() {
this.worker.postMessage("status");
}.bind(this),
if (isCurrentRun() && !run.ended) worker.postMessage("status");
},
200
);
if (this._state == 1)
throw "When using multiple points of test, you must call selectServer before starting the test";
this.updater = run.updater;
if (this._state == 2) {
this._settings.url_dl =
this._selectedServer.server + this._selectedServer.dlURL;
@ -333,13 +419,19 @@ Speedtest.prototype = {
});
}
this._state = 3;
this.worker.postMessage("start " + JSON.stringify(this._settings));
worker.postMessage("start " + JSON.stringify(this._settings));
},
/**
* Aborts the test while it's running.
*/
abort: function() {
if (this._state < 3) throw "You cannot abort a test that's not started yet";
if (this._state < 4) this.worker.postMessage("abort");
const run = this._activeRun;
if (this._state < 4 && run && this.worker === run.worker) {
run.worker.postMessage("abort");
if (!run.ended && run.abortTimeout === null) {
run.armAbortTimeout();
}
}
}
};

224
speedtest_worker.js Normal file → Executable file
View file

@ -6,18 +6,19 @@
*/
// data reported to main thread
var testState = -1; // -1=not started, 0=starting, 1=download test, 2=ping+jitter test, 3=upload test, 4=finished, 5=abort
var dlStatus = ""; // download speed in megabit/s with 2 decimal digits
var ulStatus = ""; // upload speed in megabit/s with 2 decimal digits
var pingStatus = ""; // ping in milliseconds with 2 decimal digits
var jitterStatus = ""; // jitter in milliseconds with 2 decimal digits
var clientIp = ""; // client's IP address as reported by getIP.php
var dlProgress = 0; //progress of download test 0-1
var ulProgress = 0; //progress of upload test 0-1
var pingProgress = 0; //progress of ping+jitter test 0-1
var testId = null; //test ID (sent back by telemetry if used, null otherwise)
let testState = -1; // -1=not started, 0=starting, 1=download test, 2=ping+jitter test, 3=upload test, 4=finished, 5=abort
let dlStatus = ""; // download speed in megabit/s with 2 decimal digits
let ulStatus = ""; // upload speed in megabit/s with 2 decimal digits
let pingStatus = ""; // ping in milliseconds with 2 decimal digits
let jitterStatus = ""; // jitter in milliseconds with 2 decimal digits
let clientIp = ""; // client's IP address as reported by getIP.php
let dlProgress = 0; //progress of download test 0-1
let ulProgress = 0; //progress of upload test 0-1
let pingProgress = 0; //progress of ping+jitter test 0-1
let testId = null; //test ID (sent back by telemetry if used, null otherwise)
let abortPending = false; // true while aborted-run telemetry is being submitted
var log = ""; //telemetry log
let log = ""; //telemetry log
function tlog(s) {
if (settings.telemetry_level >= 2) {
log += Date.now() + ": " + s + "\n";
@ -36,7 +37,7 @@ function twarn(s) {
}
// test settings. can be overridden by sending specific values with the start command
var settings = {
let settings = {
mpot: false, //set to true when in MPOT mode
test_order: "IP_D_U", //order in which tests will be performed as a string. D=Download, U=Upload, P=Ping+Jitter, I=IP, _=1 second delay
time_ul_max: 15, // max duration of upload test in seconds
@ -60,16 +61,17 @@ 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
telemetry_extra: "", //extra data that can be passed to the telemetry through the settings
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
var interval = null; // timer used in tests
var test_pointer = 0; //pointer to the next test to run inside settings.test_order
let xhr = null; // array of currently active xhr requests
let interval = null; // timer used in tests
let test_pointer = 0; //pointer to the next test to run inside settings.test_order
/*
this function is used on URLs passed in the settings to determine whether we need a ? or an & as a separator
@ -87,7 +89,7 @@ function url_sep(url) {
example: start {"time_ul_max":"10", "time_dl_max":"10", "count_ping":"50"}
*/
this.addEventListener("message", function(e) {
var params = e.data.split(" ");
const params = e.data.split(" ");
if (params[0] === "status") {
// return status
postMessage(
@ -101,7 +103,8 @@ this.addEventListener("message", function(e) {
dlProgress: dlProgress,
ulProgress: ulProgress,
pingProgress: pingProgress,
testId: testId
testId: testId,
abortPending: abortPending
})
);
}
@ -110,27 +113,23 @@ this.addEventListener("message", function(e) {
testState = 0;
try {
// parse settings, if present
var s = {};
let s = {};
try {
var ss = e.data.substring(5);
const ss = e.data.substring(5);
if (ss) s = JSON.parse(ss);
} catch (e) {
twarn("Error parsing custom settings JSON. Please check your syntax");
}
//copy custom settings
for (var key in s) {
for (let key in s) {
if (typeof settings[key] !== "undefined") settings[key] = s[key];
else twarn("Unknown setting ignored: " + key);
}
const ua = navigator.userAgent;
// quirks for specific browsers. apply only if not overridden. more may be added in future releases
if (settings.enable_quirks || (typeof s.enable_quirks !== "undefined" && s.enable_quirks)) {
var ua = navigator.userAgent;
if (/Firefox.(\d+\.\d+)/i.test(ua)) {
if (typeof s.xhr_ulMultistream === "undefined") {
// ff more precise with 1 upload stream
settings.xhr_ulMultistream = 1;
}
if (typeof s.xhr_ulMultistream === "undefined") {
if (typeof s.ping_allowPerformanceApi === "undefined") {
// ff performance API sucks
settings.ping_allowPerformanceApi = false;
}
@ -149,22 +148,22 @@ this.addEventListener("message", function(e) {
}
}
if (/Edge.(\d+\.\d+)/i.test(ua)) {
//Edge 15 introduced a bug that causes onprogress events to not get fired, we have to use the "small chunks" workaround that reduces accuracy
settings.forceIE11Workaround = true;
if (typeof s.forceIE11Workaround === "undefined") {
//Edge 15 introduced a bug that causes onprogress events to not get fired, we have to use the "small chunks" workaround that reduces accuracy
settings.forceIE11Workaround = true;
}
}
if (/PlayStation 4.(\d+\.\d+)/i.test(ua)) {
//PS4 browser has the same bug as IE11/Edge
settings.forceIE11Workaround = true;
if (typeof s.forceIE11Workaround === "undefined") {
//PS4 browser has the same bug as IE11/Edge
settings.forceIE11Workaround = true;
}
}
if (/Chrome.(\d+)/i.test(ua) && /Android|iPhone|iPad|iPod|Windows Phone/i.test(ua)) {
//cheap af
//Chrome mobile introduced a limitation somewhere around version 65, we have to limit XHR upload size to 4 megabytes
settings.xhr_ul_blob_megabytes = 4;
}
if (/^((?!chrome|android|crios|fxios).)*safari/i.test(ua)) {
//Safari also needs the IE11 workaround but only for the MPOT version
settings.forceIE11Workaround = true;
}
//telemetry_level has to be parsed and not just copied
if (typeof s.telemetry_level !== "undefined") settings.telemetry_level = s.telemetry_level === "basic" ? 1 : s.telemetry_level === "full" ? 2 : s.telemetry_level === "debug" ? 3 : 0; // telemetry level
//transform test_order to uppercase, just in case
@ -175,11 +174,11 @@ this.addEventListener("message", function(e) {
// run the tests
tverb(JSON.stringify(settings));
test_pointer = 0;
var iRun = false,
let iRun = false,
dRun = false,
uRun = false,
pRun = false;
var runNextTest = function() {
const runNextTest = function() {
if (testState == 5) return;
if (test_pointer >= settings.test_order.length) {
//test is finished
@ -249,13 +248,12 @@ this.addEventListener("message", function(e) {
}
if (params[0] === "abort") {
// abort command
if (testState >= 4) return;
if (testState >= 4 || abortPending) return;
tlog("manually aborted");
clearRequests(); // stop all xhr activity
runNextTest = null;
if (interval) clearInterval(interval); // clear timer if present
if (settings.telemetry_level > 1) sendTelemetry(function() {});
testState = 5; //set test as aborted
abortPending = settings.telemetry_level > 1;
dlStatus = "";
ulStatus = "";
pingStatus = "";
@ -264,13 +262,19 @@ this.addEventListener("message", function(e) {
dlProgress = 0;
ulProgress = 0;
pingProgress = 0;
const completeAbort = function() {
abortPending = false;
testState = 5; //set test as aborted
};
if (abortPending) sendTelemetry(completeAbort);
else completeAbort();
}
});
// stops all XHR activity, aggressively
function clearRequests() {
tverb("stopping pending XHRs");
if (xhr) {
for (var i = 0; i < xhr.length; i++) {
for (let i = 0; i < xhr.length; i++) {
try {
xhr[i].onprogress = null;
xhr[i].onload = null;
@ -292,18 +296,18 @@ function clearRequests() {
}
}
// gets client's IP using url_getIp, then calls the done function
var ipCalled = false; // used to prevent multiple accidental calls to getIp
var ispInfo = ""; //used for telemetry
let ipCalled = false; // used to prevent multiple accidental calls to getIp
let ispInfo = ""; //used for telemetry
function getIp(done) {
tverb("getIp");
if (ipCalled) return;
else ipCalled = true; // getIp already called?
var startT = new Date().getTime();
let startT = new Date().getTime();
xhr = new XMLHttpRequest();
xhr.onload = function() {
tlog("IP: " + xhr.responseText + ", took " + (new Date().getTime() - startT) + "ms");
try {
var data = JSON.parse(xhr.responseText);
const data = JSON.parse(xhr.responseText);
clientIp = data.processedString;
ispInfo = data.rawIspInfo;
} catch (e) {
@ -320,25 +324,25 @@ function getIp(done) {
xhr.send();
}
// download test, calls done function when it's over
var dlCalled = false; // used to prevent multiple accidental calls to dlTest
let dlCalled = false; // used to prevent multiple accidental calls to dlTest
function dlTest(done) {
tverb("dlTest");
if (dlCalled) return;
else dlCalled = true; // dlTest already called?
var totLoaded = 0.0, // total number of loaded bytes
let totLoaded = 0.0, // total number of loaded bytes
startT = new Date().getTime(), // timestamp when test was started
bonusT = 0, //how many milliseconds the test has been shortened by (higher on faster connections)
graceTimeDone = false, //set to true after the grace time is past
failed = false; // set to true if a stream fails
xhr = [];
// function to create a download stream. streams are slightly delayed so that they will not end at the same time
var testStream = function(i, delay) {
const testStream = function(i, delay) {
setTimeout(
function() {
if (testState !== 1) return; // delayed stream ended up starting after the end of the download test
tverb("dl test stream started " + i + " " + delay);
var prevLoaded = 0; // number of bytes loaded last time onprogress was called
var x = new XMLHttpRequest();
let prevLoaded = 0; // number of bytes loaded last time onprogress was called
let x = new XMLHttpRequest();
xhr[i] = x;
xhr[i].onprogress = function(event) {
tverb("dl stream progress event " + i + " " + event.loaded);
@ -348,7 +352,7 @@ function dlTest(done) {
} catch (e) {}
} // just in case this XHR is still running after the download test
// progress event, add number of new loaded bytes to totLoaded
var loadDiff = event.loaded <= 0 ? 0 : event.loaded - prevLoaded;
const loadDiff = event.loaded <= 0 ? 0 : event.loaded - prevLoaded;
if (isNaN(loadDiff) || !isFinite(loadDiff) || loadDiff < 0) return; // just in case
totLoaded += loadDiff;
prevLoaded = event.loaded;
@ -383,14 +387,14 @@ function dlTest(done) {
);
}.bind(this);
// open streams
for (var i = 0; i < settings.xhr_dlMultistream; i++) {
for (let i = 0; i < settings.xhr_dlMultistream; i++) {
testStream(i, settings.xhr_multistreamDelay * i);
}
// every 200ms, update dlStatus
interval = setInterval(
function() {
tverb("DL: " + dlStatus + (graceTimeDone ? "" : " (in grace time)"));
var t = new Date().getTime() - startT;
const t = new Date().getTime() - startT;
if (graceTimeDone) dlProgress = (t + bonusT) / (settings.time_dl_max * 1000);
if (t < 200) return;
if (!graceTimeDone) {
@ -404,11 +408,11 @@ function dlTest(done) {
graceTimeDone = true;
}
} else {
var speed = totLoaded / (t / 1000.0);
const speed = totLoaded / (t / 1000.0);
if (settings.time_auto) {
//decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here
var bonus = (6.4 * speed) / 100000;
bonusT += bonus > 800 ? 800 : bonus;
const bonus = (5.0 * speed) / 100000;
bonusT += bonus > 400 ? 400 : bonus;
}
//update status
dlStatus = ((speed * 8 * settings.overheadCompensationFactor) / (settings.useMebibits ? 1048576 : 1000000)).toFixed(2); // speed is multiplied by 8 to go from bytes to bits, overhead compensation is applied, then everything is divided by 1048576 or 1000000 to go to megabits/mebibits
@ -426,47 +430,47 @@ function dlTest(done) {
200
);
}
// upload test, calls done function whent it's over
var ulCalled = false; // used to prevent multiple accidental calls to ulTest
// upload test, calls done function when it's over
let ulCalled = false; // used to prevent multiple accidental calls to ulTest
function ulTest(done) {
tverb("ulTest");
if (ulCalled) return;
else ulCalled = true; // ulTest already called?
// garbage data for upload test
var r = new ArrayBuffer(1048576);
var maxInt = Math.pow(2, 32) - 1;
let r = new ArrayBuffer(1048576);
const maxInt = Math.pow(2, 32) - 1;
try {
r = new Uint32Array(r);
for (var i = 0; i < r.length; i++) r[i] = Math.random() * maxInt;
for (let i = 0; i < r.length; i++) r[i] = Math.random() * maxInt;
} catch (e) {}
var req = [];
var reqsmall = [];
for (var i = 0; i < settings.xhr_ul_blob_megabytes; i++) req.push(r);
let req = [];
let reqsmall = [];
for (let i = 0; i < settings.xhr_ul_blob_megabytes; i++) req.push(r);
req = new Blob(req);
r = new ArrayBuffer(262144);
try {
r = new Uint32Array(r);
for (var i = 0; i < r.length; i++) r[i] = Math.random() * maxInt;
for (let i = 0; i < r.length; i++) r[i] = Math.random() * maxInt;
} catch (e) {}
reqsmall.push(r);
reqsmall = new Blob(reqsmall);
var testFunction = function() {
var totLoaded = 0.0, // total number of transmitted bytes
const testFunction = function() {
let totLoaded = 0.0, // total number of transmitted bytes
startT = new Date().getTime(), // timestamp when test was started
bonusT = 0, //how many milliseconds the test has been shortened by (higher on faster connections)
graceTimeDone = false, //set to true after the grace time is past
failed = false; // set to true if a stream fails
xhr = [];
// function to create an upload stream. streams are slightly delayed so that they will not end at the same time
var testStream = function(i, delay) {
const testStream = function(i, delay) {
setTimeout(
function() {
if (testState !== 3) return; // delayed stream ended up starting after the end of the upload test
tverb("ul test stream started " + i + " " + delay);
var prevLoaded = 0; // number of bytes transmitted last time onprogress was called
var x = new XMLHttpRequest();
let prevLoaded = 0; // number of bytes transmitted last time onprogress was called
let x = new XMLHttpRequest();
xhr[i] = x;
var ie11workaround;
let ie11workaround;
if (settings.forceIE11Workaround) ie11workaround = true;
else {
try {
@ -477,7 +481,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;
@ -499,24 +503,34 @@ function ulTest(done) {
} catch (e) {}
} // just in case this XHR is still running after the upload test
// progress event, add number of new loaded bytes to totLoaded
var loadDiff = event.loaded <= 0 ? 0 : event.loaded - prevLoaded;
const loadDiff = event.loaded <= 0 ? 0 : event.loaded - prevLoaded;
if (isNaN(loadDiff) || !isFinite(loadDiff) || loadDiff < 0) return; // just in case
totLoaded += loadDiff;
prevLoaded = event.loaded;
}.bind(this);
xhr[i].upload.onload = function() {
// this stream sent all the garbage data, start again
tverb("ul stream finished " + i);
testStream(i, 0);
// body uploaded, but response not yet available.
// xhr.onload below handles the full lifecycle.
}.bind(this);
xhr[i].upload.onerror = function() {
tverb("ul stream failed " + i);
if (settings.xhr_ignoreErrors === 0) failed = true; //abort
try {
xhr[i].abort();
} catch (e) {}
if (settings.xhr_ignoreErrors === 0) failed = true;
try { x.abort(); } catch (e) {}
delete xhr[i];
if (settings.xhr_ignoreErrors === 1) testStream(i, 0); //restart stream
if (settings.xhr_ignoreErrors === 1) testStream(i, 0);
}.bind(this);
xhr[i].onload = function() {
// response complete — check status on captured x, not xhr[i]
if (x.status >= 200 && x.status < 300) {
tverb("ul stream finished " + i);
testStream(i, 0);
} else {
tverb("ul stream failed with HTTP " + x.status + " " + i);
if (settings.xhr_ignoreErrors === 0) failed = true;
try { x.abort(); } catch (e) {}
delete xhr[i];
if (settings.xhr_ignoreErrors === 1) testStream(i, 0);
}
}.bind(this);
// send xhr
xhr[i].open("POST", settings.url_ul + url_sep(settings.url_ul) + (settings.mpot ? "cors=true&" : "") + "r=" + Math.random(), true); // random string to prevent caching
@ -527,18 +541,18 @@ function ulTest(done) {
xhr[i].send(req);
}
}.bind(this),
1
delay
);
}.bind(this);
// open streams
for (var i = 0; i < settings.xhr_ulMultistream; i++) {
for (let i = 0; i < settings.xhr_ulMultistream; i++) {
testStream(i, settings.xhr_multistreamDelay * i);
}
// every 200ms, update ulStatus
interval = setInterval(
function() {
tverb("UL: " + ulStatus + (graceTimeDone ? "" : " (in grace time)"));
var t = new Date().getTime() - startT;
const t = new Date().getTime() - startT;
if (graceTimeDone) ulProgress = (t + bonusT) / (settings.time_ul_max * 1000);
if (t < 200) return;
if (!graceTimeDone) {
@ -552,11 +566,11 @@ function ulTest(done) {
graceTimeDone = true;
}
} else {
var speed = totLoaded / (t / 1000.0);
const speed = totLoaded / (t / 1000.0);
if (settings.time_auto) {
//decide how much to shorten the test. Every 200ms, the test is shortened by the bonusT calculated here
var bonus = (6.4 * speed) / 100000;
bonusT += bonus > 800 ? 800 : bonus;
const bonus = (5.0 * speed) / 100000;
bonusT += bonus > 400 ? 400 : bonus;
}
//update status
ulStatus = ((speed * 8 * settings.overheadCompensationFactor) / (settings.useMebibits ? 1048576 : 1000000)).toFixed(2); // speed is multiplied by 8 to go from bytes to bits, overhead compensation is applied, then everything is divided by 1048576 or 1000000 to go to megabits/mebibits
@ -587,20 +601,20 @@ function ulTest(done) {
} else testFunction();
}
// ping+jitter test, function done is called when it's over
var ptCalled = false; // used to prevent multiple accidental calls to pingTest
let ptCalled = false; // used to prevent multiple accidental calls to pingTest
function pingTest(done) {
tverb("pingTest");
if (ptCalled) return;
else ptCalled = true; // pingTest already called?
var startT = new Date().getTime(); //when the test was started
var prevT = null; // last time a pong was received
var ping = 0.0; // current ping value
var jitter = 0.0; // current jitter value
var i = 0; // counter of pongs received
var prevInstspd = 0; // last ping time, used for jitter calculation
const startT = new Date().getTime(); //when the test was started
let prevT = null; // last time a pong was received
let ping = 0.0; // current ping value
let jitter = 0.0; // current jitter value
let i = 0; // counter of pongs received
let prevInstspd = 0; // last ping time, used for jitter calculation
xhr = [];
// ping function
var doPing = function() {
const doPing = function() {
tverb("ping");
pingProgress = i / settings.count_ping;
prevT = new Date().getTime();
@ -611,13 +625,13 @@ function pingTest(done) {
if (i === 0) {
prevT = new Date().getTime(); // first pong
} else {
var instspd = new Date().getTime() - prevT;
let instspd = new Date().getTime() - prevT;
if (settings.ping_allowPerformanceApi) {
try {
//try to get accurate performance timing using performance api
var p = performance.getEntries();
let p = performance.getEntries();
p = p[p.length - 1];
var d = p.responseStart - p.requestStart;
let d = p.responseStart - p.requestStart;
if (d <= 0) d = p.duration;
if (d > 0 && d < instspd) instspd = d;
} catch (e) {
@ -628,7 +642,7 @@ function pingTest(done) {
//noticed that some browsers randomly have 0ms ping
if (instspd < 1) instspd = prevInstspd;
if (instspd < 1) instspd = 1;
var instjitter = Math.abs(instspd - prevInstspd);
const instjitter = Math.abs(instspd - prevInstspd);
if (i === 1) ping = instspd;
/* first ping, can't tell jitter yet*/ else {
if (instspd < ping) ping = instspd; // update ping, if the instant ping is lower
@ -687,10 +701,10 @@ function sendTelemetry(done) {
xhr = new XMLHttpRequest();
xhr.onload = function() {
try {
var parts = xhr.responseText.split(" ");
const parts = xhr.responseText.split(" ");
if (parts[0] == "id") {
try {
var id = parts[1];
let id = parts[1];
done(id);
} catch (e) {
done(null);
@ -705,12 +719,12 @@ function sendTelemetry(done) {
done(null);
};
xhr.open("POST", settings.url_telemetry + url_sep(settings.url_telemetry) + (settings.mpot ? "cors=true&" : "") + "r=" + Math.random(), true);
var telemetryIspInfo = {
const telemetryIspInfo = {
processedString: clientIp,
rawIspInfo: typeof ispInfo === "object" ? ispInfo : ""
};
try {
var fd = new FormData();
const fd = new FormData();
fd.append("ispinfo", JSON.stringify(telemetryIspInfo));
fd.append("dl", dlStatus);
fd.append("ul", ulStatus);
@ -720,7 +734,7 @@ function sendTelemetry(done) {
fd.append("extra", settings.telemetry_extra);
xhr.send(fd);
} catch (ex) {
var postData = "extra=" + encodeURIComponent(settings.telemetry_extra) + "&ispinfo=" + encodeURIComponent(JSON.stringify(telemetryIspInfo)) + "&dl=" + encodeURIComponent(dlStatus) + "&ul=" + encodeURIComponent(ulStatus) + "&ping=" + encodeURIComponent(pingStatus) + "&jitter=" + encodeURIComponent(jitterStatus) + "&log=" + encodeURIComponent(settings.telemetry_level > 1 ? log : "");
const postData = "extra=" + encodeURIComponent(settings.telemetry_extra) + "&ispinfo=" + encodeURIComponent(JSON.stringify(telemetryIspInfo)) + "&dl=" + encodeURIComponent(dlStatus) + "&ul=" + encodeURIComponent(ulStatus) + "&ping=" + encodeURIComponent(pingStatus) + "&jitter=" + encodeURIComponent(jitterStatus) + "&log=" + encodeURIComponent(settings.telemetry_level > 1 ? log : "");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(postData);
}

Some files were not shown because too many files have changed in this diff Show more