Add files via upload

This commit is contained in:
XIU2 2020-08-31 11:31:31 +08:00 committed by GitHub
parent 31dbf635a8
commit df0b12f018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

20
main.go
View File

@ -17,31 +17,31 @@ func init() {
var downloadSecond int64
var printVersion bool
const help = `CloudflareSpeedTest
测试 Cloudflare CDN 所有 IP 的延迟和速度获取最佳 IP
https://github.com/XIU2/CloudflareSpeedTest
测试 Cloudflare CDN 所有 IP 的延迟和速度获取最佳 IP
https://github.com/XIU2/CloudflareSpeedTest
参数
-n 500
测速线程数量请勿超过1000 (default 500)
测速线程数量请勿超过1000 (默认 500)
-t 4
延迟测速次数单个 IP (default 4)
-dn 10
下载测速数量延迟测速后从最低延迟起测试下载速度的数量请勿太多 (default 10)
延迟测速次数单个 IP (默认 4)
-dn 20
下载测速数量延迟测速后从最低延迟起测试下载速度的数量请勿太多 (默认 20)
-dt 10
下载测试时间单个 IP 测速最长时间单位 (default 10)
下载测试时间单个 IP 测速最长时间单位 (默认 10)
-v
打印程序版本
-h
打印帮助说明
示例
WindowsCloudflareST.exe -n 800 -t 4 -dn 10 -dt 10
LinuxCloudflareST -n 800 -t 4 -dn 10 -dt 10
WindowsCloudflareST.exe -n 800 -t 4 -dn 20 -dt 10
LinuxCloudflareST -n 800 -t 4 -dn 20 -dt 10
`
pingRoutine = *flag.Int("n", 500, "测速线程数量请勿超过1000")
pingTime = *flag.Int("t", 4, "延迟测速次数;单个 IP")
downloadTestCount = *flag.Int("dn", 10, "下载测速数量;延迟测速后,从最低延迟起测试下载速度的数量,请勿太多")
downloadTestCount = *flag.Int("dn", 20, "下载测速数量;延迟测速后,从最低延迟起测试下载速度的数量,请勿太多")
flag.Int64Var(&downloadSecond, "dt", 10, "下载测速时间;单个 IP 测速最长时间,单位:秒")
flag.BoolVar(&printVersion, "v", false, "打印程序版本")

View File

@ -2,13 +2,14 @@ package main
import (
"encoding/csv"
"github.com/cheggaaa/pb/v3"
"log"
"math/rand"
"net"
"os"
"strconv"
"time"
"github.com/cheggaaa/pb/v3"
)
type CloudflareIPData struct {
@ -35,7 +36,7 @@ func ExportCsv(filePath string, data []CloudflareIPData) {
}
defer fp.Close()
w := csv.NewWriter(fp) //创建一个新的写入文件流
w.Write([]string{"IP Address", "Ping count", "Ping received", "Ping received rate", "Ping time", "Download Speed (MB/s)"})
w.Write([]string{"IP 地址", "Ping 发送次数", "Ping 接收次数", "Ping 接收率", "平均延迟", "下载速度 (MB/s)"})
w.WriteAll(convertToString(data))
w.Flush()
}
@ -89,7 +90,7 @@ const failTime = 4
type CloudflareIPDataSet []CloudflareIPData
func initipEndWith() {
rand.Seed(time.Now().UnixNano())
rand.Seed(time.Now().UnixNano())
ipEndWith = uint8(rand.Intn(254) + 1)
}