13 Commits

Author SHA1 Message Date
xiu2
3736d81dda README.md 2021-08-11 10:48:12 +08:00
xiu2
a42059737b 新增 [平均延迟下限] 参数(用于过滤被假蔷的 IP) 2021-08-11 10:46:36 +08:00
xiu2
46da45b25f 新增 [平均延迟下限] 参数(用于过滤被假蔷的 IP) 2021-08-11 10:37:59 +08:00
xiu2
acd47ee96d README.md 2021-08-10 01:14:08 +08:00
xiu2
698108f453 优化 文本显示 2021-07-24 13:45:11 +08:00
xiu2
2963b61910 README.md 2021-07-22 19:20:39 +08:00
xiu2
9bab2944b1 README.md 2021-07-17 07:21:54 +08:00
xiu2
fa5e4f34f0 README.md 2021-07-04 08:04:59 +08:00
xiu2
db9d092010 README.md 2021-07-01 14:34:53 +08:00
xiu2
180097b044 删除 多余的空格 2021-04-09 12:53:45 +08:00
xiu2
c115249811 更新 ip.txt(官方改动) 2021-04-09 07:23:04 +08:00
xiu2
3b7851f77c README.md 2021-04-03 10:19:26 +08:00
xiu2
80c201f160 README.md 2021-03-21 21:00:03 +08:00
3 changed files with 84 additions and 43 deletions

View File

@@ -9,16 +9,16 @@
[国外很多网站](https://github.com/XIU2/CloudflareSpeedTest/discussions/62)都在使用 Cloudflare CDN但分配给中国访客的 IP 并不友好(高延迟/高丢包/速度慢等)。
虽然 Cloudflare 公开了所有 [IP 段](https://www.cloudflare.com/ips/) ,但想要在这么多 IP 中找到适合自己的,怕是要累死,所以就有了这个软件。
该软件可以**测试 Cloudflare CDN 延迟和速度,获取最快 IP (IPv4+IPv6)**觉得好用请**点个⭐鼓励一下下~**
**「自选 IP/优选 IP」测试 Cloudflare CDN 延迟和速度,获取最快 IP (IPv4+IPv6)**好用的话**点个⭐鼓励一下下~**
> _我另一个开源项目 **[一个 \[油猴脚本\] 轻松解决「Github」文件下载速度慢的问题](https://github.com/XIU2/UserScript)**_
> _我另一个开源项目 **[一个 \[油猴脚本\] 轻松解决「Github」文件下载速度慢的问题+ 其他原创油猴脚本~](https://github.com/XIU2/UserScript)**_
****
## 快速使用
### 下载运行
1. 下载编译好的可执行文件 [蓝奏云](https://xiu.lanzoux.com/b0742hkxe) / [Github](https://github.com/XIU2/CloudflareSpeedTest/releases) 并解压。
1. 下载编译好的可执行文件 [蓝奏云](https://pan.lanzoui.com/b0742hkxe) / [Github](https://github.com/XIU2/CloudflareSpeedTest/releases) 并解压。
2. 双击运行 `CloudflareST.exe`文件Windows等待测速完成...
<details>
@@ -78,7 +78,10 @@ IP 地址 已发送 已接收 丢包率 平均延迟 下载速度
# 如果平均延迟非常低(如 0.xx则说明 CloudflareST 测速时走了代理,请先关闭代理软件后再测速。
# 如果在路由器上运行(如 OpenWrt请先关闭路由器内的代理否则测速结果会不准确且无法使用。
# 因为默认下载测速地址的文件大小只有 300MB如果你速度太快的话测速结果可能会低于实际速度。
# 因为每次测速都是在每个 IP 段中随机 IP所以每次的测速结果都不可能相同这是正常的
# 软件是先 延迟测速并按从低到高排序后,再从 最低延迟的 IP 开始下载测速的,所以:
```
@@ -119,15 +122,17 @@ https://github.com/XIU2/CloudflareSpeedTest
-url https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png
下载测速地址;用来下载测速的 Cloudflare CDN 文件地址,如地址含有空格请加上引号;
-tl 200
平均延迟上限;只输出低于指定平均延迟的 IP单独使用也可搭配下载速度下限(默认 9999.00 ms)
平均延迟上限;只输出低于指定平均延迟的 IP与其他上限/下限搭配(默认 9999 ms)
-tll 40
平均延迟下限;只输出高于指定平均延迟的 IP可与其他上限/下限搭配,过滤被假蔷的 IP(默认 0 ms)
-sl 5
下载速度下限;只输出高于指定下载速度的 IP凑够指定数量 [-dn] 才会停止测速;(默认 0.00 MB/s )
下载速度下限;只输出高于指定下载速度的 IP凑够指定数量 [-dn] 才会停止测速;(默认 0.00 MB/s)
-p 20
显示结果数量;测速后直接显示指定数量的结果,为 0 时不显示结果直接退出;(默认 20 )
-f ip.txt
IP段数据文件如路径含有空格请加上引号支持其他 CDN IP段(默认 ip.txt )
-o result.csv
输出结果文件;如路径含有空格请加上引号;值为空时不输出 [-o " "](默认 result.csv )
写入结果文件;如路径含有空格请加上引号;值为空时不写入文件 [-o ""](默认 result.csv )
-dd
禁用下载测速;禁用后测速结果会按延迟排序 (默认按下载速度排序)(默认 启用 )
-ipv6
@@ -142,7 +147,7 @@ https://github.com/XIU2/CloudflareSpeedTest
### 使用示例
Windows 在 CMD 中运行,或者把相关参数添加到快捷方式目标中。
Windows 要指定参数需要在 CMD 中运行,或者把参数添加到快捷方式目标中。
> **注意**:各参数均有**默认值**,使用默认值的参数是可以省略的(**按需选择**),参数**不分前后顺序**。
> **提示**Linux 系统只需要把下面命令中的 `CloudflareST.exe` 改为 `./CloudflareST` 即可。
@@ -150,10 +155,10 @@ Windows 是在 CMD 中运行,或者把相关参数添加到快捷方式目标
#### \# IPv4/IPv6
``` bash
# 指定 IPv4 数据文件(-f 默认值就是 ip.txt所以该参数可以省略
# 测速 IPv4 时,需要指定 IPv4 数据文件(-f 默认值就是 ip.txt所以该参数可以省略
CloudflareST.exe -f ip.txt
# 指定 IPv6 数据文件( ipv6.txt ),需要加上 -ipv6 参数
# 测速 IPv6 时,需要指定 IPv6 数据文件( ipv6.txt ),需要加上 -ipv6 参数
CloudflareST.exe -f ipv6.txt -ipv6
```
****
@@ -161,16 +166,16 @@ CloudflareST.exe -f ipv6.txt -ipv6
``` bash
# 指定 IPv4 数据文件,不显示结果直接退出,输出结果到文件(-p 值为 0
CloudflareST.exe -f ip.txt -p 0 -dd
CloudflareST.exe -f 1.txt -p 0 -dd
# 指定 IPv4 数据文件,不输出结果到文件,直接显示结果(-p 值为 10 条,-o 值为空
CloudflareST.exe -f ip.txt -o " " -p 10 -dd
# 指定 IPv4 数据文件,不输出结果到文件,直接显示结果(-p 值为 10 条,-o 值为空但引号不能少
CloudflareST.exe -f 2.txt -o "" -p 10 -dd
# 指定 IPv4 数据文件 及 输出结果到文件(相对路径,即当前目录下,如含空格请加上引号)
CloudflareST.exe -f ip.txt -o result.csv -dd
CloudflareST.exe -f 3.txt -o result.txt -dd
# 指定 IPv4 数据文件 及 输出结果到文件(绝对路径,即 C:\abc\ 目录下,如含空格请加上引号)
CloudflareST.exe -f C:\abc\ip.txt -o C:\abc\result.csv -dd
CloudflareST.exe -f C:\abc\4.txt -o C:\abc\result.csv -dd
```
****
#### \# 自定义下载测速地址
@@ -178,11 +183,25 @@ CloudflareST.exe -f C:\abc\ip.txt -o C:\abc\result.csv -dd
``` bash
# 地址要求:可以直接下载、文件大小超过 200MB、用的是 Cloudflare CDN
CloudflareST.exe -url https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png
# 因为默认下载测速地址的文件大小只有 300MB如果你速度太快的话测速结果可能会低于实际速度。
```
****
#### \# 自定义测速条件
- \# 仅指定 **[平均延迟上限]** 条件
<details>
<summary><code><strong>「 点击展开 查看内容 」</strong></code></summary>
****
- 指定 **[平均延迟下限]** 条件(用于过滤**被假蔷的 IP**,这类 IP 都被 TCP 劫持因此延迟很低只有几十ms
``` bash
# 平均延迟下限40 ms
# 平均延迟下限和其他的上下限参数一样,都可以单独使用、互相搭配使用!
CloudflareST.exe -tll 40
```
- 仅指定 **[平均延迟上限]** 条件
``` bash
# 平均延迟上限200 ms下载速度下限0 MB/s数量10 个(可选)
@@ -194,7 +213,7 @@ CloudflareST.exe -tl 200 -dn 10
****
- \# 仅指定 **[平均延迟上限]** 条件,且**只延迟测速,不下载测速**
- 仅指定 **[平均延迟上限]** 条件,且**只延迟测速,不下载测速**
``` bash
# 平均延迟上限200 ms下载速度下限0 MB/s数量不知道多少 个
@@ -204,7 +223,7 @@ CloudflareST.exe -tl 200 -dd
****
- \# 仅指定 **[下载速度下限]** 条件
- 仅指定 **[下载速度下限]** 条件
``` bash
# 平均延迟上限9999 ms下载速度下限5 MB/s数量10 个(可选)
@@ -217,7 +236,7 @@ CloudflareST.exe -sl 5 -dn 10
****
- \# 同时指定 **[平均延迟上限] + [下载速度下限]** 条件
- 同时指定 **[平均延迟上限] + [下载速度下限]** 条件
``` bash
# 平均延迟上限、下载速度下限均支持小数(如 -sl 0.5
@@ -233,8 +252,15 @@ CloudflareST.exe -tl 200 -sl 5.6 -dn 10
> 因为Cloudflare 公开的 IP 段是**回源 IP+任播 IP**,而**回源 IP**是无法使用的,所以下载测速是 0.00。
> 运行时可以加上 `-sl 0.01`(下载速度下限),过滤掉**回源 IP**(下载测速低于 0.01MB/s 的结果)。
</details>
****
#### \# Windows 快捷方式如何使用参数
<details>
<summary><code><strong>「 点击展开 查看内容 」</strong></code></summary>
****
#### \# Windows 快捷方式
``` bash
## 右键快捷方式 - 目标
@@ -244,17 +270,26 @@ D:\ABC\CloudflareST\CloudflareST.exe -n 500 -t 4 -dn 20 -dt 5 -o " "
# 如果文件路径包含引号,则需要把启动参数放在引号外面,记得引号和 - 之间有空格。
"D:\Program Files\CloudflareST\CloudflareST.exe" -n 500 -t 4 -dn 20 -dt 5 -o " "
```
</details>
****
#### \# 单独对一个或多个 IP 测速
<details>
<summary><code><strong>「 点击展开 查看内容 」</strong></code></summary>
****
#### \# 单独测速 IP
如果要单独**对一个或多个 IP 进行测速**,只需要把这些 IP 按如下格式写入到任意文本文件中,例如:`1.txt`
``` json
1.1.1.1/32
1.1.1.1
1.1.1.200
1.0.0.1/24
```
> 子网掩码 `/32` 指的是这个 IP 本身,即 `1.1.1.1`。
> 自从 v1.4.10 版本后,单个 IP 就不需要添加子网掩码 `/32` 了(`1.1.1.1`等同于 `1.1.1.1/32`
> 子网掩码 `/24` 指的是这个 IP 最后一段,即 `1.0.0.1~1.0.0.255`。
@@ -271,14 +306,16 @@ CloudflareST.exe -f 1.txt
# 对于 IP 段 1.0.0.1/24 软件只会随机最后一段1.0.0.1~255如果要测速该 IP 段中的所有 IP需要加上 -allip 参数。
```
</details>
****
#### \# 一劳永逸加速所有使用 Cloudflare CDN 的网站(不需要再一个个添加域名到 Hosts 了)
我以前说过,开发该软件项目的目的就是为了通过**改 Hosts 的方式来加速访问使用 Cloudflare CDN 的网站**。
但就如 #8 所说,一个个添加域名到 Hosts 实在**太麻烦**了,于是我就找到了个**一劳永逸**的办法!
但就如 [**#8**](https://github.com/XIU2/CloudflareSpeedTest/issues/8) 所说,一个个添加域名到 Hosts 实在**太麻烦**了,于是我就找到了个**一劳永逸**的办法!
可以看这个 [**还在一个个添加 Hosts完美本地加速所有使用 Cloudflare CDN 的网站方法来了!**](https://github.com/XIU2/CloudflareSpeedTest/discussions/71)
可以看这个 [**还在一个个添加 Hosts完美本地加速所有使用 Cloudflare CDN 的网站方法来了!**](https://github.com/XIU2/CloudflareSpeedTest/discussions/71)
****
#### \# 自动更新 Hosts
@@ -287,13 +324,6 @@ CloudflareST.exe -f 1.txt
可以看这个 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues/42) 获取 **Windows/Linux 自动更新 Hosts 脚本**
****
#### \# 自动更新域名解析记录
如果你的域名托管在 Cloudflare则可以通过 Cloudflare 官方提供的 API 来自动更新域名解析记录。
可以看这个 [**Issues**](https://github.com/XIU2/CloudflareSpeedTest/issues/40) 获取**手动教程**或 **Windows/Linux 自动更新脚本**
****
## 问题反馈

3
ip.txt
View File

@@ -8,7 +8,8 @@
190.93.240.0/20
198.41.128.0/17
162.159.0.0/16
104.16.0.0/12
104.16.0.0/13
104.24.0.0/14
172.64.0.0/17
172.64.128.0/18
172.64.192.0/19

32
main.go
View File

@@ -18,7 +18,7 @@ import (
var version, ipFile, outputFile, versionNew string
var disableDownload, ipv6Mode, allip bool
var tcpPort, printResultNum, downloadSecond int
var timeLimit, speedLimit float64
var timeLimit, timeLimitLow, speedLimit float64
func init() {
var printVersion bool
@@ -41,7 +41,9 @@ https://github.com/XIU2/CloudflareSpeedTest
-url https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png
下载测速地址;用来下载测速的 Cloudflare CDN 文件地址,如地址含有空格请加上引号;
-tl 200
平均延迟上限;只输出低于指定平均延迟的 IP单独使用也可搭配下载速度下限(默认 9999.00 ms)
平均延迟上限;只输出低于指定平均延迟的 IP与其他上限/下限搭配(默认 9999 ms)
-tll 40
平均延迟下限;只输出高于指定平均延迟的 IP可与其他上限/下限搭配,过滤被假蔷的 IP(默认 0 ms)
-sl 5
下载速度下限;只输出高于指定下载速度的 IP凑够指定数量 [-dn] 才会停止测速;(默认 0.00 MB/s)
-p 20
@@ -49,7 +51,7 @@ https://github.com/XIU2/CloudflareSpeedTest
-f ip.txt
IP段数据文件如路径含有空格请加上引号支持其他 CDN IP段(默认 ip.txt)
-o result.csv
输出结果文件;如路径含有空格请加上引号;值为空时不输出 [-o " "](默认 result.csv)
写入结果文件;如路径含有空格请加上引号;值为空时不写入文件 [-o ""](默认 result.csv)
-dd
禁用下载测速;禁用后测速结果会按延迟排序 (默认按下载速度排序)(默认 启用)
-ipv6
@@ -69,6 +71,7 @@ https://github.com/XIU2/CloudflareSpeedTest
flag.IntVar(&downloadSecond, "dt", 10, "下载测速时间")
flag.StringVar(&url, "url", "https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png", "下载测速地址")
flag.Float64Var(&timeLimit, "tl", 9999, "平均延迟上限")
flag.Float64Var(&timeLimitLow, "tll", 0, "平均延迟下限")
flag.Float64Var(&speedLimit, "sl", 0, "下载速度下限")
flag.IntVar(&printResultNum, "p", 20, "显示结果数量")
flag.BoolVar(&disableDownload, "dd", false, "禁用下载测速")
@@ -109,9 +112,12 @@ https://github.com/XIU2/CloudflareSpeedTest
if url == "" {
url = "https://cf.xiu2.xyz/Github/CloudflareSpeedTest.png"
}
if timeLimit <= 0 {
if timeLimit <= 0 || timeLimit > 9999 {
timeLimit = 9999
}
if timeLimitLow < 0 || timeLimitLow > 9999 {
timeLimitLow = 0
}
if speedLimit < 0 {
speedLimit = 0
}
@@ -142,9 +148,9 @@ func main() {
// 开始延迟测速
fmt.Println("# XIU2/CloudflareSpeedTest " + version + "\n")
if ipv6Mode { // IPv6 模式判断
fmt.Println("开始延迟测速模式TCP IPv6端口" + strconv.Itoa(tcpPort) + ",平均延迟上限:" + fmt.Sprintf("%.2f", timeLimit) + " ms")
fmt.Println("开始延迟测速模式TCP IPv6端口" + strconv.Itoa(tcpPort) + ",平均延迟上限:" + fmt.Sprintf("%.2f", timeLimit) + " ms" + ",平均延迟下限:" + fmt.Sprintf("%.2f", timeLimitLow) + " ms")
} else {
fmt.Println("开始延迟测速模式TCP IPv4端口" + strconv.Itoa(tcpPort) + ",平均延迟上限:" + fmt.Sprintf("%.2f", timeLimit) + " ms")
fmt.Println("开始延迟测速模式TCP IPv4端口" + strconv.Itoa(tcpPort) + ",平均延迟上限:" + fmt.Sprintf("%.2f", timeLimit) + " ms" + ",平均延迟下限:" + fmt.Sprintf("%.2f", timeLimitLow) + " ms")
}
control := make(chan bool, pingRoutine)
for _, ip := range ips {
@@ -158,11 +164,15 @@ func main() {
sort.Sort(CloudflareIPDataSet(data)) // 排序(按延迟,从低到高,不同丢包率会分开单独按延迟和丢包率排序)
// 延迟测速完毕后,以 [平均延迟上限] 条件过滤结果
if timeLimit < 9999 && timeLimit > 0 {
// 延迟测速完毕后,以 [平均延迟上限] + [平均延迟下限] 条件过滤结果
if timeLimit != 9999 || timeLimitLow != 0 {
for i := 0; i < len(data); i++ {
if float64(data[i].pingTime) <= timeLimit {
data2 = append(data2, data[i]) // 延迟满足条件时,添加到新数组中
if float64(data[i].pingTime) <= timeLimit { // 平均延迟上限
if float64(data[i].pingTime) > timeLimitLow { // 平均延迟下限
data2 = append(data2, data[i]) // 延迟满足条件时,添加到新数组中
} else {
continue
}
} else {
break
}
@@ -235,7 +245,7 @@ func printResult(data []CloudflareIPData) {
}
if versionNew != "" {
fmt.Println("\n发现新版本 [" + versionNew + "]!请前往 [https://github.com/XIU2/CloudflareSpeedTest] 更新!")
fmt.Println("\n*** 发现新版本 [" + versionNew + "]!请前往 [https://github.com/XIU2/CloudflareSpeedTest] 更新! ***")
}
if sysType == "windows" { // 如果是 Windows 系统,则需要按下 回车键 或 Ctrl+C 退出(避免通过双击运行时,测速完毕后直接关闭)