新增 HTTPing 延迟测速模式(beta); 新增 IP 机场三字码 colo 筛选功能(beta) (#282)

这两个功能目前仅为测试版,后续会大幅改动,以最终成品为准~
This commit is contained in:
kaka
2023-01-31 12:48:28 +08:00
committed by GitHub
parent 562789aa15
commit f4f1fdcd80
7 changed files with 213 additions and 19 deletions

View File

@@ -6,7 +6,10 @@ import (
"log"
"net"
"os"
"sort"
"strconv"
"strings"
"sync"
"time"
)
@@ -21,6 +24,7 @@ var (
InputMinDelay = minDelay
Output = defaultOutput
PrintNum = 10
ColoAble sync.Map
)
// 是否打印测试结果
@@ -139,6 +143,16 @@ func (s DownloadSpeedSet) Swap(i, j int) {
}
func (s DownloadSpeedSet) Print() {
var colos []string
ColoAble.Range(func(key, value interface{}) bool {
colos = append(colos, key.(string))
return true
})
if len(colos) != 0 {
sort.Strings(colos)
colostrings := strings.Join(colos, ",")
fmt.Println("\n下次可以考虑机场三字码参数" + colostrings + "\n")
}
if NoPrintResult() {
return
}

View File

@@ -1,19 +1,25 @@
package utils
import "github.com/cheggaaa/pb/v3"
import (
"fmt"
"github.com/cheggaaa/pb/v3"
)
type Bar struct {
pb *pb.ProgressBar
}
func NewBar(count int) *Bar {
return &Bar{pb.Simple.Start(count)}
func NewBar(count int, MyStrStart, MyStrEnd string) *Bar {
tmpl := fmt.Sprintf(`{{counters . }}{{ bar . "[" "-" (cycle . "↖" "↗" "↘" "↙" ) "_" "]"}} %s {{string . "MyStr" | green}} %s `, MyStrStart, MyStrEnd)
bar := pb.ProgressBarTemplate(tmpl).Start(count)
return &Bar{pb: bar}
}
func (b *Bar) Grow(num int) {
b.pb.Add(num)
func (b *Bar) Grow(num int, MyStrVal string) {
b.pb.Set("MyStr", MyStrVal).Add(num)
}
func (b *Bar) Done() {
b.pb.Finish()
}
}