pxndscvm

package module
v0.0.0-...-31787f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 23 Imported by: 0

README

PxndScvm

GoDoc Go Report Card

SOCKS5/4/4a validating proxy pool

Demo

This package is for managing and accessing thousands upon thousands of arbitrary SOCKS proxies.

Pipe it a file filled with SOCKS proxies (host:port per line) and it will validate them continously while automatically weeding out the invalid ones.

This project is in development.

See the docs and the example for more details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proxy

type Proxy struct {
	// Endpoint is the address:port of the proxy that we connect to
	Endpoint string
	// ProxiedIP is the address that we end up having when making proxied requests through this proxy
	ProxiedIP string
	// Proto is the version/Protocol (currently SOCKS* only) of the proxy
	Proto atomic.Value
	// contains filtered or unexported fields
}

Proxy represents an individual proxy

func (Proxy) GetProto

func (sock Proxy) GetProto() string

GetProto safely retrieves the protocol value of the Proxy.

func (Proxy) UniqueKey

func (sock Proxy) UniqueKey() string

UniqueKey is an implementation of the Identity interface from Rate5. See: https://pkg.go.dev/github.com/yunginnanet/Rate5#Identity

type Statistics

type Statistics struct {
	// Valid4 is the amount of SOCKS4 proxies validated
	Valid4 int
	// Valid4a is the amount of SOCKS4a proxies validated
	Valid4a int
	// Valid5 is the amount of SOCKS5 proxies validated
	Valid5 int
	// ValidHTTP is the amount of HTTP proxies validated
	ValidHTTP int
	// Dispensed is a simple ticker to keep track of proxies dispensed via our getters
	Dispensed int
	// Stale is the amount of proxies that failed our stale policy upon dispensing
	Stale int
	// Checked is the amount of proxies we've checked.
	Checked int
	// contains filtered or unexported fields
}

Statistics is used to encapsulate various swampy stats

func (*Statistics) GetUptime

func (stats *Statistics) GetUptime() time.Duration

GetUptime returns the total lifetime duration of our pool.

type Swamp

type Swamp struct {
	// 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
	// ValidHTTP is a constant stream of verified ValidSocks5 proxies
	ValidHTTP chan *Proxy

	// Stats holds the Statistics for our swamp
	Stats *Statistics

	Status SwampStatus

	// Pending is a constant stream of proxy strings to be verified
	Pending chan *Proxy
	// contains filtered or unexported fields
}

Swamp represents a proxy pool

func NewDefaultSwamp

func NewDefaultSwamp() *Swamp

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 (*Swamp) AddCheckEndpoints

func (s *Swamp) AddCheckEndpoints(endpoints []string)

AddCheckEndpoints appends entries to the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)

func (*Swamp) AddUserAgents

func (s *Swamp) AddUserAgents(uagents []string)

AddUserAgents appends to the list of useragents we randomly choose from during proxied requests

func (*Swamp) ClearSOCKSList

func (s *Swamp) ClearSOCKSList()

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 (*Swamp) DebugChannel

func (s *Swamp) DebugChannel() chan string

DebugChannel will return a channel which will receive debug messages once debug is enabled. This will alter the flow of debug messages, they will no longer print to console, they will be pushed into this channel. Make sure you pull from the channel eventually to avoid build up of blocked goroutines.

func (*Swamp) DebugEnabled

func (s *Swamp) DebugEnabled() bool

DebugEnabled returns the current state of our debug switch.

func (*Swamp) DialContext

func (s *Swamp) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

func (*Swamp) DisableDebug

func (s *Swamp) DisableDebug()

DisableDebug enables printing of verbose messages during operation. WARNING: if you are using a DebugChannel, you must read all of the messages in the channel's cache or this will block.

func (*Swamp) DisableDebugChannel

func (s *Swamp) DisableDebugChannel()

DisableDebugChannel redirects debug messages back to the console. DisableProxyChannel does not disable debug, use DisableDebug().

func (*Swamp) DisableRecycling

func (s *Swamp) DisableRecycling()

DisableRecycling enables recycling used proxies back into the pending channel for revalidation after dispensed.

func (*Swamp) EnableDebug

func (s *Swamp) EnableDebug()

EnableDebug enables printing of verbose messages during operation

func (*Swamp) EnableRecycling

func (s *Swamp) EnableRecycling()

EnableRecycling disables recycling used proxies back into the pending channel for revalidation after dispensed.

func (*Swamp) GetAnySOCKS

func (s *Swamp) GetAnySOCKS() Proxy

GetAnySOCKS retrieves any version SOCKS proxy as a Proxy type Will block if one is not available!

func (*Swamp) GetDialerBailout

func (s *Swamp) GetDialerBailout() int

GetDialerBailout retrieves the dialer bailout policy. See SetDialerBailout for more info.

func (*Swamp) GetMaxWorkers

func (s *Swamp) GetMaxWorkers() int

GetMaxWorkers returns maximum amount of workers that validate proxies concurrently. Note this is read-only during runtime.

func (*Swamp) GetRandomEndpoint

func (s *Swamp) GetRandomEndpoint() string

GetRandomEndpoint returns a random whatismyip style endpoint from our Swamp's options

func (*Swamp) GetRecyclingStatus

func (s *Swamp) GetRecyclingStatus() bool

GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.

func (*Swamp) GetRemoveAfter

func (s *Swamp) GetRemoveAfter() int

GetRemoveAfter retrieves the removeafter policy, the amount of times a recycled proxy is marked as bad until it is removed entirely.

  • returns -1 if recycling is disabled.

func (*Swamp) GetStaleTime

func (s *Swamp) GetStaleTime() time.Duration

GetStaleTime returns the duration of time after which a proxy will be considered "stale".

func (*Swamp) GetTimeoutSecondsStr

func (s *Swamp) GetTimeoutSecondsStr() string

GetTimeoutSecondsStr returns the current value of validationTimeout (in seconds string).

func (*Swamp) GetValidationTimeout

func (s *Swamp) GetValidationTimeout() time.Duration

GetValidationTimeout returns the current value of validationTimeout.

func (*Swamp) GetWorkers

func (s *Swamp) GetWorkers() (int, int, int)

GetWorkers retrieves pond worker statistics:

  • return MaxWorkers, RunningWorkers, IdleWorkers

func (*Swamp) IsRunning

func (s *Swamp) IsRunning() bool

IsRunning returns true if our background goroutines defined in daemons.go are currently operational

func (*Swamp) LoadMultiLineString

func (s *Swamp) LoadMultiLineString(socks string) int

LoadMultiLineString loads a multiine string object with one (host:port) SOCKS proxy per line.

func (*Swamp) LoadProxyTXT

func (s *Swamp) LoadProxyTXT(seedFile string) int

LoadProxyTXT loads proxies from a given seed file and feeds them to the mapBuilder to be later queued automatically for validation.

func (*Swamp) LoadSingleProxy

func (s *Swamp) LoadSingleProxy(sock string)

LoadSingleProxy loads a SOCKS proxy into our map. Uses the format: 127.0.0.1:1080 (host:port).

func (*Swamp) MysteryDialer

func (s *Swamp) MysteryDialer(ctx context.Context, network, addr string) (net.Conn, error)

MysteryDialer is a dialer function that will use a different proxy for every request.

func (*Swamp) Pause

func (s *Swamp) Pause() error

Pause will cease the creation of any new proxy validation operations.

  • You will be able to start the proxy pool again with Swamp.Resume(), it will have the same Statistics, options, and ratelimits.
  • During pause you are still able to dispense proxies.
  • Options may be changed and proxy lists may be loaded when paused.
  • Pausing an already paused Swamp is a nonop.

func (*Swamp) RandomUserAgent

func (s *Swamp) RandomUserAgent() string

RandomUserAgent retrieves a random user agent from our list in string form.

func (*Swamp) Resume

func (s *Swamp) Resume() error

Resume will resume pause proxy pool operations, attempting to resume a running Swamp is a non-op.

func (*Swamp) SetCheckEndpoints

func (s *Swamp) SetCheckEndpoints(newendpoints []string)

SetCheckEndpoints replaces the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)

func (*Swamp) SetDialerBailout

func (s *Swamp) SetDialerBailout(dialattempts int)

SetDialerBailout sets the amount of times the MysteryDialer will dial out and fail before it bails out.

  • The dialer will attempt to redial a destination with a different proxy a specified amount of times before it gives up

func (*Swamp) SetMaxWorkers

func (s *Swamp) SetMaxWorkers(num int) error

SetMaxWorkers set the maximum workers for proxy checking and clears the current proxy map and worker pool jobs.

func (*Swamp) SetRemoveAfter

func (s *Swamp) SetRemoveAfter(timesfailed int)

SetRemoveAfter sets the removeafter policy, the amount of times a recycled proxy is marked as bad until it is removed entirely.

  • Only applies when recycling is enabled *

func (*Swamp) SetStaleTime

func (s *Swamp) SetStaleTime(newtime time.Duration)

SetStaleTime replaces the duration of time after which a proxy will be considered "stale". stale proxies will be skipped upon retrieval.

func (*Swamp) SetUserAgents

func (s *Swamp) SetUserAgents(uagents []string)

SetUserAgents sets the list of useragents we randomly choose from during proxied requests

func (*Swamp) SetValidationTimeout

func (s *Swamp) SetValidationTimeout(timeout time.Duration)

SetValidationTimeout sets the validationTimeout option.

func (*Swamp) Socks4Str

func (s *Swamp) Socks4Str() string

Socks4Str gets a SOCKS4 proxy that we have fully verified. Will block if one is not available!

func (*Swamp) Socks4aStr

func (s *Swamp) Socks4aStr() string

Socks4aStr gets a SOCKS4 proxy that we have fully verified. Will block if one is not available!

func (*Swamp) Socks5Str

func (s *Swamp) Socks5Str() string

Socks5Str gets a SOCKS5 proxy that we have fully verified (dialed and then retrieved our IP address from a what-is-my-ip endpoint. Will block if one is not available!

func (*Swamp) Start

func (s *Swamp) Start() error

Start starts our proxy pool operations. Trying to start a running Swamp will return an error.

func (*Swamp) StartSOCKS5Server

func (s *Swamp) StartSOCKS5Server(listen, username, password string) error

StartSOCKS5Server starts our rotating proxy SOCKS5 server. listen is standard Go listen string, e.g: "127.0.0.1:1080". username and password are used for authenticatig to the SOCKS5 server.

type SwampStatus

type SwampStatus uint32

SwampStatus represents the current state of our Swamp.

const (
	// Running means the proxy pool is currently taking in proxys and validating them, and is available to dispense proxies.
	Running SwampStatus = iota
	// Paused means the proxy pool has been with Swamp.Pause() and may be resumed with Swamp.Resume()
	Paused
	// New means the proxy pool has never been started.
	New
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL