Compare commits

...

5 Commits

Author SHA1 Message Date
scientificworld c9fa405afa
Merge 8e984033dd into 176271d5bb 2024-01-20 02:01:05 -08:00
xiu2 176271d5bb README.md 2024-01-20 10:26:48 +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 21 additions and 4 deletions

View File

@ -24,7 +24,7 @@
### 下载运行
1. 下载编译好的可执行文件( [Github Releases](https://github.com/XIU2/CloudflareSpeedTest/releases) / [蓝奏云](https://pan.lanzouj.com/b0742hkxe) )并解压。
1. 下载编译好的可执行文件( [Github Releases](https://github.com/XIU2/CloudflareSpeedTest/releases) / [蓝奏云](https://pan.lanpw.com/b0742hkxe) )并解压。
2. 双击运行 `CloudflareST.exe` 文件Windows 系统),等待测速完成...
<details>

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 {