From 8f510c21feb2860c8a5367ffba0eea565929da74 Mon Sep 17 00:00:00 2001 From: zu1k Date: Wed, 12 Aug 2020 19:57:57 +0800 Subject: [PATCH] fix send on close channel --- app/task.go | 1 + getter/subscribe.go | 3 +-- getter/tgchannel.go | 3 +-- getter/web_fanqiangdang.go | 3 +-- getter/web_free_ssr_xyz.go | 3 +-- getter/web_fuzz.go | 3 +-- getter/web_lucn_org.go | 3 +-- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/task.go b/app/task.go index ffaa4d9..ae6a617 100644 --- a/app/task.go +++ b/app/task.go @@ -34,6 +34,7 @@ func CrawlGo() { wg := &sync.WaitGroup{} var pc = make(chan proxy.Proxy) for _, g := range Getters { + wg.Add(1) go g.Get2Chan(pc, wg) } proxies := cache.GetProxies() diff --git a/getter/subscribe.go b/getter/subscribe.go index 3e0ed93..a57f442 100644 --- a/getter/subscribe.go +++ b/getter/subscribe.go @@ -40,12 +40,11 @@ func (s *Subscribe) Get() []proxy.Proxy { } func (s *Subscribe) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := s.Get() for _, node := range nodes { pc <- node } - wg.Done() } func NewSubscribe(options tool.Options) Getter { diff --git a/getter/tgchannel.go b/getter/tgchannel.go index 60c290f..545e5a3 100644 --- a/getter/tgchannel.go +++ b/getter/tgchannel.go @@ -61,10 +61,9 @@ func (g *TGChannelGetter) Get() []proxy.Proxy { } func (g *TGChannelGetter) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := g.Get() for _, node := range nodes { pc <- node } - wg.Done() } diff --git a/getter/web_fanqiangdang.go b/getter/web_fanqiangdang.go index c0c0c5b..c774ad4 100644 --- a/getter/web_fanqiangdang.go +++ b/getter/web_fanqiangdang.go @@ -61,10 +61,9 @@ func (w *WebFanqiangdang) Get() []proxy.Proxy { } func (w *WebFanqiangdang) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := w.Get() for _, node := range nodes { pc <- node } - wg.Done() } diff --git a/getter/web_free_ssr_xyz.go b/getter/web_free_ssr_xyz.go index 567d6fe..5efdee6 100644 --- a/getter/web_free_ssr_xyz.go +++ b/getter/web_free_ssr_xyz.go @@ -34,12 +34,11 @@ func (w *WebFreessrXyz) Get() []proxy.Proxy { } func (w *WebFreessrXyz) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := w.Get() for _, node := range nodes { pc <- node } - wg.Done() } func freessrxyzFetch(link string) []proxy.Proxy { diff --git a/getter/web_fuzz.go b/getter/web_fuzz.go index fe49ee7..2129417 100644 --- a/getter/web_fuzz.go +++ b/getter/web_fuzz.go @@ -32,12 +32,11 @@ func (w *WebFuzz) Get() []proxy.Proxy { } func (w *WebFuzz) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := w.Get() for _, node := range nodes { pc <- node } - wg.Done() } func NewWebFuzzGetter(options tool.Options) Getter { diff --git a/getter/web_lucn_org.go b/getter/web_lucn_org.go index 930e77a..04e2167 100644 --- a/getter/web_lucn_org.go +++ b/getter/web_lucn_org.go @@ -67,12 +67,11 @@ func (w *WebLucnOrg) Get() []proxy.Proxy { } func (w *WebLucnOrg) Get2Chan(pc chan proxy.Proxy, wg *sync.WaitGroup) { - wg.Add(1) + defer wg.Done() nodes := w.Get() for _, node := range nodes { pc <- node } - wg.Done() } func decryptAesForLucn(code string, c string) []byte {