Skip to content

Commit ea46fc5

Browse files
committed
修复 IP 解析不够随机的问题
1 parent 9471094 commit ea46fc5

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ https://github.com/XIU2/CloudflareSpeedTest
101101
}
102102

103103
func main() {
104-
go checkUpdate() // 检查版本更新
104+
go checkUpdate() // 检查版本更新
105+
task.InitRandSeed() // 置随机数种子
105106

106107
fmt.Printf("# XIU2/CloudflareSpeedTest %s \n\n", version)
107108

@@ -123,7 +124,7 @@ func endPrint() {
123124
return
124125
}
125126
if runtime.GOOS == "windows" { // 如果是 Windows 系统,则需要按下 回车键 或 Ctrl+C 退出(避免通过双击运行时,测速完毕后直接关闭)
126-
fmt.Printf("\n按下 回车键 或 Ctrl+C 退出。")
127+
fmt.Printf("按下 回车键 或 Ctrl+C 退出。")
127128
var pause int
128129
fmt.Scanln(&pause)
129130
}

task/ip.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ var (
2222
IPFile = defaultInputFile
2323
)
2424

25-
func randIPEndWith(num byte) byte {
25+
func InitRandSeed() {
2626
rand.Seed(time.Now().UnixNano())
27+
}
28+
29+
func randIPEndWith(num byte) byte {
2730
return byte(rand.Intn(int(num)))
2831
}
2932

utils/csv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,6 @@ func (s DownloadSpeedSet) Print(ipv6 bool) {
161161
fmt.Printf(dataFormat, dateString[i][0], dateString[i][1], dateString[i][2], dateString[i][3], dateString[i][4], dateString[i][5])
162162
}
163163
if !noOutput() {
164-
fmt.Printf("\n完整测速结果已写入 %v 文件,可使用记事本/表格软件查看。", Output)
164+
fmt.Printf("\n完整测速结果已写入 %v 文件,可使用记事本/表格软件查看。\n", Output)
165165
}
166166
}

0 commit comments

Comments
 (0)