Documentation ¶
Index ¶
- type Proxy
- type Statistics
- type Swamp
- func (s *Swamp) AddCheckEndpoints(endpoints []string)
- func (s *Swamp) AddUserAgents(uagents []string)
- func (s *Swamp) ClearSOCKSList()
- func (s *Swamp) DebugChannel() chan string
- func (s *Swamp) DebugEnabled() bool
- func (s *Swamp) DialContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (s *Swamp) DisableDebug()
- func (s *Swamp) DisableDebugChannel()
- func (s *Swamp) DisableRecycling()
- func (s *Swamp) EnableDebug()
- func (s *Swamp) EnableRecycling()
- func (s *Swamp) GetAnySOCKS() Proxy
- func (s *Swamp) GetDialerBailout() int
- func (s *Swamp) GetMaxWorkers() int
- func (s *Swamp) GetRandomEndpoint() string
- func (s *Swamp) GetRecyclingStatus() bool
- func (s *Swamp) GetRemoveAfter() int
- func (s *Swamp) GetStaleTime() time.Duration
- func (s *Swamp) GetTimeoutSecondsStr() string
- func (s *Swamp) GetValidationTimeout() time.Duration
- func (s *Swamp) GetWorkers() (int, int, int)
- func (s *Swamp) IsRunning() bool
- func (s *Swamp) LoadMultiLineString(socks string) int
- func (s *Swamp) LoadProxyTXT(seedFile string) int
- func (s *Swamp) LoadSingleProxy(sock string)
- func (s *Swamp) MysteryDialer(ctx context.Context, network, addr string) (net.Conn, error)
- func (s *Swamp) Pause() error
- func (s *Swamp) RandomUserAgent() string
- func (s *Swamp) Resume() error
- func (s *Swamp) SetCheckEndpoints(newendpoints []string)
- func (s *Swamp) SetDialerBailout(dialattempts int)
- func (s *Swamp) SetMaxWorkers(num int) error
- func (s *Swamp) SetRemoveAfter(timesfailed int)
- func (s *Swamp) SetStaleTime(newtime time.Duration)
- func (s *Swamp) SetUserAgents(uagents []string)
- func (s *Swamp) SetValidationTimeout(timeout time.Duration)
- func (s *Swamp) Socks4Str() string
- func (s *Swamp) Socks4aStr() string
- func (s *Swamp) Socks5Str() string
- func (s *Swamp) Start() error
- func (s *Swamp) StartSOCKS5Server(listen, username, password string) error
- type SwampStatus
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) UniqueKey ¶
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 ¶
AddCheckEndpoints appends entries to the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
func (*Swamp) AddUserAgents ¶
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 ¶
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 ¶
DebugEnabled returns the current state of our debug switch.
func (*Swamp) DialContext ¶
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 ¶
GetAnySOCKS retrieves any version SOCKS proxy as a Proxy type Will block if one is not available!
func (*Swamp) GetDialerBailout ¶
GetDialerBailout retrieves the dialer bailout policy. See SetDialerBailout for more info.
func (*Swamp) GetMaxWorkers ¶
GetMaxWorkers returns maximum amount of workers that validate proxies concurrently. Note this is read-only during runtime.
func (*Swamp) GetRandomEndpoint ¶
GetRandomEndpoint returns a random whatismyip style endpoint from our Swamp's options
func (*Swamp) GetRecyclingStatus ¶
GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.
func (*Swamp) GetRemoveAfter ¶
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 ¶
GetStaleTime returns the duration of time after which a proxy will be considered "stale".
func (*Swamp) GetTimeoutSecondsStr ¶
GetTimeoutSecondsStr returns the current value of validationTimeout (in seconds string).
func (*Swamp) GetValidationTimeout ¶
GetValidationTimeout returns the current value of validationTimeout.
func (*Swamp) GetWorkers ¶
GetWorkers retrieves pond worker statistics:
- return MaxWorkers, RunningWorkers, IdleWorkers
func (*Swamp) IsRunning ¶
IsRunning returns true if our background goroutines defined in daemons.go are currently operational
func (*Swamp) LoadMultiLineString ¶
LoadMultiLineString loads a multiine string object with one (host:port) SOCKS proxy per line.
func (*Swamp) LoadProxyTXT ¶
LoadProxyTXT loads proxies from a given seed file and feeds them to the mapBuilder to be later queued automatically for validation.
func (*Swamp) LoadSingleProxy ¶
LoadSingleProxy loads a SOCKS proxy into our map. Uses the format: 127.0.0.1:1080 (host:port).
func (*Swamp) MysteryDialer ¶
MysteryDialer is a dialer function that will use a different proxy for every request.
func (*Swamp) Pause ¶
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 ¶
RandomUserAgent retrieves a random user agent from our list in string form.
func (*Swamp) Resume ¶
Resume will resume pause proxy pool operations, attempting to resume a running Swamp is a non-op.
func (*Swamp) SetCheckEndpoints ¶
SetCheckEndpoints replaces the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
func (*Swamp) SetDialerBailout ¶
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 ¶
SetMaxWorkers set the maximum workers for proxy checking and clears the current proxy map and worker pool jobs.
func (*Swamp) SetRemoveAfter ¶
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 ¶
SetStaleTime replaces the duration of time after which a proxy will be considered "stale". stale proxies will be skipped upon retrieval.
func (*Swamp) SetUserAgents ¶
SetUserAgents sets the list of useragents we randomly choose from during proxied requests
func (*Swamp) SetValidationTimeout ¶
SetValidationTimeout sets the validationTimeout option.
func (*Swamp) Socks4Str ¶
Socks4Str gets a SOCKS4 proxy that we have fully verified. Will block if one is not available!
func (*Swamp) Socks4aStr ¶
Socks4aStr gets a SOCKS4 proxy that we have fully verified. Will block if one is not available!
func (*Swamp) Socks5Str ¶
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 ¶
Start starts our proxy pool operations. Trying to start a running Swamp will return an error.
func (*Swamp) StartSOCKS5Server ¶
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 )