修复 IP 解析不够随机的问题

This commit is contained in:
xiu2 2021-11-17 15:40:53 +08:00
parent 9471094d27
commit ea46fc5e04
3 changed files with 8 additions and 4 deletions

View File

@ -101,7 +101,8 @@ https://github.com/XIU2/CloudflareSpeedTest
}
func main() {
go checkUpdate() // 检查版本更新
go checkUpdate() // 检查版本更新
task.InitRandSeed() // 置随机数种子
fmt.Printf("# XIU2/CloudflareSpeedTest %s \n\n", version)
@ -123,7 +124,7 @@ func endPrint() {
return
}
if runtime.GOOS == "windows" { // 如果是 Windows 系统,则需要按下 回车键 或 Ctrl+C 退出(避免通过双击运行时,测速完毕后直接关闭)
fmt.Printf("\n按下 回车键 或 Ctrl+C 退出。")
fmt.Printf("按下 回车键 或 Ctrl+C 退出。")
var pause int
fmt.Scanln(&pause)
}

View File

@ -22,8 +22,11 @@ var (
IPFile = defaultInputFile
)
func randIPEndWith(num byte) byte {
func InitRandSeed() {
rand.Seed(time.Now().UnixNano())
}
func randIPEndWith(num byte) byte {
return byte(rand.Intn(int(num)))
}

View File

@ -161,6 +161,6 @@ func (s DownloadSpeedSet) Print(ipv6 bool) {
fmt.Printf(dataFormat, dateString[i][0], dateString[i][1], dateString[i][2], dateString[i][3], dateString[i][4], dateString[i][5])
}
if !noOutput() {
fmt.Printf("\n完整测速结果已写入 %v 文件,可使用记事本/表格软件查看。", Output)
fmt.Printf("\n完整测速结果已写入 %v 文件,可使用记事本/表格软件查看。\n", Output)
}
}