Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
fix log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksherron committed Feb 3, 2020
1 parent d381990 commit dfcd39f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
19 changes: 13 additions & 6 deletions internal/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
resolveCount int
)

func resolveJudges() {
func resolveJudges() {

suffix := "/get?show_env"
sites := []string{
Expand All @@ -82,12 +82,20 @@ func resolveJudges() {
timer map[string]time.Duration
}{counter: make(map[string]int), timer: make(map[string]time.Duration)}

var limit int

if Workers < 100 {
limit = Workers
} else {
limit = 100
}

// make n requests with each url and choose whichever one gets done the fastest
for _, site := range sites {
u := site + suffix
var w sync.WaitGroup
start := time.Now()
for i := 0; i < Workers; i++ {
for i := 0; i < limit; i++ {
w.Add(1)
go func() {
defer w.Done()
Expand Down Expand Up @@ -124,7 +132,7 @@ func resolveJudges() {
}
var records []rec
for k, v := range sources.timer {
if float64(sources.counter[k]/Workers) > .80 {
if float64(sources.counter[k]/limit) > .80 {
records = append(records, rec{k, int(v)})
}
}
Expand Down Expand Up @@ -289,6 +297,7 @@ func proxyCheck(proxy *Proxy) {

// CheckInit checks all proxies from GormDB to see if they are transparent or anonymous and if they work.
func CheckInit() {
log.Println("Starting proxy checks...")
busy = true
resolveJudges()
if os.Getenv("PROXI_DEBUG_JUDGES") == "1" {
Expand All @@ -304,16 +313,14 @@ func CheckInit() {
} else {
limit = int64(Workers)
}

log.Print("\nStarting proxy checks...\n\n")
log.SetOutput(nil)
atomic.StoreInt64(&testCount, 0)
realIP = hostIP()
counter = 0

wgLoop.Add(1)
if Progress {
bar = pb.ProgressBarTemplate(barTemplate).Start(len(proxies)).SetMaxWidth(80)
bar = pb.ProgressBarTemplate(barTemplate).Start(len(proxies)).SetMaxWidth(60)
bar.Set("message", "Testing proxies\t")
}
go func() {
Expand Down
2 changes: 1 addition & 1 deletion internal/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func getKuaidaili(u string) (string, error) {

// DownloadProxies downloads proxies from providers.
func DownloadProxies() Proxies {
log.Println(" Starting proxy downloads...")
log.Println("Starting proxy downloads...")
wgD.Add(17)
var providerProxies Proxies

Expand Down
2 changes: 0 additions & 2 deletions internal/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ func proxylistDownloadP(ctx context.Context) Proxies {
}
}


func usProxyP(ctx context.Context) Proxies {
defer ctx.Done()
start := time.Now()
Expand Down Expand Up @@ -789,7 +788,6 @@ func usProxyP(ctx context.Context) Proxies {
}
}


func blogspotP(ctx context.Context) Proxies {
defer ctx.Done()
start := time.Now()
Expand Down

0 comments on commit dfcd39f

Please sign in to comment.