Compare commits

...

5 Commits

Author SHA1 Message Date
scientificworld 9b0f5a223f
Merge 8e984033dd into d96281af1f 2024-02-13 10:37:35 -08:00
xiu2 d96281af1f README.md 2024-02-13 22:47:06 +08:00
scientificworld 8e984033dd
feat: improve compatibility 2023-07-01 22:12:48 +08:00
scientificworld a74d121d88
fix: remove debug log 2023-07-01 17:53:06 +08:00
scientificworld ccfd1edb8c
feat!: find default IP segment file at the location of the executable 2023-06-30 19:37:28 +08:00
3 changed files with 20 additions and 4 deletions

View File

@ -44,7 +44,6 @@ cd CloudflareST
# 下载 CloudflareST 压缩包(自行根据需求替换 URL 中 [版本号] 和 [文件名]
wget -N https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.5/CloudflareST_linux_amd64.tar.gz
# 如果你是在国内网络环境中下载,那么请使用下面这几个镜像加速之一:
# wget -N https://download.nuaa.cf/XIU2/CloudflareSpeedTest/releases/download/v2.2.5/CloudflareST_linux_amd64.tar.gz
# wget -N https://download.scholar.rr.nu/XIU2/CloudflareSpeedTest/releases/download/v2.2.5/CloudflareST_linux_amd64.tar.gz
# wget -N https://ghproxy.cc/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.5/CloudflareST_linux_amd64.tar.gz
# wget -N https://ghproxy.net/https://github.com/XIU2/CloudflareSpeedTest/releases/download/v2.2.5/CloudflareST_linux_amd64.tar.gz

View File

@ -92,7 +92,7 @@ https://github.com/XIU2/CloudflareSpeedTest
flag.Float64Var(&task.MinSpeed, "sl", 0, "下载速度下限")
flag.IntVar(&utils.PrintNum, "p", 10, "显示结果数量")
flag.StringVar(&task.IPFile, "f", "ip.txt", "IP段数据文件")
flag.StringVar(&task.IPFile, "f", "", "IP段数据文件")
flag.StringVar(&task.IPText, "ip", "", "指定IP段数据")
flag.StringVar(&utils.Output, "o", "result.csv", "输出结果文件")

View File

@ -9,15 +9,28 @@ import (
"strconv"
"strings"
"time"
"path/filepath"
)
const defaultInputFile = "ip.txt"
func getDefaultInputFile() string {
exe, err := os.Executable()
if err != nil {
log.Fatal(err)
}
sym, err := filepath.EvalSymlinks(exe)
if err != nil {
log.Fatal(err)
}
return filepath.Join(filepath.Dir(sym), defaultInputFile)
}
var (
// TestAll test all ip
TestAll = false
// IPFile is the filename of IP Rangs
IPFile = defaultInputFile
IPFile = getDefaultInputFile()
IPText string
)
@ -165,7 +178,11 @@ func loadIPRanges() []*net.IPAddr {
}
} else { // 从文件中获取 IP 段数据
if IPFile == "" {
IPFile = defaultInputFile
if _, err := os.Stat(defaultInputFile); err != nil {
IPFile = getDefaultInputFile()
} else {
IPFile = defaultInputFile
}
}
file, err := os.Open(IPFile)
if err != nil {