Hi, i have memory leaks cause http Transport dies too slowly. I'v creating
Transports for checking proxy every 2 minute, so new Transports creates
faster that old dies.
Here i'm checking
func checkProxySOCKS(prox string, c chan QR, wg *sync.WaitGroup) (err error)
{
defer wg.Done()
dialer, err := proxy.SOCKS5("tcp", prox, nil, proxy.Direct)
if err != nil {
return
}
timeout := time.Duration(1 * time.Second)
httpClient := &http.Client{
Timeout: timeout,
Transport: &http.Transport{
DisableKeepAlives: true,
Dial: dialer.Dial,
},
}
res, err := httpClient.Get("https://telegram.org/")
if err != nil {
c <- QR{Addr: prox, Res: false}
return
}
defer res.Body.Close()
io.Copy(ioutil.Discard, res.Body)
c <- QR{Addr: prox, Res: true}
return nil
}
Here i'm create it
for _, proxy := range splitedProxies {
wg.Add(1)
go checkProxySOCKS(proxy, respChan, &wg)
}
for range splitedProxies {
wg.Add(1)
r := <-respChan
if r.Res {
checkedProxiesArray = append(checkedProxiesArray, r.Addr)
}
wg.Done()
}
wg.Wait()
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.