From 0b64f64b2c2fb2f781d3253344ba5e3920ae47e5 Mon Sep 17 00:00:00 2001 From: Alan Xiong Date: Mon, 15 Apr 2024 08:18:29 +0800 Subject: [PATCH] =?UTF-8?q?Docker=E6=9B=B4=E6=94=B9=E4=B8=BA=E4=B8=AD?= =?UTF-8?q?=E6=96=87=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=8F=AF=E4=BB=A5=E4=BD=BF?= =?UTF-8?q?=E7=94=A8TZ=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 5 ++ README.md | 113 +++++++++++++++---------------- doc.md | 9 +-- doc_docker.md | 140 +++++++++++++++++++-------------------- docker/entrypoint.sh | 24 ++----- docker/frontend.php | 87 +++++++++++++----------- docker/standalone.php | 85 +++++++++++++----------- index.html | 68 +++++++++---------- results/index.php | 64 +++++++++--------- results/simhei.ttf | Bin 0 -> 9753388 bytes results/stats.php | 57 ++++++++-------- results/telemetry_db.php | 11 +-- speedtest.js | 2 +- 13 files changed, 333 insertions(+), 332 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 results/simhei.ttf diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6c2ff60 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "master" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 4076988..6d08675 100755 --- a/README.md +++ b/README.md @@ -2,83 +2,74 @@ # LibreSpeed -No Flash, No Java, No Websocket, No Bullshit. +无需Flash、Java、WebSocket,没有废话。 -This is a very lightweight speed test implemented in Javascript, using XMLHttpRequest and Web Workers. +这是一个用Javascript实现的非常轻量级的网速测试工具,使用XMLHttpRequest和Web Workers。 -## Try it -[Take a speed test](https://librespeed.org) +## 试试吧 +[进行网速测试](https://librespeed.org) -## Compatibility -All modern browsers are supported: IE11, latest Edge, latest Chrome, latest Firefox, latest Safari. -Works with mobile versions too. +## 兼容性 +支持所有现代浏览器:IE11、最新版Edge、最新版Chrome、最新版Firefox、最新版Safari。 +同样适用于移动版本。 -## Features -* Download -* Upload -* Ping -* Jitter -* IP Address, ISP, distance from server (optional) -* Telemetry (optional) -* Results sharing (optional) -* Multiple Points of Test (optional) +## 特性 +* 下载速度 +* 上传速度 +* 延迟(Ping) +* 抖动(Jitter) +* IP地址、ISP、与服务器的距离(可选) +* 遥测数据(可选) +* 结果分享(可选) +* 多点测试(可选) -![Screenrecording of a running Speedtest](https://speedtest.fdossena.com/mpot_v6.gif) +![正在进行的Speedtest屏幕录像](https://speedtest.fdossena.com/mpot_v6.gif) +## 服务器要求 +* 一个配置合理的快速Web服务器,支持Apache 2(也支持nginx、IIS) +* PHP 5.4(也支持其他后端) +* MySQL数据库来存储测试结果(可选,也支持Microsoft SQL Server、PostgreSQL和SQLite) +* 一个快速的互联网连接 -## Server requirements -* A reasonably fast web server with Apache 2 (nginx, IIS also supported) -* PHP 5.4 or newer (other backends also available) -* MySQL database to store test results (optional, Microsoft SQL Server, PostgreSQL and SQLite also supported) -* A fast! internet connection +## 安装 +假设你已经安装了PHP,安装步骤相当简单。 +我在QNAP上设置了这个。 +以此次为例,我在网络共享区域使用了一个名为**speedtest**的文件夹。 -## Installation -Assuming you have PHP installed, the installation steps are quite simple. -I set this up on a QNAP. -For this example, I am using a folder called **speedtest** in my web share area. +1. 选择example-xxx.html文件中的一个作为你speedtest文件夹中的新index.html。我使用的是:example-singleServer-full.html +2. 将speedtest.js、speedtest_worker.js和favicon.ico添加到你的speedtest文件夹中。 +3. 将整个backend文件夹下载到speedtest/backend中。 +4. 将整个results文件夹下载到speedtest/results中。 +5. 确保你的权限允许执行(755)。 +6. 访问YOURSITE/speedtest/index.html,就这样! -1. Choose one of the example-xxx.html files in `examples` folder as your index.html if the default index.html does not fit. -2. Add: speedtest.js, speedtest_worker.js, and favicon.ico to your speedtest folder. -3. Download all of the backend folder into speedtest/backend. -4. Download all of the results folder into speedtest/results. -5. Be sure your permissions allow execute (755). -6. Visit YOURSITE/speedtest/index.html and voila! +### 安装视频 +这里有一个更深入的安装视频: +* [Ubuntu Server 19.04快速开始安装指南](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag) -### Installation Video -There is a more in-depth installation video here: -* [Quick start installation guide for Ubuntu Server 19.04](https://fdossena.com/?p=speedtest/quickstart_v5_ubuntu.frag) - -## Android app -A template to build an Android client for your LibreSpeed installation is available [here](https://github.com/librespeed/speedtest-android). - -## CLI client -A command line client is available [here](https://github.com/librespeed/speedtest-cli). +## Android应用 +为你的LibreSpeed安装构建Android客户端的模板可以在[这里](https://github.com/librespeed/speedtest-android)找到。 ## Docker -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. +Docker镜像可以在[GitHub](https://github.com/librespeed/speedtest/pkgs/container/speedtest)上找到,查看我们的[docker文档](doc_docker.md)了解更多信息。 -## 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). +## Go后端 +一个Go实现版本可以在[`speedtest-go`](https://github.com/librespeed/speedtest-go)仓库中找到,由[Maddie Zhan](https://github.com/maddie)维护。 -## Node.js backend -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. +## Node.js后端 +`node`分支中有一个部分实现的Node.js版本,由[dunklesToast](https://github.com/dunklesToast)开发。目前不推荐使用。 -## Donate -[![Donate with Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate) -[Donate with PayPal](https://www.paypal.me/sineisochronic) +## 捐赠 +[![通过Liberapay捐赠](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/fdossena/donate) +[通过PayPal捐赠](https://www.paypal.me/sineisochronic) -## License -Copyright (C) 2016-2022 Federico Dossena +## 许可证 +版权所有 (C) 2016-2022 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 -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. +这个程序是自由软件:你可以在GNU Lesser General Public License的条款下重新分发和/或修改它,该许可证由自由软件基金会发布,要么是许可证的第3版,或者(根据你的选择)任何后续版本。 -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. +这个程序希望它是有用的, +但没有任何保证;甚至没有暗示的保证MERCHANTABILITY或特定目的的适用性。详情请参见GNU通用公共许可证。 -You should have received a copy of the GNU Lesser General Public License -along with this program. If not, see . +你应该已经收到了GNU Lesser General Public License的副本, +和这个程序一起。如果没有,参见。 \ No newline at end of file diff --git a/doc.md b/doc.md index 236c1cf..b30a01a 100755 --- a/doc.md +++ b/doc.md @@ -109,7 +109,8 @@ A basic front-end for visualizing and searching tests by ID is available in `res A login is required to access the interface. __Important__: change the default password in `results/telemetry_settings.php`. #### The end -Now that the test is installed, the default page uses telemetry and results sharing. If you want another index page, rename one of the examples to `index.html` and delete the other examples. The best starting point for most people is `example-singleServer-gauges.html`. +Now that the test is installed, rename one of the examples to `index.html` and delete the other examples. +The best starting point for most people is `example-singleServer-gauges.html`. If you want to use telemetry and results sharing, use `example-singleServer-full.html` instead. If you're not using telemetry and results sharing, you can delete the `results` folder too. @@ -118,7 +119,7 @@ Details about the examples and how to make custom UIs will be discussed later. I #### Privacy Telemetry contains personal information (according to GDPR definition), therefore it is important to treat this data respectfully of national and international laws, especially if you plan to offer the service in the European Union. -Default `index.html` and `example-multipleServers-full.html` both contain a privacy policy for the service: you MUST read it, change it if necessary, and add your email address for data deletion requests. __Failure to comply with GDPR regulations can get you in serious trouble.__ +`example-singleServer-full.html` and `example-multipleServers-full.html` both contain a privacy policy for the service: you MUST read it, change it if necessary, and add your email address for data deletion requests. __Failure to comply with GDPR regulations can get you in serious trouble.__ ### Multiple servers, PHP The speed test can automatically choose between multiple test points and use the one with the lowest ping in a list. @@ -239,11 +240,11 @@ __Single server:__ * `example-singleServer-customSettings.html`: Same as `example-singleServer-pretty.html` but configures the test so that it only performs download and upload tests, and with a fixed length instead of automatic * `example-singleServer-gauges.html`: The most sophisticated example, with the same functionality as `example-singleServer-pretty.html` but adds gauges. This is also a good starting point, but the gauges may slow down underpowered devices * `example-singleServer-chart.html`: Shows how to use the test with the Chart.js library -* default `index.html`: The most complete example. Based on `example-singleServer-gauges.html`, also enables telemetry and results sharing +* `example-singleServer-full.html`: The most complete example. Based on `example-singleServer-gauges.html`, also enables telemetry and results sharing __Multiple servers:__ * `example-multipleServers-pretty.html`: Same as `example-singleServer-pretty.html` but with multiple test points. Server selection is fully automatic -* `example-multipleServers-full.html`: Same as default `index.html` but with multiple test points. Server selection is automatic but the server can be changed afterwards by the user +* `example-multipleServers-full.html`: Same as `example-singleServer-full.html` but with multiple test points. Server selection is automatic but the server can be changed afterwards by the user ### Initialization To use the speed test in your page, first you need to load it: diff --git a/doc_docker.md b/doc_docker.md index a11a8ed..d4efe06 100755 --- a/doc_docker.md +++ b/doc_docker.md @@ -1,24 +1,23 @@ -A docker version of LibreSpeed is available here: [GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest) +LibreSpeed的Docker版本可以在这里找到:[GitHub Packages](https://github.com/librespeed/speedtest/pkgs/container/speedtest) -## Downloading docker image -To download LibreSpeed from the docker repo, use this command: +## 下载 Docker 镜像 +要从 Docker 仓库下载 LibreSpeed,请使用以下命令: ``` -docker pull ghcr.io/librespeed/speedtest +docker pull ghcr.io/kumakaiha/speedtest ``` -You will now have a new docker image called `librespeed/speedtest`. - +现在您将拥有一个名为 `kumakaiha/speedtest` 的新 Docker 镜像。 ## Docker Compose -To start the container using [docker compose](https://docs.docker.com/compose/) the following configuration can be used: +要使用 [docker compose](https://docs.docker.com/compose/) 启动容器,可以使用以下配置: ```yml version: '3.7' services: speedtest: container_name: speedtest - image: ghcr.io/librespeed/speedtest:latest + image: ghcr.io/kumakaiha/speedtest:latest restart: always environment: MODE: standalone @@ -35,72 +34,73 @@ services: - "80:80" # webport mapping (host:container) ``` -Please adjust the environment variables according to the intended operating mode. +请根据预期的操作模式调整环境变量。 -## Standalone mode -If you want to install LibreSpeed on a single server, you need to configure it in standalone mode. To do this, set the `MODE` environment variable to `standalone`. +## 独立模式 +如果您想在单个服务器上安装 LibreSpeed,则需要将其配置为独立模式。为此,请将 `MODE` 环境变量设置为 `standalone`。 -The test can be accessed on port 80. +测试可以通过端口 80 访问。 -Here's a list of additional environment variables available in this mode: -* __`TITLE`__: Title of your speed test. Default value: `LibreSpeed` -* __`TELEMETRY`__: Whether to enable telemetry or not. If enabled, you maybe want your data to be persisted. See below. Default value: `false` -* __`ENABLE_ID_OBFUSCATION`__: When set to true with telemetry enabled, test IDs are obfuscated, to avoid exposing the database internal sequential IDs. Default value: `false` -* __`REDACT_IP_ADDRESSES`__: When set to true with telemetry enabled, IP addresses and hostnames are redacted from the collected telemetry, for better privacy. Default value: `false` -* __`PASSWORD`__: Password to access the stats page. If not set, stats page will not allow accesses. -* __`EMAIL`__: Email address for GDPR requests. Must be specified when telemetry is enabled. -* __`IPINFO_APIKEY`__: API key for ipinfo.io. Optional, but required if you expect to serve a large number of tests -* __`DISABLE_IPINFO`__: If set to true, ISP info and distance will not be fetched from ipinfo.io. Default: value: `false` -* __`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. Default value: `km` -* __`WEBPORT`__: Allows choosing a custom port for the included web server. Default value: `80`. Note that you will have to expose it through docker with the -p argument +以下是在此模式下可用的其他环境变量列表: +* __`TITLE`__: 您的速度测试标题。默认值:`LibreSpeed` +* __`TELEMETRY`__: 是否启用遥测。如果启用,您可能希望持久保存数据。请参见下文。默认值:`false` +* __`ENABLE_ID_OBFUSCATION`__: 当启用遥测并设置为 true 时,测试 ID 将被模糊化,以避免暴露数据库内部的顺序 ID。默认值:`false` +* __`REDACT_IP_ADDRESSES`__: 当启用遥测并设置为 true 时,IP 地址和主机名将从收集的遥测数据中删除,以提高隐私性。默认值:`false` +* __`PASSWORD`__: 访问统计页面的密码。如果未设置,统计页面将不允许访问。 +* __`EMAIL`__: GDPR 请求的电子邮件地址。在启用遥测时必须指定。 +* __`IPINFO_APIKEY`__: ipinfo.io 的 API 密钥。可选,但如果您希望提供大量测试,则需要。 +* __`DISABLE_IPINFO`__: 如果设置为 true,则不会从 ipinfo.io 获取 ISP 信息和距离。默认值:`false` +* __`DISTANCE`__: 当 `DISABLE_IPINFO` 设置为 false 时,指定从服务器测量的距离方式。可以是 `km` 表示千米,`mi` 表示英里,或空字符串表示禁用距离测量。默认值:`km` +* __`WEBPORT`__: 允许选择包含的 Web 服务器的自定义端口。默认值:`80`。请注意,您将需要通过 -p 参数在 Docker 中公开它。 +* __`TZ`__: 设定容器时区,并使得遥测数据符合当地时间。默认值:`Asia/Shanghai`。注意:仅在x86设备使用SQLITE的Docker环境中测试。 -If telemetry is enabled, a stats page will be available at `http://your.server/results/stats.php`, but a password must be specified. +如果启用了遥测,将在 `http://your.server/results/stats.php` 上提供统计页面,但必须指定密码。 -### Persist sqlite database +### 持久化 sqlite 数据库 -Default DB driver is sqlite. The DB file is written to `/database/db.sql`. +默认的数据库驱动程序是 sqlite。数据库文件写入 `/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`. +因此,如果希望数据在镜像更新后保持不变,必须通过 `-v $PWD/db-dir:/database` 挂载卷。 - -###### Example -This command starts LibreSpeed in standalone mode, with the default settings, on port 80: +###### 示例 +此命令在端口 80 上使用默认设置以独立模式启动 LibreSpeed: ``` -docker run -e MODE=standalone -p 80:80 -it ghcr.io/librespeed/speedtest +docker run -e MODE=standalone -p 80:80 -it ghcr.io/kumakaiha/speedtest ``` -This command starts LibreSpeed in standalone mode, with telemetry, ID obfuscation and a stats password, on port 86: +此命令在端口 86 上使用独立模式启动 LibreSpeed,包括遥测、ID 模糊化和统计密码: ``` -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 +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/kumakaiha/speedtest ``` -## Multiple Points of Test -For multiple servers, you need to set up 1+ LibreSpeed backends, and 1 LibreSpeed frontend. +## 多个测试点 +对于多个服务器,您需要设置 1 个或多个 LibreSpeed 后端和 1 个 LibreSpeed 前端。 -### Backend mode -In backend mode, LibreSpeed provides only a test point with no UI. To do this, set the `MODE` environment variable to `backend`. +### 后端模式 +在后端模式下,LibreSpeed 仅提供一个测试点,没有用户界面。为此,请将 `MODE` 环境变量设置为 `backend`。 -The following backend files can be accessed on port 80: `garbage.php`, `empty.php`, `getIP.php` +可以通过端口 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. Optional, but required if you expect to serve a large number of tests +以下是在此模式下可用的其他环境变量列表: +* __`IPINFO_APIKEY`__: ipinfo.io 的 API 密钥。可选,但如果您希望提供大量测试,则需要。 + +###### 示例: +此命令在端口 80 上使用默认设置以后端模式启动 LibreSpeed: -###### Example: -This command starts LibreSpeed in backend mode, with the default settings, on port 80: ``` docker run -e MODE=backend -p 80:80 -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: +### 前端模式 +在前端模式下,LibreSpeed 为客户端提供 Web 用户界面和服务器列表。为此: +* 将 `MODE` 环境变量设置为 `frontend` +* 使用您的测试点创建一个 servers.json 文件。语法如下: ``` [ { - "name": "Friendly name for Server 1", + "name": "服务器 1 的友好名称", "server" :"//server1.mydomain.com/", "dlURL" :"garbage.php", "ulURL" :"empty.php", @@ -108,41 +108,35 @@ In frontend mode, LibreSpeed serves clients the Web UI and a list of servers. To "getIpURL" :"getIP.php" }, { - "name": "Friendly name for Server 2", + "name": "服务器 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) + 注意:如果服务器仅支持 HTTP 或 HTTPS,请在服务器字段中指定协议。如果两者都支持,请使用 `//`。 +* 将此文件挂载到容器中的 `/servers.json`(在本文件末尾有示例) -The test can be accessed on port 80. +测试可以通过端口 80 访问。 -Here's a list of additional environment variables available in this mode: -* __`TITLE`__: Title of your speedtest. Default value: `LibreSpeed` -* __`TELEMETRY`__: Whether to enable telemetry or not. Default value: `false` -* __`ENABLE_ID_OBFUSCATION`__: When set to true with telemetry enabled, test IDs are obfuscated, to avoid exposing the database internal sequential IDs. Default value: `false` -* __`REDACT_IP_ADDRESSES`__: When set to true with telemetry enabled, IP addresses and hostnames are redacted from the collected telemetry, for better privacy. Default value: `false` -* __`PASSWORD`__: Password to access the stats page. If not set, stats page will not allow accesses. -* __`EMAIL`__: Email address for GDPR requests. Must be specified when telemetry is enabled. -* __`DISABLE_IPINFO`__: If set to true, ISP info and distance will not be fetched from ipinfo.io. Default: value: `false` -* __`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. Default value: `km` -* __`WEBPORT`__: Allows choosing a custom port for the included web server. Default value: `80` +以下是在此模式下可用的其他环境变量列表: +* __`TITLE`__: 您的速度测试标题。默认值:`LibreSpeed` +* __`TELEMETRY`__: 是否启用遥测。默认值:`false` +* __`ENABLE_ID_OBFUSCATION`__: 当启用遥测并设置为 true 时,测试 ID 将被模糊化,以避免暴露数据库内部的顺序 ID。默认值:`false` +* __`REDACT_IP_ADDRESSES`__: 当启用遥测并设置为 true 时,IP 地址和主机名将从收集的遥测数据中删除,以提高隐私性。默认值:`false` +* __`PASSWORD`__: 访问统计页面的密码。如果未设置,统计页面将不允许访问。 +* __`EMAIL`__: GDPR 请求的电子邮件地址。在启用遥测时必须指定。 +* __`DISABLE_IPINFO`__: 如果设置为 true,则不会从 ipinfo.io 获取 ISP 信息和距离。默认值:`false` +* __`DISTANCE`__: 当 `DISABLE_IPINFO` 设置为 false 时,指定从服务器测量的距禂方式。可以是 `km` 表示千米,`mi` 表示英里,或空字符串表示禁用距离测量。默认值:`km` +* __`WEBPORT`__: 允许选择包含的 Web 服务器的自定义端口。默认值:`80` + +###### 示例 +此命令在前端模式下启动 LibreSpeed,使用给定的 `servers.json` 文件,以及遥测、ID 模糊化和统计密码: -###### Example -This command starts LibreSpeed in frontend mode, with a given `servers.json` file, and with telemetry, ID obfuscation, and a stats password: ``` -docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it 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. \ No newline at end of file +docker run -e MODE=frontend -e TELEMETRY=true -e ENABLE_ID_OBFUSCATION=true -e PASSWORD="yourPasswordHere" -v $(pwd)/servers.json:/servers.json -p 80:80 -it ghcr.io/kumakaiha/speedtest +``` \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 6717429..d35f828 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,48 +1,39 @@ #!/bin/bash - set -e set -x # Cleanup rm -rf /var/www/html/* - # Copy frontend files cp /speedtest/*.js /var/www/html/ - # Copy favicon cp /speedtest/favicon.ico /var/www/html/ - # Set up backend side for standlone modes -if [[ "$MODE" == "standalone" || "$MODE" == "dual" ]]; then +if [ "$MODE" == "standalone" ]; 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" ]]; then +if [ "$MODE" == "frontend" ]; then cp /speedtest/frontend.php /var/www/html/index.php elif [ "$MODE" == "standalone" ]; then cp /speedtest/standalone.php /var/www/html/index.php 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 +if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalone" ) ]]; then cp -r /speedtest/results /var/www/html/results - if [ "$MODE" == "frontend" ]; then mkdir /var/www/html/backend cp /speedtest/backend/getIP_util.php /var/www/html/backend 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 @@ -61,31 +52,24 @@ if [[ "$TELEMETRY" == "true" && ( "$MODE" == "frontend" || "$MODE" == "standalon else sed -i s/\$db_type\ =\ \'.*\'/\$db_type\ =\ \'sqlite\'\/g /var/www/html/results/telemetry_settings.php fi - 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 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/ chown www-data /database/ fi - chown -R www-data /var/www/html/* - # Allow selection of Apache port for network_mode: host if [ "$WEBPORT" != "80" ]; then sed -i "s/^Listen 80\$/Listen $WEBPORT/g" /etc/apache2/ports.conf sed -i "s/*:80>/*:$WEBPORT>/g" /etc/apache2/sites-available/000-default.conf fi - echo "Done, Starting APACHE" - # This runs apache apache2-foreground + diff --git a/docker/frontend.php b/docker/frontend.php index 724fdc0..a0882f7 100755 --- a/docker/frontend.php +++ b/docker/frontend.php @@ -182,6 +182,14 @@ function initUI(){ I("jitText").textContent=""; I("ip").textContent=""; } +function copyResultsURL() { + var resultsURL = document.getElementById('resultsURL'); + resultsURL.style.display = 'block'; // 显示文本框 + resultsURL.select(); // 选中文本 + document.execCommand('copy'); // 复制文本 + resultsURL.style.display = 'none'; // 隐藏文本框 + alert('结果链接已复制'); +} -<?= getenv('TITLE') ?: 'LibreSpeed Example' ?> +<?= getenv('TITLE') ?: '服务器测速' ?> -

+

-

Selecting a server...

+

选择一个服务器...