Docs: small updates

This commit is contained in:
kayos@tcp.direct 2021-09-21 05:24:30 -07:00
parent 9e7b970a3b
commit 81df33fd6e
8 changed files with 33 additions and 31 deletions

View File

@ -2,7 +2,7 @@ package pxndscvm
import "errors"
// Start starts our proxy pool operations. Trying to start a running Swamp is a nonop.
// Start starts our proxy pool operations. Trying to start a running Swamp will return an error.
func (s *Swamp) Start() error {
if s.started {
return errors.New("already running")

View File

@ -104,7 +104,7 @@ func (s *Swamp) jobSpawner() {
go s.pool.Submit(sock.validate)
time.Sleep(time.Duration(10) * time.Millisecond)
default:
time.Sleep(100*time.Millisecond)
time.Sleep(100 * time.Millisecond)
}
}
}

View File

@ -23,7 +23,7 @@ func (s *Swamp) DebugChannel() chan string {
return debugChan
}
// DebugEnabled returns the current state of our debug switch
// DebugEnabled returns the current state of our debug switch.
func (s *Swamp) DebugEnabled() bool {
return s.swampopt.debug
}

24
defs.go
View File

@ -21,12 +21,12 @@ const (
// Swamp represents a proxy pool
type Swamp struct {
// Socks5 is a constant stream of verified Socks5 proxies
Socks5 chan *Proxy
// Socks4 is a constant stream of verified Socks4 proxies
Socks4 chan *Proxy
// Socks4a is a constant stream of verified Socks5 proxies
Socks4a chan *Proxy
// ValidSocks5 is a constant stream of verified ValidSocks5 proxies
ValidSocks5 chan *Proxy
// ValidSocks4 is a constant stream of verified ValidSocks4 proxies
ValidSocks4 chan *Proxy
// ValidSocks4a is a constant stream of verified ValidSocks5 proxies
ValidSocks4a chan *Proxy
// Stats holds the Statistics for our swamp
Stats *Statistics
@ -149,18 +149,20 @@ type Proxy struct {
lock uint32
}
// UniqueKey is an implementation of the Identity interface from Rate5
// UniqueKey is an implementation of the Identity interface from Rate5.
// See: https://pkg.go.dev/github.com/yunginnanet/Rate5#Identity
func (sock Proxy) UniqueKey() string {
return sock.Endpoint
}
// NewDefaultSwamp returns a Swamp with basic options.
// After calling this you can use the various "setters" to change the options before calling Swamp.Start().
func NewDefaultSwamp() *Swamp {
s := &Swamp{
Socks5: make(chan *Proxy, 100000),
Socks4: make(chan *Proxy, 100000),
Socks4a: make(chan *Proxy, 100000),
Pending: make(chan *Proxy, 100000),
ValidSocks5: make(chan *Proxy, 100000),
ValidSocks4: make(chan *Proxy, 100000),
ValidSocks4a: make(chan *Proxy, 100000),
Pending: make(chan *Proxy, 100000),
Stats: &Statistics{
Valid4: 0,

View File

@ -12,7 +12,7 @@ import (
func (s *Swamp) Socks5Str() string {
for {
select {
case sock := <-s.Socks5:
case sock := <-s.ValidSocks5:
if !s.stillGood(sock) {
continue
}
@ -27,7 +27,7 @@ func (s *Swamp) Socks5Str() string {
func (s *Swamp) Socks4Str() string {
for {
select {
case sock := <-s.Socks4:
case sock := <-s.ValidSocks4:
if !s.stillGood(sock) {
continue
}
@ -42,7 +42,7 @@ func (s *Swamp) Socks4Str() string {
func (s *Swamp) Socks4aStr() string {
for {
select {
case sock := <-s.Socks4a:
case sock := <-s.ValidSocks4a:
if !s.stillGood(sock) {
continue
}
@ -71,7 +71,7 @@ func (sock *Proxy) copy() (Proxy, error) {
func (s *Swamp) GetAnySOCKS() Proxy {
for {
select {
case sock := <-s.Socks4:
case sock := <-s.ValidSocks4:
if !s.stillGood(sock) {
continue
}
@ -80,7 +80,7 @@ func (s *Swamp) GetAnySOCKS() Proxy {
return sox
}
continue
case sock := <-s.Socks4a:
case sock := <-s.ValidSocks4a:
if !s.stillGood(sock) {
continue
}
@ -89,7 +89,7 @@ func (s *Swamp) GetAnySOCKS() Proxy {
return sox
}
continue
case sock := <-s.Socks5:
case sock := <-s.ValidSocks5:
if !s.stillGood(sock) {
continue
}

View File

@ -9,8 +9,8 @@ import (
ipa "inet.af/netaddr"
)
// throw shit proxies here, get map
// see daemons.go
var inChan chan string
func init() {
@ -31,10 +31,10 @@ func (s *Swamp) stage1(in string) bool {
return true
}
// LoadProxyTXT loads proxies from a given seed file and randomly feeds them to the workers.
// LoadProxyTXT loads proxies from a given seed file and feeds them to the mapBuilder to be later queued automatically for validation.
func (s *Swamp) LoadProxyTXT(seedFile string) int {
var count int
s.dbgPrint("LoadProxyTXT start: "+seedFile)
s.dbgPrint("LoadProxyTXT start: " + seedFile)
defer s.dbgPrint("LoadProxyTXT finished: " + strconv.Itoa(count))
f, err := os.Open(seedFile)
@ -60,12 +60,12 @@ func (s *Swamp) LoadProxyTXT(seedFile string) int {
return count
}
// 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 map. Uses the format: 127.0.0.1:1080 (host:port).
func (s *Swamp) LoadSingleProxy(sock string) {
inChan <- sock
}
// 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) int {
var count int
scan := bufio.NewScanner(strings.NewReader(socks))
@ -79,8 +79,8 @@ func (s *Swamp) LoadMultiLineString(socks string) int {
return count
}
// ClearSOCKSList clears the slice of proxies that we continually draw from at random for validation
// * Other operations (proxies that are still in buffered channels) will resume unless paused.
// ClearSOCKSList clears the map of proxies that we have on record.
// Other operations (proxies that are still in buffered channels) will continue unless paused.
func (s *Swamp) ClearSOCKSList() {
s.swampmap.clear()
}

View File

@ -19,7 +19,7 @@ type Statistics struct {
Stale int
// birthday represents the time we started checking proxies with this pool
birthday time.Time
mu *sync.Mutex
mu *sync.Mutex
}
func (stats *Statistics) dispense() {

View File

@ -141,12 +141,12 @@ func (sock *Proxy) validate() {
switch sock.Proto {
case "4":
go s.Stats.v4()
s.Socks4 <- sock
s.ValidSocks4 <- sock
case "4a":
go s.Stats.v4a()
s.Socks4a <- sock
s.ValidSocks4a <- sock
case "5":
go s.Stats.v5()
s.Socks5 <- sock
s.ValidSocks5 <- sock
}
}