diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100755 index f6726e31d..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -name: Bug report -about: Report a bug with this project. Don't use this if you need help configuring - it - ---- - -## Description -A short description of what's going on - -## Server -Every info you can provide about your server: web server, database, PHP version, ... as well as server-side speedtest settings -If possible, provide an URL to your speedtest so we can check it - -## Client -Browser, OS, type of connection, unusual software, ... - -## Steps to reproduce -* Do this -* Do that -* Bad stuff happens - -## Expected behaviour -What should have happened - -## Screenshots -If necessary, add screenshots of the test. -F12 > Network screenshots can be particularly useful diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100755 index 08d4db820..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - -## Description -A short description of your idea - -## Why it should be implemented -Who it would benefit, ... - -## Optional: implementation suggestions -If you have experience in this field, feel free to give us suggestions - -## Optional: screenshots -Add some screenshots, mockups, ... if they help clarify what you want diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 4f89e48d3..000000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,83 +0,0 @@ -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' - push: - branches: ["*"] - # Publish semver tags as releases. - tags: ["v*.*.*"] - pull_request: - branches: ["{{is_default_branch}}"] - release: - types: [published] - -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@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@v3 - - # 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@v3 - 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@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=branch - type=ref,event=pr - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v5 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/github-docker.yml b/.github/workflows/github-docker.yml new file mode 100644 index 000000000..47380cd82 --- /dev/null +++ b/.github/workflows/github-docker.yml @@ -0,0 +1,51 @@ +# This workflow will build the source code and create a new github package. +# For more information see: https://github.com/marketplace/actions/build-and-push-docker-images + +name: Build + +on: + push: + branches: + - master + - develop + tags: + - v* + - Sv* + pull_request: + branches: + - master + - develop + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Build and push Docker images + uses: docker/build-push-action@v1.1.0 + with: + # Username used to log in to a Docker registry. If not set then no login will occur + username: ${{ github.actor }} + # Password or personal access token used to log in to a Docker registry. If not set then no login will occur + password: ${{ secrets.GITHUB_TOKEN }} + # Server address of Docker registry. If not set then will default to Docker Hub + registry: ghcr.io + # Docker repository to tag the image with + repository: talview/speedtest/speedtest + # Automatically tags the built image with the git reference as per the readme + tag_with_ref: true + tag_with_sha: true + # Path to the build context + path: . + # Path to the Dockerfile (Default is '{path}/Dockerfile') + dockerfile: Dockerfile + # Always attempt to pull a newer version of the image + always_pull: true + # Comma-delimited list of images to consider as cache sources + cache_froms: talview/speedtest/speedtest:develop,talview/speedtest/speedtest:latest + # Adds labels with git repository information to the built image + add_git_labels: true + # Whether to push the image + push: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a626296bb..eeb57a1ca 100755 --- a/Dockerfile +++ b/Dockerfile @@ -12,12 +12,17 @@ RUN apt-get update && apt-get install -y \ && docker-php-ext-install -j$(nproc) gd pdo pdo_mysql pdo_pgsql pgsql \ && rm -rf /var/lib/apt/lists/* + +# RUN sudo apt install mysql-server -y + + # Prepare files and folders RUN mkdir -p /speedtest/ # Copy sources COPY backend/ /speedtest/backend + COPY results/*.php /speedtest/results/ COPY results/*.ttf /speedtest/results/ @@ -26,6 +31,8 @@ COPY favicon.ico /speedtest/ COPY docker/servers.json /servers.json +COPY logo.png /speedtest/ + COPY docker/*.php /speedtest/ COPY docker/entrypoint.sh / @@ -33,7 +40,7 @@ COPY docker/entrypoint.sh / ENV TITLE=LibreSpeed ENV MODE=standalone ENV PASSWORD=password -ENV TELEMETRY=false +ENV TELEMETRY=true ENV ENABLE_ID_OBFUSCATION=false ENV REDACT_IP_ADDRESSES=false ENV WEBPORT=80 @@ -43,4 +50,4 @@ STOPSIGNAL SIGWINCH # Final touches EXPOSE 80 -CMD ["bash", "/entrypoint.sh"] +CMD ["bash", "/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md index 6b0ca5c72..fe5f81711 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ +##To Run in Docker: + +## Enter in the directory and Run these in terminal + +docker build . -t speedtest + +docker run -p 8080:80 docker-img-name + +## To test or view, in browser + +Go to browser: localhost:8080 + + ![LibreSpeed Logo](https://github.com/librespeed/speedtest/blob/master/.logo/logo3.png?raw=true) # LibreSpeed diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 172fd3198..901bbba84 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -12,6 +12,11 @@ cp /speedtest/*.js /var/www/html/ # Copy favicon cp /speedtest/favicon.ico /var/www/html/ +# Copy logo +cp /speedtest/logo.png /var/www/html/ + +# cp /speedtest/results/*.* /var/www/html/ + # Set up backend side for standlone modes if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then cp -r /speedtest/backend/ /var/www/html/backend diff --git a/docker/frontend.php b/docker/frontend.php index 724fdc029..004f1e6f0 100755 --- a/docker/frontend.php +++ b/docker/frontend.php @@ -471,4 +471,4 @@ function initUI(){ Close
- + \ No newline at end of file diff --git a/docker/standalone.php b/docker/standalone.php index 2ef5899a9..7dc38c9e5 100755 --- a/docker/standalone.php +++ b/docker/standalone.php @@ -21,347 +21,627 @@ function I(i){return document.getElementById(i);} s.setParameter("getIp_ispInfo_distance",""); -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=""; - 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){} +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; + + + 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); + } + + + // 3: Good + // 2: Average + // 1: Poor + // "": Empty + + function classifySpeed(value) { + if (value=="") return 0; + if (value > 50) return 3; + if (value >= 10) return 2; + return 1; + + } + + function classifySpeedUl(value) { + if (value=="") return 0; + if (value > 20) return 3; + if (value >= 5) return 2; + return 1; + + } + + function updateDlColor(value) { + + const dl_text_element = document.getElementById("dlText"); + const speed_classification = classifySpeed(value); + + switch (speed_classification){ + case 3: dl_text_element.style.color = "#16A34A"; + break; + case 2: dl_text_element.style.color = "#CA8A04"; + break; + case 1: dl_text_element.style.color = "#DC2626"; + break; + case 0: dl_text_element.style.color = "#111827"; + break; + + default: dl_text_element.style.color = "#111827"; + } + } + + function updateUlColor(value) { + + const ul_text_element = document.getElementById("ulText"); + const speed_classification = classifySpeedUl(value); + + switch (speed_classification){ + case 3: ul_text_element.style.color = "#16A34A"; + break; + case 2: ul_text_element.style.color = "#CA8A04"; + break; + case 1: ul_text_element.style.color = "#DC2626"; + break; + case 0: ul_text_element.style.color = "#111827"; + break; + + default: ul_element.style.color = "#111827"; + } + } + + function classifyPing(value){ + + if (value=="") return 0; + if (value>100) return 1; + if (value>=20) return 2; + return 3; + } + + function updatePingColor(value){ + const ping_element = document.getElementById("pingText"); + const ping_classification = classifyPing(value) + + + switch (ping_classification){ + case 3: ping_element.style.color = "#16A34A"; + break; + case 2: ping_element.style.color = "#CA8A04"; + break; + case 1: ping_element.style.color = "#DC2626"; + break; + case 0: ping_element.style.color = "#111827"; + break; + + default: ping_element.style.color = "#111827"; + } + } + + function classifyJitter(value){ + if (value=="") return 0; + if (value>20) return 1; + if (value>=5) return 2; + return 3; + } + + function updateJitterColor(value){ + const jitter_element = document.getElementById("jitText"); + const jitter_classification = classifyJitter(value); + + // jitter_classification === 2?jitter_element.style.color = "#16A34A":(jitter_classification === 1?jitter_element.style.color = "#CA8A04":jitter_element.style.color = "#DC2626"); + + switch (jitter_classification){ + case 3: jitter_element.style.color = "#16A34A"; + break; + case 2: jitter_element.style.color = "#CA8A04"; + break; + case 1: jitter_element.style.color = "#DC2626"; + break; + case 0: jitter_element.style.color = "#111827"; + break; + + default: jitter_element.style.color = "#111827"; + } + } + + //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 + // I("startStopBtn").textContent = "Try Again"; + I("startStopBtn").className = "new-class"; + try { + var testId = uiData.testId; + if (testId != null) { + var shareURL = window.location.href.substring(0, window.location.href.lastIndexOf("/")) + "/results/?id=" + testId; + console.log("ShareURL: ", shareURL); + // 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); + + if (status == 1){ + updateDlColor(uiData.dlStatus); + // updateDlColor(30, "download"); + }else if(status == 3){ + updateUlColor(uiData.ulStatus); + }else{ + updateDlColor(uiData.dlStatus); + updateUlColor(uiData.ulStatus); + } + + + updatePingColor(uiData.pingStatus); + updateJitterColor(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() { + I("dlText").textContent = ""; + I("ulText").textContent = ""; + I("pingText").textContent = ""; + I("jitText").textContent = ""; + } + + + + + -<?= getenv('TITLE') ?: 'LibreSpeed Example' ?> + + } + + @media (max-width: 750px) { + .container .testArea, + .container .testArea2 { + padding: 12px; + border-radius: 8px; + gap: 6px; + } + .container .title-class { + font-size: 24px; + } + .container { + padding: 10px; + } + } + + @media (max-height: 620px){ + .child-container{ + height:auto; + } + } + + + Talview Speedtest + -

-
-

- - Privacy - -
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
-
-
Download
- -
-
Mbit/s
-
-
-
Upload
- -
-
Mbit/s
+ +
+
+
+ +
+ +
+ +
Internet Speed Test
+ + + +
+ +
+
+
Ping
+
+
ms
+
+
+
Jitter
+
+
ms
+
+
+
+
+
Download
+ +
+
Mbit/s
+
+
+
Upload
+ +
+
Mbit/s
+
+
+ +
+ + + + + + +
+ +
+
+ + + + + +
-
- -
- + + +
- Source code -
- - + + - + + \ No newline at end of file diff --git a/examples/example-multipleServers-full.html b/examples/example-multipleServers-full.html deleted file mode 100755 index ed594731d..000000000 --- a/examples/example-multipleServers-full.html +++ /dev/null @@ -1,490 +0,0 @@ - - - - - - - - - -LibreSpeed Example - - -

LibreSpeed Example

-
-

Selecting a server...

-
- - - - diff --git a/examples/example-multipleServers-pretty.html b/examples/example-multipleServers-pretty.html deleted file mode 100755 index 43b305217..000000000 --- a/examples/example-multipleServers-pretty.html +++ /dev/null @@ -1,245 +0,0 @@ - - - - - - -LibreSpeed Example - - - - - - -

LibreSpeed Example

-
-
Selecting server...
-
-
-
-
Download
-
-
Mbit/s
-
-
-
Upload
-
-
Mbit/s
-
-
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
- IP Address: -
-
-Source code - - - diff --git a/examples/example-singleServer-basic.html b/examples/example-singleServer-basic.html deleted file mode 100755 index 18c85ea62..000000000 --- a/examples/example-singleServer-basic.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - LibreSpeed Example - - - - -

LibreSpeed Example

- -

IP Address

-

- -

Download

-

- -

Upload

-

- -

Latency

-

- - - - Source code - - - diff --git a/examples/example-singleServer-chart.html b/examples/example-singleServer-chart.html deleted file mode 100755 index 7783cd5f7..000000000 --- a/examples/example-singleServer-chart.html +++ /dev/null @@ -1,256 +0,0 @@ - - - - - LibreSpeed Example - - - - - - - - -

LibreSpeed - Chart.js example

- - Run speed test -

Charts by Chart.js

Source code - - diff --git a/examples/example-singleServer-customSettings.html b/examples/example-singleServer-customSettings.html deleted file mode 100755 index 1a06f8900..000000000 --- a/examples/example-singleServer-customSettings.html +++ /dev/null @@ -1,174 +0,0 @@ - - - - - -LibreSpeed Example - - - - - - - -

LibreSpeed Example

-
-
-
-
-
Download
-
-
Mbit/s
-
-
-
Upload
-
-
Mbit/s
-
-
-
-Source code - - - diff --git a/examples/example-singleServer-gauges.html b/examples/example-singleServer-gauges.html deleted file mode 100755 index 0b6c388f4..000000000 --- a/examples/example-singleServer-gauges.html +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - -LibreSpeed Example - - -

LibreSpeed Example

-
-
-
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
-
-
Download
- -
-
Mbit/s
-
-
-
Upload
- -
-
Mbit/s
-
-
-
- -
-
- Source code -
- - - diff --git a/examples/example-singleServer-pretty.html b/examples/example-singleServer-pretty.html deleted file mode 100755 index eca431bb2..000000000 --- a/examples/example-singleServer-pretty.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - -LibreSpeed Example - - - - - - - -

LibreSpeed Example

-
-
-
-
-
Download
-
-
Mbit/s
-
-
-
Upload
-
-
Mbit/s
-
-
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
- IP Address: -
-
-Source code - - - diff --git a/examples/example-singleServer-progressBar.html b/examples/example-singleServer-progressBar.html deleted file mode 100755 index ce037b6b2..000000000 --- a/examples/example-singleServer-progressBar.html +++ /dev/null @@ -1,212 +0,0 @@ - - - - - -LibreSpeed Example - - - - - - - -

LibreSpeed Example

-
-
-
-
-
-
Download
-
-
Mbit/s
-
-
-
Upload
-
-
Mbit/s
-
-
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
- IP Address: -
-
-Source code - - - diff --git a/favicon.ico b/favicon.ico index e50e89a37..ec0517a80 100755 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/index.html b/index.html index 262761581..0f91b07bc 100755 --- a/index.html +++ b/index.html @@ -1,365 +1,639 @@ + - - - - - + + + + + + -LibreSpeed Example + + } + + @media (max-width: 750px) { + .container .testArea, + .container .testArea2 { + padding: 12px; + border-radius: 8px; + gap: 6px; + } + .container .title-class { + font-size: 24px; + } + .container { + padding: 10px; + } + } + + @media (max-height: 620px){ + .child-container{ + height:auto; + } + } + + + Talview Speedtest + -

LibreSpeed Example

-
-

- Privacy -
-
-
-
Ping
-
-
ms
-
-
-
Jitter
-
-
ms
-
-
-
-
-
Download
- -
-
Mbit/s
-
-
-
Upload
- -
-
Mbit/s
+ +
+
+
+ +
+ +
+ +
Internet Speed Test
+ + + +
+ +
+
+
Ping
+
+
ms
+
+
+
Jitter
+
+
ms
+
+
+
+
+
Download
+ +
+
Mbit/s
+
+
+
Upload
+ +
+
Mbit/s
+
+
+ +
+ + + + + + +
+ +
+
+ + + + + +
-
- -
- + + +
- Source code -
- - + + - + + \ No newline at end of file diff --git a/logo.png b/logo.png new file mode 100644 index 000000000..4bdf21ed0 Binary files /dev/null and b/logo.png differ diff --git a/results/telemetry_settings.php b/results/telemetry_settings.php index ea1993848..d741e143c 100755 --- a/results/telemetry_settings.php +++ b/results/telemetry_settings.php @@ -1,7 +1,7 @@