mirror of
https://github.com/XIU2/CloudflareSpeedTest.git
synced 2026-03-06 14:45:56 +08:00
rebuild tcping
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package utils
|
||||
|
||||
import "github.com/cheggaaa/pb/v3"
|
||||
|
||||
type ProgressEvent int
|
||||
|
||||
const (
|
||||
@@ -7,3 +9,24 @@ const (
|
||||
AvailableIPFound
|
||||
NormalPing
|
||||
)
|
||||
|
||||
type Bar struct {
|
||||
*pb.ProgressBar
|
||||
}
|
||||
|
||||
func NewBar(count int) *Bar {
|
||||
return &Bar{pb.Simple.Start(count)}
|
||||
}
|
||||
|
||||
func handleProgressGenerator(pb *pb.ProgressBar) func(e ProgressEvent) {
|
||||
return func(e ProgressEvent) {
|
||||
switch e {
|
||||
case NoAvailableIPFound:
|
||||
// pb.Add(pingTime)
|
||||
case AvailableIPFound:
|
||||
// pb.Add(failTime)
|
||||
case NormalPing:
|
||||
pb.Increment()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user