mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-03-07 15:15:52 +08:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3125b49b63 | ||
|
|
729631deef | ||
|
|
fe0721f077 | ||
|
|
201619ecf7 | ||
|
|
12effc301f | ||
|
|
fede8a04e6 | ||
|
|
b63f368837 | ||
|
|
c9a8c2b8cf | ||
|
|
e80d7fff50 | ||
|
|
f61a94886b | ||
|
|
f3f2bafbe7 | ||
|
|
5cf3b4bb42 | ||
|
|
6667e82c84 | ||
|
|
af4e8cf8b2 | ||
|
|
f2ec0a447c | ||
|
|
45b604103e | ||
|
|
05ba005960 | ||
|
|
a0b194f1d0 | ||
|
|
7e21b2f46b | ||
|
|
efafc38db8 | ||
|
|
b14b3657b7 | ||
|
|
2634fe43ff | ||
|
|
b26fa89447 | ||
|
|
a6b08bb4b8 | ||
|
|
bd6fbb9f1f | ||
|
|
465a83462b |
33
.github/ISSUE_TEMPLATE/01-bugReport.yml
vendored
Normal file
33
.github/ISSUE_TEMPLATE/01-bugReport.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: 反馈问题 (Bug report)
|
||||
description: 软件报错等异常情况,或遇到预期之外的问题...
|
||||
labels: 反馈问题
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
发之前,请先搜下有没有类似的 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues)、[**Discussions**](https://github.com/XIU2/CloudflareSpeedTest/discussions) 问题(包括[**已关闭**](https://github.com/XIU2/CloudflareSpeedTest/issues?q=is%3Aissue+is%3Aclosed)的),请勿重复发起!
|
||||
|
||||
注意!如果你反馈的问题和 CloudflareST **软件本身功能无关**(如关于 Cloudflare CDN 的网络问题),请**前往讨论区** (💬 [**Discussions**](https://github.com/XIU2/CloudflareSpeedTest/discussions)) 发帖交流!(不合适的 Issues 会被转过去
|
||||
****
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 问题描述
|
||||
description: 必填,最好写上 复现问题 的步骤,越详细越好,特别是一些复杂的问题
|
||||
placeholder: 请输入...
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: 软件版本
|
||||
description: 必填,可通过运行软件来获取版本信息(例如 v2.2.2)
|
||||
placeholder: 请输入...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: screenshots
|
||||
attributes:
|
||||
label: 附加截图
|
||||
description: 可选,也可以是一些错误代码
|
||||
placeholder: 可在此粘贴图片,或点击下方 [Attach files by dragging & dropping, selecting or pasting them.] 文字来选择图片...
|
||||
29
.github/ISSUE_TEMPLATE/02-featureRequest.yml
vendored
Normal file
29
.github/ISSUE_TEMPLATE/02-featureRequest.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: 功能建议 (Feature request)
|
||||
description: 有什么建议,或希望添加、完善某个功能...
|
||||
labels: 功能建议
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
发之前,请先搜下有没有类似的 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues)、[**Discussions**](https://github.com/XIU2/CloudflareSpeedTest/discussions) 问题(包括[**已关闭**](https://github.com/XIU2/CloudflareSpeedTest/issues?q=is%3Aissue+is%3Aclosed)的),请勿重复发起!
|
||||
|
||||
注意!如果你提的功能建议和 CloudflareST **软件本身功能无关**,请**前往讨论区** (💬 [**Discussions**](https://github.com/XIU2/CloudflareSpeedTest/discussions)) 发帖交流!
|
||||
|
||||
> 另外,不接受**个性化**的功能请求(即 **很少人** 或 **只有你自己** 才会用到的功能)
|
||||
****
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: 功能需求
|
||||
description: 必填,你要什么样的功能?
|
||||
placeholder: 请输入...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: anticipation
|
||||
attributes:
|
||||
label: 预期目标
|
||||
description: 必填,你希望该功能具体是什么样子的?如果能提供 示例/截图/代码 就更好了
|
||||
placeholder: 请输入...
|
||||
validations:
|
||||
required: true
|
||||
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
5
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 前往讨论区 (💬 Discussions)
|
||||
url: https://github.com/XIU2/CloudflareSpeedTest/discussions
|
||||
about: Issues 仅用于反馈问题、功能建议,其他话题请到 💬 Discussions 发帖讨论(不合适的 Issues 会被转过去
|
||||
136
README.md
136
README.md
@@ -7,14 +7,14 @@
|
||||
[](https://github.com/XIU2/CloudflareSpeedTest/)
|
||||
|
||||
国外很多网站都在使用 Cloudflare CDN,但分配给中国内地访客的 IP 并不友好(延迟高、丢包多、速度慢)。
|
||||
虽然 Cloudflare 公开了所有 [IP 段](https://www.cloudflare.com/ips/) ,但想要在这么多 IP 中找到适合自己的,怕是要累死,于是就有了这个软件。
|
||||
虽然 Cloudflare 公开了所有 [IP 段](https://www.cloudflare.com/zh-cn/ips/) ,但想要在这么多 IP 中找到适合自己的,怕是要累死,于是就有了这个软件。
|
||||
|
||||
**「自选优选 IP」测试 Cloudflare CDN 延迟和速度,获取最快 IP (IPv4+IPv6)**!好用的话**点个`⭐`鼓励一下叭~**
|
||||
|
||||
> _分享我其他开源项目:[**TrackersList.com** - 全网热门 BT Tracker 列表!有效提高 BT 下载速度~](https://github.com/XIU2/TrackersListCollection) <img src="https://img.shields.io/github/stars/XIU2/TrackersListCollection.svg?style=flat-square&label=Star&color=4285dd&logo=github" height="16px" />_
|
||||
> _[**UserScript** - 🐵 Github 高速下载、知乎增强、自动无缝翻页、护眼模式 等十几个**油猴脚本**!](https://github.com/XIU2/UserScript)<img src="https://img.shields.io/github/stars/XIU2/UserScript.svg?style=flat-square&label=Star&color=4285dd&logo=github" height="16px" />_
|
||||
|
||||
> 本项目也支持对**其他 CDN / 网站 IP** 延迟测速(如:[CloudFront](https://github.com/XIU2/CloudflareSpeedTest/issues/180)、[Gcore](https://github.com/XIU2/CloudflareSpeedTest/issues/267) CDN),但下载测速需自行寻找地址
|
||||
> 本项目也支持对**其他 CDN / 网站 IP** 延迟测速(如:[CloudFront](https://github.com/XIU2/CloudflareSpeedTest/discussions/304)、[Gcore](https://github.com/XIU2/CloudflareSpeedTest/discussions/303) CDN),但下载测速需自行寻找地址
|
||||
|
||||
> 对于**代理套 Cloudflare CDN** 的用户,须知这应为**备用方案**,而不应该是**唯一方案**,请勿过度依赖 [#217](https://github.com/XIU2/CloudflareSpeedTest/issues/217) [#188](https://github.com/XIU2/CloudflareSpeedTest/issues/188)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
### 下载运行
|
||||
|
||||
1. 下载编译好的可执行文件 [蓝奏云](https://pan.lanzouv.com/b0742hkxe) / [Github](https://github.com/XIU2/CloudflareSpeedTest/releases) 并解压。
|
||||
1. 下载编译好的可执行文件 [蓝奏云](https://pan.lanzouf.com/b0742hkxe) / [Github](https://github.com/XIU2/CloudflareSpeedTest/releases) 并解压。
|
||||
2. 双击运行 `CloudflareST.exe` 文件(Windows 系统),等待测速完成...
|
||||
|
||||
<details>
|
||||
@@ -41,10 +41,10 @@ mkdir CloudflareST
|
||||
cd CloudflareST
|
||||
|
||||
# 下载 CloudflareST 压缩包(自行根据需求替换 URL 中 [版本号] 和 [文件名])
|
||||
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.1/CloudflareST_linux_amd64.tar.gz
|
||||
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.2/CloudflareST_linux_amd64.tar.gz
|
||||
# 如果你是在国内服务器上下载,那么请使用下面这几个镜像加速:
|
||||
# wget -N https://download.fastgit.org/XIU2/CloudflareSpeedTest/releases/download/v2.2.1/CloudflareST_linux_amd64.tar.gz
|
||||
# wget -N https://ghproxy.com/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.1/CloudflareST_linux_amd64.tar.gz
|
||||
# wget -N https://download.fastgit.org/XIU2/CloudflareSpeedTest/releases/download/v2.2.2/CloudflareST_linux_amd64.tar.gz
|
||||
# wget -N https://ghproxy.com/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.2/CloudflareST_linux_amd64.tar.gz
|
||||
# 如果下载失败的话,尝试删除 -N 参数(如果是为了更新,则记得提前删除旧压缩包 rm CloudflareST_linux_amd64.tar.gz )
|
||||
|
||||
# 解压(不需要删除旧文件,会直接覆盖,自行根据需求替换 文件名)
|
||||
@@ -67,7 +67,7 @@ chmod +x CloudflareST
|
||||
|
||||
****
|
||||
|
||||
> _在**手机**上独立运行 CloudflareST 测速的简单教程:**[Android](https://github.com/XIU2/CloudflareSpeedTest/discussions/61)、[Android APP](https://github.com/xianshenglu/cloudflare-ip-tester-app)、[IOS](https://github.com/XIU2/CloudflareSpeedTest/issues/151)**_
|
||||
> _在**手机**上独立运行 CloudflareST 测速的简单教程:**[Android](https://github.com/XIU2/CloudflareSpeedTest/discussions/61)、[Android APP](https://github.com/xianshenglu/cloudflare-ip-tester-app)、[IOS](https://github.com/XIU2/CloudflareSpeedTest/discussions/321)**_
|
||||
|
||||
### 结果示例
|
||||
|
||||
@@ -109,7 +109,7 @@ IP 地址 已发送 已接收 丢包率 平均延迟 下载速度
|
||||
|
||||
```
|
||||
IP 地址, 已发送, 已接收, 丢包率, 平均延迟, 下载速度 (MB/s)
|
||||
104.27.200.69, 4, 4, 0.00, 146.23, 28.64
|
||||
104.27.200.69,4,4,0.00,146.23,28.64
|
||||
```
|
||||
|
||||
> _大家可以按自己需求,对完整结果**进一步筛选处理**,或者去看一看进阶使用**指定过滤条件**!_
|
||||
@@ -142,10 +142,12 @@ https://github.com/XIU2/CloudflareSpeedTest
|
||||
|
||||
-httping
|
||||
切换测速模式;延迟测速模式改为 HTTP 协议,所用测试地址为 [-url] 参数;(默认 TCPing)
|
||||
注意:HTTPing 本质上也算一种 网络扫描 行为,因此如果你在服务器上面运行,需要降低并发(-n),否则可能会被一些严格的商家暂停服务。
|
||||
如果你遇到 HTTPing 首次测速可用 IP 数量正常,后续测速越来越少甚至直接为 0,但停一段时间后又恢复了的情况,那么也可能是被 运营商、Cloudflare CDN 认为你在网络扫描而 触发临时限制机制,因此才会过一会儿就恢复了,建议降低并发(-n)减少这种情况的发生。
|
||||
-httping-code 200
|
||||
有效状态代码;HTTPing 延迟测速时网页返回的有效 HTTP 状态码,仅限一个;(默认 200 301 302)
|
||||
-cfcolo HKG,KHH,NRT,LAX,SEA,SJC,FRA,MAD
|
||||
匹配指定地区;地区名为当地机场三字码,英文逗号分隔,仅 HTTPing 模式可用;(默认 所有地区)
|
||||
匹配指定地区;地区名为当地机场三字码,英文逗号分隔,支持小写,支持 Cloudflare、AWS CloudFront,仅 HTTPing 模式可用;(默认 所有地区)
|
||||
|
||||
-tl 200
|
||||
平均延迟上限;只输出低于指定平均延迟的 IP,可与其他上限/下限搭配;(默认 9999 ms)
|
||||
@@ -179,6 +181,7 @@ https://github.com/XIU2/CloudflareSpeedTest
|
||||
Windows 要指定参数需要在 CMD 中运行,或者把参数添加到快捷方式目标中。
|
||||
|
||||
> **注意**:各参数均有**默认值**,使用默认值的参数是可以省略的(**按需选择**),参数**不分前后顺序**。
|
||||
> **提示**:Windows **PowerShell** 只需把下面命令中的 `CloudflareST.exe` 改为 `.\CloudflareST.exe` 即可。
|
||||
> **提示**:Linux 系统只需要把下面命令中的 `CloudflareST.exe` 改为 `./CloudflareST` 即可。
|
||||
|
||||
****
|
||||
@@ -207,6 +210,8 @@ Windows 要指定参数需要在 CMD 中运行,或者把参数添加到快捷
|
||||
|
||||
> 当然你也可以随便打开一个 CMD 窗口,然后输入如 `cd /d "D:\Program Files\CloudflareST"` 来进入程序目录
|
||||
|
||||
> **提示**:如果用的是 **PowerShell** 只需把命令中的 `CloudflareST.exe` 改为 `.\CloudflareST.exe` 即可。
|
||||
|
||||
</details>
|
||||
|
||||
****
|
||||
@@ -272,7 +277,7 @@ TCP 协议耗时更短、消耗资源更少,超时时间为 1 秒,该协议
|
||||
HTTP 协议适用于快速测试某域名指向某 IP 时是否可以访问,超时时间为 2 秒。
|
||||
同一个 IP,各协议去 Ping 得到的延迟一般为:**ICMP < TCP < HTTP**,越靠右对丢包等网络波动越敏感。
|
||||
|
||||
> 注意:HTTPing 本质上也算一种**网络扫描**行为,因此如果你在服务器上面运行,需要**降低并发**(`-n`),否则可能会被一些严格的商家暂停服务。
|
||||
> 注意:HTTPing 本质上也算一种**网络扫描**行为,因此如果你在服务器上面运行,需要**降低并发**(`-n`),否则可能会被一些严格的商家暂停服务。如果你遇到 HTTPing 首次测速可用 IP 数量正常,后续测速越来越少甚至直接为 0,但停一段时间后又恢复了的情况,那么也可能是被 运营商、Cloudflare CDN 认为你在网络扫描而**触发临时限制机制**,因此才会过一会儿就恢复了,建议**降低并发**(`-n`)减少这种情况的发生。
|
||||
|
||||
``` bash
|
||||
# 只需加上 -httping 参数即可切换到 HTTP 协议延迟测速模式
|
||||
@@ -285,8 +290,8 @@ CloudflareST.exe -httping -httping-code 200
|
||||
CloudflareST.exe -httping -url https://cf.xiu2.xyz/url
|
||||
|
||||
# 注意:如果测速地址为 HTTP 协议,记得加上 -tp 80(这个参数会影响 延迟测速/下载测速 时使用的端口)
|
||||
# 同理,如果要测速 80 端口,那么也需要加上 -url 参数来指定一个 http:// 协议的地址才行(默认测速地址是 HTTPS 的)
|
||||
CloudflareST.exe -httping -tp 80 -url http://xxx/xxx
|
||||
# 同理,如果要测速 80 端口,那么也需要加上 -url 参数来指定一个 http:// 协议的地址才行(且该地址不会强制重定向至 HTTPS),如果是非 80 443 端口,那么需要确定该下载测速地址是否支持通过该端口访问。
|
||||
CloudflareST.exe -httping -tp 80 -url http://cdn.cloudflare.steamstatic.com/steam/apps/5952/movie_max.webm
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -301,15 +306,16 @@ CloudflareST.exe -httping -tp 80 -url http://xxx/xxx
|
||||
****
|
||||
|
||||
``` bash
|
||||
# 该功能支持 Cloudflare CDN、AWS CloudFront CDN,且这两个 CDN 的机场三字码是通用的
|
||||
# 指定地区名后,延迟测速后得到的结果就都是指定地区的 IP 了(也可以继续进行下载测速)
|
||||
# 节点地区名为当地 机场三字码,指定多个时用英文逗号分隔
|
||||
# 节点地区名为当地 机场三字码,指定多个时用英文逗号分隔,v2.2.3 版本后支持小写
|
||||
|
||||
CloudflareST.exe -cfcolo HKG,KHH,NRT,LAX,SEA,SJC,FRA,MAD
|
||||
|
||||
# 注意,该参数只有在 HTTPing 延迟测速模式下才可用(因为要访问网页来获得)
|
||||
```
|
||||
|
||||
> Cloudflare 所有节点地区名(机场三字码),请看:https://www.cloudflarestatus.com/
|
||||
> 两个 CDN 机场三字码通用,各地区见:https://www.cloudflarestatus.com/
|
||||
|
||||
</details>
|
||||
|
||||
@@ -360,6 +366,26 @@ C:\abc\CloudflareST.exe -f C:\abc\4.txt -o C:\abc\result.csv -dd
|
||||
|
||||
****
|
||||
|
||||
#### \# 测速其他端口
|
||||
|
||||
<details>
|
||||
<summary><code><strong>「 点击展开 查看内容 」</strong></code></summary>
|
||||
|
||||
****
|
||||
|
||||
``` bash
|
||||
# 如果你想要测速非默认 443 的其他端口,则需要通过 -tp 参数指定(该参数会影响 延迟测速/下载测速 时使用的端口)
|
||||
|
||||
# 如果要延迟测速 80 端口+下载测速(如果 -dd 禁用了下载测速则不需要),那么还需要指定 http:// 协议的下载测速地址才行(且该地址不会强制重定向至 HTTPS,因为那样就变成 443 端口了)
|
||||
CloudflareST.exe -tp 80 -url http://cdn.cloudflare.steamstatic.com/steam/apps/5952/movie_max.webm
|
||||
|
||||
# 如果是非 80 443 的其他端口,那么需要确定你使用的下载测速地址是否支持通过该非标端口访问。
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
****
|
||||
|
||||
#### \# 自定义测速地址
|
||||
|
||||
<details>
|
||||
@@ -373,8 +399,8 @@ C:\abc\CloudflareST.exe -f C:\abc\4.txt -o C:\abc\result.csv -dd
|
||||
# 地址要求:可以直接下载、文件大小超过 200MB、用的是 Cloudflare CDN
|
||||
CloudflareST.exe -url https://cf.xiu2.xyz/url
|
||||
|
||||
# 注意:如果测速地址为 HTTP 协议,记得加上 -tp 80(这个参数会影响 延迟测速/下载测速 时使用的端口)
|
||||
CloudflareST.exe -tp 80 -url http://xxx/xxx
|
||||
# 注意:如果测速地址为 HTTP 协议(该地址不能强制重定向至 HTTPS),记得加上 -tp 80(这个参数会影响 延迟测速/下载测速 时使用的端口),如果是非 80 443 端口,那么需要确定下载测速地址是否支持通过该端口访问。
|
||||
CloudflareST.exe -tp 80 -url http://cdn.cloudflare.steamstatic.com/steam/apps/5952/movie_max.webm
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -388,6 +414,8 @@ CloudflareST.exe -tp 80 -url http://xxx/xxx
|
||||
|
||||
****
|
||||
|
||||
> 注意:延迟测速进度条右边的**可用数量**,仅指延迟测速过程中**未超时的 IP 数量**,和延迟上下限条件无关。
|
||||
|
||||
- 指定 **[平均延迟下限]** 条件
|
||||
|
||||
``` bash
|
||||
@@ -508,7 +536,7 @@ CloudflareST.exe -f 1.txt
|
||||
|
||||
我以前说过,开发该软件项目的目的就是为了通过**改 Hosts 的方式来加速访问使用 Cloudflare CDN 的网站**。
|
||||
|
||||
但就如 [**#8**](https://github.com/XIU2/CloudflareSpeedTest/issues/8) 所说,一个个添加域名到 Hosts 实在**太麻烦**了,于是我就找到了个**一劳永逸**的办法!可以看这个 [**还在一个个添加 Hosts?完美本地加速所有使用 Cloudflare CDN 的网站方法来了!**](https://github.com/XIU2/CloudflareSpeedTest/discussions/71) 和另一个[依靠本地 DNS 服务来修改域名解析 IP 为自选 IP](https://github.com/XIU2/CloudflareSpeedTest/issues/115) 的教程。
|
||||
但就如 [**#8**](https://github.com/XIU2/CloudflareSpeedTest/issues/8) 所说,一个个添加域名到 Hosts 实在**太麻烦**了,于是我就找到了个**一劳永逸**的办法!可以看这个 [**还在一个个添加 Hosts?完美本地加速所有使用 Cloudflare CDN 的网站方法来了!**](https://github.com/XIU2/CloudflareSpeedTest/discussions/71) 和另一个[依靠本地 DNS 服务来修改域名解析 IP 为自选 IP](https://github.com/XIU2/CloudflareSpeedTest/discussions/317) 的教程。
|
||||
|
||||
****
|
||||
|
||||
@@ -516,16 +544,16 @@ CloudflareST.exe -f 1.txt
|
||||
|
||||
考虑到很多人获得最快 Cloudflare CDN IP 后,需要替换 Hosts 文件中的 IP。
|
||||
|
||||
可以看这个 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues/42) 获取 **Windows/Linux 自动更新 Hosts 脚本**!
|
||||
可以看这个 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/discussions/312) 获取 **Windows/Linux 自动更新 Hosts 脚本**!
|
||||
|
||||
****
|
||||
|
||||
## 问题反馈
|
||||
|
||||
如果你遇到什么问题,可以先去 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues) 里看看是否有别人问过了(记得去看下 [**Closed**](https://github.com/XIU2/CloudflareSpeedTest/issues?q=is%3Aissue+is%3Aclosed) 的)。
|
||||
如果你遇到什么问题,可以先去 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues)、[Discussions](https://github.com/XIU2/CloudflareSpeedTest/discussions) 里看看是否有别人问过了(记得去看下 [**Closed**](https://github.com/XIU2/CloudflareSpeedTest/issues?q=is%3Aissue+is%3Aclosed) 的)。
|
||||
如果没找到类似问题,请新开个 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues/new) 来告诉我!
|
||||
|
||||
> _有问题请**大胆告诉我**,描述越详细越好(随时可远程协助),如果不说那我怎么去完善功能或~~修复 BUG~~ 呢?!_
|
||||
> **注意**!_与 `反馈问题、功能建议` 无关的,请前往项目内部 论坛 讨论(上面的 `💬 Discussions`_
|
||||
|
||||
****
|
||||
|
||||
@@ -538,15 +566,18 @@ CloudflareST.exe -f 1.txt
|
||||
## 衍生项目
|
||||
|
||||
- _https://github.com/xianshenglu/cloudflare-ip-tester-app_
|
||||
_**CloudflareST 安卓版 APP [#202](https://github.com/XIU2/CloudflareSpeedTest/issues/202)**_
|
||||
_**CloudflareST 安卓版 APP [#202](https://github.com/XIU2/CloudflareSpeedTest/discussions/320)**_
|
||||
|
||||
- _https://github.com/mingxiaoyu/luci-app-cloudflarespeedtest_
|
||||
_**CloudflareST OpenWrt 路由器插件版 [#174](https://github.com/XIU2/CloudflareSpeedTest/issues/174)**_
|
||||
_**CloudflareST OpenWrt 路由器插件版 [#174](https://github.com/XIU2/CloudflareSpeedTest/discussions/319)**_
|
||||
|
||||
- _https://github.com/immortalwrt-collections/openwrt-cdnspeedtest_
|
||||
_**CloudflareST OpenWrt 原生编译版本 [#64](https://github.com/XIU2/CloudflareSpeedTest/discussions/64)**_
|
||||
|
||||
> _此处仅收集了在本项目 Issues 中宣传过的部分 CloudflareST 相关衍生项目,如果有遗漏可以告诉我~_
|
||||
- _https://github.com/hoseinnikkhah/CloudflareSpeedTest-English_
|
||||
_**English language version of CloudflareST (Text language differences only) [#64](https://github.com/XIU2/CloudflareSpeedTest/issues/68)**_
|
||||
|
||||
> _此处仅收集了在本项目中宣传过的部分 CloudflareST 相关衍生项目,如果有遗漏可以告诉我~_
|
||||
|
||||
****
|
||||
|
||||
@@ -559,6 +590,65 @@ _**CloudflareST OpenWrt 原生编译版本 [#64](https://github.com/XIU2/Cloudfl
|
||||
|
||||
****
|
||||
|
||||
## 手动编译
|
||||
|
||||
<details>
|
||||
<summary><code><strong>「 点击展开 查看内容 」</strong></code></summary>
|
||||
|
||||
****
|
||||
|
||||
为了方便,我是在编译的时候将版本号写入代码中的 version 变量,因此你手动编译时,需要像下面这样在 `go build` 命令后面加上 `-ldflags` 参数来指定版本号:
|
||||
|
||||
```bash
|
||||
go build -ldflags "-s -w -X main.version=v2.3.3"
|
||||
# 在 CloudflareSpeedTest 目录中通过命令行(例如 CMD、Bat 脚本)运行该命令,即可编译一个可在和当前设备同样系统、位数、架构的环境下运行的二进制程序(Go 会自动检测你的系统位数、架构)且版本号为 v2.3.3
|
||||
```
|
||||
|
||||
如果想要在 Windows 64位系统下编译**其他系统、架构、位数**,那么需要指定 **GOOS** 和 **GOARCH** 变量。
|
||||
|
||||
例如在 Windows 系统下编译一个适用于 **Linux 系统 amd 架构 64 位**的二进制程序:
|
||||
|
||||
```bat
|
||||
SET GOOS=linux
|
||||
SET GOARCH=amd64
|
||||
go build -ldflags "-s -w -X main.version=v2.3.3"
|
||||
```
|
||||
|
||||
例如在 Linux 系统下编译一个适用于 **Windows 系统 amd 架构 32 位**的二进制程序:
|
||||
|
||||
```bash
|
||||
GOOS=windows
|
||||
GOARCH=386
|
||||
go build -ldflags "-s -w -X main.version=v2.3.3"
|
||||
```
|
||||
|
||||
> 可以运行 `go tool dist list` 来查看当前 Go 版本支持编译哪些组合。
|
||||
|
||||
****
|
||||
|
||||
当然,为了方便批量编译,我会专门指定一个变量为版本号,后续编译直接调用该版本号变量即可。
|
||||
同时,批量编译的话,还需要分开放到不同文件夹才行(或者文件名不同),需要加上 `-o` 参数指定。
|
||||
|
||||
```bat
|
||||
:: Windows 系统下是这样:
|
||||
SET version=v2.3.3
|
||||
SET GOOS=linux
|
||||
SET GOARCH=amd64
|
||||
go build -o Releases\CloudflareST_linux_amd64\CloudflareST -ldflags "-s -w -X main.version=%version%"
|
||||
```
|
||||
|
||||
```bash
|
||||
# Linux 系统下是这样:
|
||||
version=v2.3.3
|
||||
GOOS=windows
|
||||
GOARCH=386
|
||||
go build -o Releases/CloudflareST_windows_386/CloudflareST.exe -ldflags "-s -w -X main.version=${version}"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
****
|
||||
|
||||
## License
|
||||
|
||||
The GPL-3.0 License.
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module CloudflareSpeedTest
|
||||
module github.com/XIU2/CloudflareSpeedTest
|
||||
|
||||
go 1.14
|
||||
|
||||
|
||||
4
main.go
4
main.go
@@ -9,8 +9,8 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"CloudflareSpeedTest/task"
|
||||
"CloudflareSpeedTest/utils"
|
||||
"github.com/XIU2/CloudflareSpeedTest/task"
|
||||
"github.com/XIU2/CloudflareSpeedTest/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"CloudflareSpeedTest/utils"
|
||||
"github.com/XIU2/CloudflareSpeedTest/utils"
|
||||
|
||||
"github.com/VividCortex/ewma"
|
||||
)
|
||||
@@ -169,6 +169,8 @@ func downloadHandler(ip *net.IPAddr) float64 {
|
||||
if err != nil {
|
||||
if err != io.EOF { // 如果文件下载过程中遇到报错(如 Timeout),且并不是因为文件下载完了,则退出循环(终止测速)
|
||||
break
|
||||
} else if contentLength == -1 { // 文件下载完成 且 文件大小未知,则退出循环(终止测速),例如:https://speed.cloudflare.com/__down?bytes=200000000 这样的,如果在 10 秒内就下载完成了,会导致测速结果明显偏低甚至显示为 0.00(下载速度太快时)
|
||||
break
|
||||
}
|
||||
// 获取上个时间片
|
||||
last_time_slice := timeStart.Add(timeSlice * time.Duration(timeCounter-1))
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -17,6 +18,7 @@ var (
|
||||
HttpingStatusCode int
|
||||
HttpingCFColo string
|
||||
HttpingCFColomap *sync.Map
|
||||
OutRegexp = regexp.MustCompile(`[A-Z]{3}`)
|
||||
)
|
||||
|
||||
// pingReceived pingTotalTime
|
||||
@@ -46,6 +48,7 @@ func (p *Ping) httping(ip *net.IPAddr) (int, time.Duration) {
|
||||
defer resp.Body.Close()
|
||||
|
||||
//fmt.Println("IP:", ip, "StatusCode:", resp.StatusCode, resp.Request.URL)
|
||||
// 如果未指定的 HTTP 状态码,或指定的状态码不合规,则默认只认为 200、301、302 才算 HTTPing 通过
|
||||
if HttpingStatusCode == 0 || HttpingStatusCode < 100 && HttpingStatusCode > 599 {
|
||||
if resp.StatusCode != 200 && resp.StatusCode != 301 && resp.StatusCode != 302 {
|
||||
return 0, 0
|
||||
@@ -58,10 +61,17 @@ func (p *Ping) httping(ip *net.IPAddr) (int, time.Duration) {
|
||||
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
|
||||
// 只有指定了地区才匹配机场三字码
|
||||
if HttpingCFColo != "" {
|
||||
cfRay := resp.Header.Get("CF-RAY")
|
||||
// 通过头部 Server 值判断是 Cloudflare 还是 AWS CloudFront 并设置 cfRay 为各自的机场三字码完整内容
|
||||
cfRay := func() string {
|
||||
if resp.Header.Get("Server") == "cloudflare" {
|
||||
return resp.Header.Get("CF-RAY") // 示例 cf-ray: 7bd32409eda7b020-SJC
|
||||
}
|
||||
return resp.Header.Get("x-amz-cf-pop") // 示例 X-Amz-Cf-Pop: SIN52-P1
|
||||
}()
|
||||
colo := p.getColo(cfRay)
|
||||
if colo == "" {
|
||||
if colo == "" { // 没有匹配到三字码或不符合指定地区则直接结束该 IP 测试
|
||||
return 0, 0
|
||||
}
|
||||
}
|
||||
@@ -102,8 +112,8 @@ func MapColoMap() *sync.Map {
|
||||
if HttpingCFColo == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
colos := strings.Split(HttpingCFColo, ",")
|
||||
// 将参数指定的地区三字码转为大写并格式化
|
||||
colos := strings.Split(strings.ToUpper(HttpingCFColo), ",")
|
||||
colomap := &sync.Map{}
|
||||
for _, colo := range colos {
|
||||
colomap.Store(colo, colo)
|
||||
@@ -115,14 +125,13 @@ func (p *Ping) getColo(b string) string {
|
||||
if b == "" {
|
||||
return ""
|
||||
}
|
||||
idColo := strings.Split(b, "-")
|
||||
|
||||
out := idColo[1]
|
||||
// 正则匹配并返回 机场三字码
|
||||
out := OutRegexp.FindString(b)
|
||||
|
||||
if HttpingCFColomap == nil {
|
||||
return out
|
||||
}
|
||||
|
||||
// 匹配 机场三字码 是否为指定的地区
|
||||
_, ok := HttpingCFColomap.Load(out)
|
||||
if ok {
|
||||
return out
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"CloudflareSpeedTest/utils"
|
||||
"github.com/XIU2/CloudflareSpeedTest/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user