add validation to items added by user + more debug
This commit is contained in:
parent
929c1a4c0e
commit
2a2fdc9711
@ -2,6 +2,7 @@ package pxndscvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ func (s *Swamp) MysteryDialer(ctx context.Context, network, addr string) (net.Co
|
|||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
candidate := s.GetAnySOCKS()
|
candidate := s.GetAnySOCKS()
|
||||||
if !s.stillGood(candidate) {
|
if !s.stillGood(candidate) {
|
||||||
|
s.dbgPrint("MysteryDialer cycle proxies, old: " + candidate.Endpoint)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +37,8 @@ func (s *Swamp) MysteryDialer(ctx context.Context, network, addr string) (net.Co
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var dialSocks = socks.Dial("socks" + sock.Proto + "://" + sock.Endpoint + "?timeout=10s")
|
socksString := fmt.Sprintf("socks%s://%s?timeout=15s", sock.Proto, sock.Endpoint)
|
||||||
|
s.dbgPrint("MysteryDialer using socks: " + socksString)
|
||||||
|
var dialSocks = socks.Dial(socksString)
|
||||||
return dialSocks(network, addr)
|
return dialSocks(network, addr)
|
||||||
}
|
}
|
||||||
|
@ -73,17 +73,15 @@ func (s *Swamp) GetAnySOCKS() Proxy {
|
|||||||
}
|
}
|
||||||
s.Stats.dispense()
|
s.Stats.dispense()
|
||||||
return sock
|
return sock
|
||||||
|
default:
|
||||||
|
time.Sleep(25 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Swamp) stillGood(candidate Proxy) bool {
|
func (s *Swamp) stillGood(candidate Proxy) bool {
|
||||||
if useProx.Check(candidate) {
|
|
||||||
s.dbgPrint(ylw+"useprox ratelimited: " + candidate.Endpoint)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if badProx.Peek(candidate) {
|
if badProx.Peek(candidate) {
|
||||||
s.dbgPrint(ylw+"badprox ratelimited: " + candidate.Endpoint)
|
s.dbgPrint(ylw + "badprox ratelimited: " + candidate.Endpoint + rst)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if time.Since(candidate.Verified) > s.swampopt.Stale {
|
if time.Since(candidate.Verified) > s.swampopt.Stale {
|
||||||
@ -91,7 +89,6 @@ func (s *Swamp) stillGood(candidate Proxy) bool {
|
|||||||
go s.Stats.stale()
|
go s.Stats.stale()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
go.mod
3
go.mod
@ -9,10 +9,13 @@ require (
|
|||||||
github.com/yunginnanet/Rate5 v0.0.0-20210907213727-36294aeeac1c
|
github.com/yunginnanet/Rate5 v0.0.0-20210907213727-36294aeeac1c
|
||||||
golang.org/x/net v0.0.0-20210908191846-a5e095526f91
|
golang.org/x/net v0.0.0-20210908191846-a5e095526f91
|
||||||
h12.io/socks v1.0.3
|
h12.io/socks v1.0.3
|
||||||
|
inet.af/netaddr v0.0.0-20210903134321-85fa6c94624e
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/mattn/go-isatty v0.0.10 // indirect
|
github.com/mattn/go-isatty v0.0.10 // indirect
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||||
|
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
|
||||||
|
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
|
||||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,10 @@ package pxndscvm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
|
ipa "inet.af/netaddr"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,19 +35,36 @@ func (s *Swamp) LoadProxyTXT(seedFile string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoadSingleProxy loads a SOCKS proxy into our queue as the format: 127.0.0.1:1080 (host:port)
|
// LoadSingleProxy loads a SOCKS proxy into our queue as the format: 127.0.0.1:1080 (host:port)
|
||||||
func (s *Swamp) LoadSingleProxy(sock string) {
|
func (s *Swamp) LoadSingleProxy(sock string) error {
|
||||||
|
if !strings.Contains(sock, ":") {
|
||||||
|
return errors.New("missing colon/missing port")
|
||||||
|
}
|
||||||
|
split := strings.Split(sock, ":")
|
||||||
|
if _, err := ipa.ParseIP(split[0]); err != nil {
|
||||||
|
return errors.New(split[0] + "is not an IP address")
|
||||||
|
}
|
||||||
|
if _, err := strconv.Atoi(split[1]); err != nil {
|
||||||
|
return errors.New(split[1] + "is not a number")
|
||||||
|
}
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.scvm = append(s.scvm, sock)
|
s.scvm = append(s.scvm, sock)
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadMultiLineString loads a multiine string object with one (host:port) SOCKS proxy per line
|
// LoadMultiLineString loads a multiine string object with one (host:port) SOCKS proxy per line
|
||||||
func (s *Swamp) LoadMultiLineString(socks string) error {
|
func (s *Swamp) LoadMultiLineString(socks string) (int, error) {
|
||||||
|
var count int
|
||||||
scan := bufio.NewScanner(strings.NewReader(socks))
|
scan := bufio.NewScanner(strings.NewReader(socks))
|
||||||
for scan.Scan() {
|
for scan.Scan() {
|
||||||
s.LoadSingleProxy(scan.Text())
|
if err := s.LoadSingleProxy(scan.Text()); err == nil {
|
||||||
|
count++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
if count < 1 {
|
||||||
|
return 0, errors.New("no valid host:ip entries found in string")
|
||||||
|
}
|
||||||
|
return count, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearSOCKSList clears the slice of proxies that we continually draw from at random for validation
|
// ClearSOCKSList clears the slice of proxies that we continually draw from at random for validation
|
||||||
|
@ -123,7 +123,7 @@ func (s *Swamp) validate() {
|
|||||||
|
|
||||||
// ratelimited
|
// ratelimited
|
||||||
if useProx.Check(p) {
|
if useProx.Check(p) {
|
||||||
s.dbgPrint(ylw+"useProx ratelimited: " + p.Endpoint+rst)
|
s.dbgPrint(ylw + "useProx ratelimited: " + p.Endpoint + rst)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user