rebuild tcping

This commit is contained in:
mz
2021-11-09 23:39:42 +08:00
parent 83c63e975e
commit 71671ebe66
7 changed files with 173 additions and 32 deletions

View File

@@ -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()
}
}
}