diff --git a/defs.go b/defs.go index 8b334a2..d226c05 100644 --- a/defs.go +++ b/defs.go @@ -32,7 +32,7 @@ type Swamp struct { } var ( - defaultStaleTime = time.Duration(1) * time.Hour + defaultStaleTime = 1 * time.Hour defWorkers = 100 defaultChecks = []string{"https://wtfismyip.com/text", "https://myexternalip.com/raw", "https://ipinfo.io/ip"} ) diff --git a/example/main.go b/example/main.go index 57affd6..ec3c091 100644 --- a/example/main.go +++ b/example/main.go @@ -25,6 +25,23 @@ func init() { println(err.Error()) os.Exit(1) } + + println("[USAGE] q: quit | d: debug | a: socks4 | b: socks4a | c: socks5") +} + +func get(ver string) { + switch ver { + case "4": + println("retrieving SOCKS4...") + println(swamp.Socks4Str()) + case "4a": + println("retrieving SOCKS4a...") + println(swamp.Socks4aStr()) + case "5": + println("retrieving SOCKS5...") + println(swamp.Socks5Str()) + + } } func main() { @@ -49,6 +66,12 @@ func main() { println("enabling debug") swamp.EnableDebug() } + case "a": + go get("4") + case "b": + go get("4a") + case "c": + go get("5") case "q": quit <- true default: diff --git a/getters.go b/getters.go index 4f251a2..eef0091 100644 --- a/getters.go +++ b/getters.go @@ -1,6 +1,9 @@ package pxndscvm -import "time" +import ( + "fmt" + "time" +) // Socks5Str gets a SOCKS5 proxy that we have fully verified (dialed and then retrieved our IP address from a what-is-my-ip endpoint. func (s *Swamp) Socks5Str() string { @@ -68,18 +71,12 @@ func (s *Swamp) GetAnySOCKS() Proxy { } func (s *Swamp) stillGood(candidate Proxy) bool { - switch { - // if since its been validated it's ended up failing so much that its on our bad list then skip it - case badProx.Peek(candidate): - fallthrough - // if we've been checking or using this too often recently then skip it - case useProx.Check(candidate): - fallthrough - case time.Since(candidate.Verified) > s.swampopt.Stale: + if time.Since(candidate.Verified) > s.swampopt.Stale { + s.dbgPrint("proxy stale: " + candidate.Endpoint) + fmt.Println("time since: ", time.Since(candidate.Verified)) return false - default: - return true } + return true } // RandomUserAgent retrieves a random user agent from our list in string form diff --git a/main.go b/main.go index 9b442e2..3c09bd3 100644 --- a/main.go +++ b/main.go @@ -222,6 +222,8 @@ func (s *Swamp) tossUp() { continue } + p.Verified = time.Now() + switch p.Proto { case "4": s.Stats.v4()