2021-10-09 17:23:13 +00:00
|
|
|
package Prox5
|
2021-09-13 09:37:59 +00:00
|
|
|
|
2021-09-13 16:32:07 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2021-09-13 10:08:04 +00:00
|
|
|
|
2021-09-13 09:37:59 +00:00
|
|
|
// AddUserAgents appends to the list of useragents we randomly choose from during proxied requests
|
|
|
|
func (s *Swamp) AddUserAgents(uagents []string) {
|
|
|
|
s.mu.Lock()
|
|
|
|
defer s.mu.Unlock()
|
2021-09-28 06:25:00 +00:00
|
|
|
s.swampopt.userAgents = append(s.swampopt.userAgents, uagents...)
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserAgents sets the list of useragents we randomly choose from during proxied requests
|
|
|
|
func (s *Swamp) SetUserAgents(uagents []string) {
|
|
|
|
s.mu.Lock()
|
|
|
|
defer s.mu.Unlock()
|
2021-09-24 21:06:08 +00:00
|
|
|
s.swampopt.userAgents = uagents
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 15:36:30 +00:00
|
|
|
// SetCheckEndpoints replaces the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
|
|
|
|
func (s *Swamp) SetCheckEndpoints(newendpoints []string) {
|
|
|
|
s.mu.Lock()
|
|
|
|
defer s.mu.Unlock()
|
2021-09-24 21:06:08 +00:00
|
|
|
s.swampopt.checkEndpoints = newendpoints
|
2021-09-13 15:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddCheckEndpoints appends entries to the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
|
2021-09-24 21:06:08 +00:00
|
|
|
func (s *Swamp) AddCheckEndpoints(endpoints []string) {
|
2021-09-13 15:36:30 +00:00
|
|
|
s.mu.Lock()
|
|
|
|
defer s.mu.Unlock()
|
2021-09-28 06:25:00 +00:00
|
|
|
s.swampopt.checkEndpoints = append(s.swampopt.checkEndpoints, endpoints...)
|
2021-09-13 15:36:30 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 16:32:07 +00:00
|
|
|
// SetStaleTime replaces the duration of time after which a proxy will be considered "stale". stale proxies will be skipped upon retrieval.
|
|
|
|
func (s *Swamp) SetStaleTime(newtime time.Duration) {
|
2021-09-24 21:06:08 +00:00
|
|
|
s.swampopt.stale.Store(newtime)
|
2021-09-13 16:32:07 +00:00
|
|
|
}
|
|
|
|
|
2021-09-24 19:07:56 +00:00
|
|
|
// SetValidationTimeout sets the validationTimeout option.
|
|
|
|
func (s *Swamp) SetValidationTimeout(timeout time.Duration) {
|
|
|
|
s.swampopt.validationTimeout.Store(timeout)
|
2021-09-13 17:40:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 16:46:09 +00:00
|
|
|
// SetServerTimeout sets the serverTimeout option.
|
2021-10-28 15:51:10 +00:00
|
|
|
// * serverTimeout defines the timeout for outgoing connections made with the MysteryDialer.
|
|
|
|
// * To disable timeout on outgoing MysteryDialer connections, set this to time.Duration(0).
|
2021-10-27 16:46:09 +00:00
|
|
|
func (s *Swamp) SetServerTimeout(timeout time.Duration) {
|
|
|
|
s.swampopt.serverTimeout.Store(timeout)
|
|
|
|
}
|
|
|
|
|
2021-09-20 08:49:06 +00:00
|
|
|
// SetMaxWorkers set the maximum workers for proxy checking and clears the current proxy map and worker pool jobs.
|
2021-10-23 17:25:28 +00:00
|
|
|
func (s *Swamp) SetMaxWorkers(num int) {
|
2021-09-23 07:38:00 +00:00
|
|
|
s.pool.Tune(num)
|
2021-09-13 10:08:04 +00:00
|
|
|
}
|
2021-09-20 07:05:21 +00:00
|
|
|
|
2021-10-27 02:51:14 +00:00
|
|
|
// EnableRecycling enables recycling used proxies back into the pending channel for revalidation after dispensed.
|
2021-09-24 21:06:08 +00:00
|
|
|
func (s *Swamp) EnableRecycling() {
|
|
|
|
s.swampopt.recycle.Store(true)
|
|
|
|
}
|
|
|
|
|
2021-10-27 02:51:14 +00:00
|
|
|
// DisableRecycling disables recycling used proxies back into the pending channel for revalidation after dispensed.
|
2021-09-24 21:06:08 +00:00
|
|
|
func (s *Swamp) DisableRecycling() {
|
|
|
|
s.swampopt.recycle.Store(false)
|
2021-09-20 07:05:21 +00:00
|
|
|
}
|
2021-09-20 08:49:06 +00:00
|
|
|
|
2021-10-27 03:08:23 +00:00
|
|
|
// SetRemoveAfter sets the removeafter policy, the amount of times a recycled proxy is marked as bad before it is removed entirely.
|
|
|
|
// * Default is 5
|
|
|
|
// * To disable deleting entirely, set this value to -1
|
|
|
|
// * Only applies when recycling is enabled
|
2021-09-28 06:25:00 +00:00
|
|
|
func (s *Swamp) SetRemoveAfter(timesfailed int) {
|
|
|
|
s.swampopt.removeafter.Store(timesfailed)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 (s *Swamp) SetDialerBailout(dialattempts int) {
|
|
|
|
s.swampopt.dialerBailout.Store(dialattempts)
|
2021-09-20 08:49:06 +00:00
|
|
|
}
|