Add count and change timeout

This commit is contained in:
kayos@tcp.direct 2022-11-22 21:30:00 -08:00
parent f174f8b1b1
commit a10b811217
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
2 changed files with 5 additions and 2 deletions

4
sox.go
View File

@ -10,7 +10,7 @@ import (
)
func persistentResolver(hostname string) []netip.Addr {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
var ips []netip.Addr
if hostname == "" {
@ -87,7 +87,7 @@ func (c *Checker) GetAndVerifySOCKS() (chan netip.AddrPort, chan error) {
go func(prx netip.AddrPort) {
defer wg.Done()
var conn net.Conn
conn, err = net.DialTimeout("tcp", prx.String(), 5*time.Second)
conn, err = net.DialTimeout("tcp", prx.String(), 10*time.Second)
if err != nil {
errs <- err
}

View File

@ -26,6 +26,7 @@ func TestChecker_GetSOCKS(t *testing.T) {
t.Fatalf("%s", err.Error())
}
gotSox, errs := c.GetAndVerifySOCKS()
count := 0
for sox := range gotSox {
select {
case err := <-errs:
@ -34,7 +35,9 @@ func TestChecker_GetSOCKS(t *testing.T) {
}
default:
t.Logf("got verified: %s", sox.String())
count++
}
}
t.Logf("got %d active mullvad SOCKS5 servers", count)
})
}