Projects STRLCPY prox5 Commits 5a7298b4
🤬
  • ■ ■ ■ ■ ■ ■
    conductor.go
    skipped 5 lines
    6 6   "sync/atomic"
    7 7  )
    8 8   
    9  -// SwampStatus represents the current state of our ProxyEngine.
     9 +// SwampStatus represents the current state of our Swamp.
    10 10  type SwampStatus uint32
    11 11   
    12 12  const (
    13 13   // StateRunning means the proxy pool is currently taking in proxys and validating them, and is available to dispense proxies.
    14 14   StateRunning SwampStatus = iota
    15  - // StatePaused means the proxy pool has been with ProxyEngine.Pause() and may be resumed with Swamp.Resume()
     15 + // StatePaused means the proxy pool has been with Swamp.Pause() and may be resumed with Swamp.Resume()
    16 16   StatePaused
    17 17   // StateNew means the proxy pool has never been started.
    18 18   StateNew
    19 19  )
    20 20   
    21  -// Start starts our proxy pool operations. Trying to start a running ProxyEngine will return an error.
    22  -func (pe *ProxyEngine) Start() error {
     21 +// Start starts our proxy pool operations. Trying to start a running Swamp will return an error.
     22 +func (pe *Swamp) Start() error {
    23 23   if atomic.LoadUint32(&pe.Status) != uint32(StateNew) {
    24 24   return pe.Resume()
    25 25   }
    skipped 6 lines
    32 32   - You will be able to start the proxy pool again with Swamp.Resume(), it will have the same Statistics, options, and ratelimits.
    33 33   - During pause you are still able to dispense proxies.
    34 34   - Options may be changed and proxy lists may be loaded when paused.
    35  - - Pausing an already paused ProxyEngine is a nonop.
     35 + - Pausing an already paused Swamp is a nonop.
    36 36  */
    37  -func (pe *ProxyEngine) Pause() error {
     37 +func (pe *Swamp) Pause() error {
    38 38   if !pe.IsRunning() {
    39 39   return errors.New("not running")
    40 40   }
    skipped 6 lines
    47 47   return nil
    48 48  }
    49 49   
    50  -func (pe *ProxyEngine) startDaemons() {
     50 +func (pe *Swamp) startDaemons() {
    51 51   go pe.mapBuilder()
    52 52   <-pe.conductor
    53 53   pe.svcUp()
    skipped 7 lines
    61 61   }
    62 62  }
    63 63   
    64  -// Resume will resume pause proxy pool operations, attempting to resume a running ProxyEngine is returns an error.
    65  -func (pe *ProxyEngine) Resume() error {
     64 +// Resume will resume pause proxy pool operations, attempting to resume a running Swamp is returns an error.
     65 +func (pe *Swamp) Resume() error {
    66 66   if pe.IsRunning() {
    67 67   return errors.New("already running")
    68 68   }
    skipped 5 lines
  • ■ ■ ■ ■ ■ ■
    daemons.go
    skipped 10 lines
    11 11   "git.tcp.direct/kayos/prox5/internal/pools"
    12 12  )
    13 13   
    14  -func (pe *ProxyEngine) svcUp() {
     14 +func (pe *Swamp) svcUp() {
    15 15   atomic.AddInt32(&pe.runningdaemons, 1)
    16 16  }
    17 17   
    18  -func (pe *ProxyEngine) svcDown() {
     18 +func (pe *Swamp) svcDown() {
    19 19   atomic.AddInt32(&pe.runningdaemons, -1)
    20 20  }
    21 21   
    22 22  type swampMap struct {
    23 23   plot map[string]*Proxy
    24 24   mu *sync.RWMutex
    25  - parent *ProxyEngine
     25 + parent *Swamp
    26 26  }
    27 27   
    28 28  func (sm swampMap) add(sock string) (*Proxy, bool) {
    skipped 45 lines
    74 74   }
    75 75  }
    76 76   
    77  -func (pe *ProxyEngine) mapBuilder() {
     77 +func (pe *Swamp) mapBuilder() {
    78 78   if pe.pool.IsClosed() {
    79 79   pe.pool.Reboot()
    80 80   }
    skipped 21 lines
    102 102   pe.conductor <- true
    103 103  }
    104 104   
    105  -func (pe *ProxyEngine) recycling() int {
     105 +func (pe *Swamp) recycling() int {
    106 106   if !pe.GetRecyclingStatus() {
    107 107   return 0
    108 108   }
    skipped 21 lines
    130 130   return count
    131 131  }
    132 132   
    133  -func (pe *ProxyEngine) jobSpawner() {
     133 +func (pe *Swamp) jobSpawner() {
    134 134   if pe.pool.IsClosed() {
    135 135   pe.pool.Reboot()
    136 136   }
    skipped 34 lines
  • ■ ■ ■ ■ ■ ■
    debug.go
    skipped 24 lines
    25 25  )
    26 26   
    27 27  type SocksLogger struct {
    28  - parent *ProxyEngine
     28 + parent *Swamp
    29 29  }
    30 30   
    31 31  // Printf is used to handle socks server logging.
    skipped 14 lines
    46 46  }
    47 47   
    48 48  // DebugEnabled returns the current state of our debug switch.
    49  -func (pe *ProxyEngine) DebugEnabled() bool {
     49 +func (pe *Swamp) DebugEnabled() bool {
    50 50   debugHardLock.RLock()
    51 51   defer debugHardLock.RUnlock()
    52 52   return atomic.CompareAndSwapUint32(debugStatus, debugEnabled, debugEnabled)
    53 53  }
    54 54   
    55 55  // EnableDebug enables printing of verbose messages during operation
    56  -func (pe *ProxyEngine) EnableDebug() {
     56 +func (pe *Swamp) EnableDebug() {
    57 57   atomic.StoreUint32(debugStatus, debugEnabled)
    58 58  }
    59 59   
    60 60  // DisableDebug enables printing of verbose messages during operation.
    61 61  // WARNING: if you are using a DebugChannel, you must read all of the messages in the channel's cache or this will block.
    62  -func (pe *ProxyEngine) DisableDebug() {
     62 +func (pe *Swamp) DisableDebug() {
    63 63   atomic.StoreUint32(debugStatus, debugDisabled)
    64 64  }
    65 65   
    skipped 3 lines
    69 69   return buf
    70 70  }
    71 71   
    72  -func (pe *ProxyEngine) dbgPrint(builder *strings.Builder) {
     72 +func (pe *Swamp) dbgPrint(builder *strings.Builder) {
    73 73   defer pools.DiscardBuffer(builder)
    74 74   if !pe.DebugEnabled() {
    75 75   return
    skipped 2 lines
    78 78   return
    79 79  }
    80 80   
    81  -func (pe *ProxyEngine) msgUnableToReach(socksString, target string, err error) {
     81 +func (pe *Swamp) msgUnableToReach(socksString, target string, err error) {
    82 82   if !pe.DebugEnabled() {
    83 83   return
    84 84   }
    skipped 14 lines
    99 99   pe.dbgPrint(buf)
    100 100  }
    101 101   
    102  -func (pe *ProxyEngine) msgUsingProxy(socksString string) {
     102 +func (pe *Swamp) msgUsingProxy(socksString string) {
    103 103   if !pe.DebugEnabled() {
    104 104   return
    105 105   }
    skipped 3 lines
    109 109   pe.dbgPrint(buf)
    110 110  }
    111 111   
    112  -func (pe *ProxyEngine) msgFailedMiddleware(socksString string) {
     112 +func (pe *Swamp) msgFailedMiddleware(socksString string) {
    113 113   if !pe.DebugEnabled() {
    114 114   return
    115 115   }
    skipped 4 lines
    120 120   pe.dbgPrint(buf)
    121 121  }
    122 122   
    123  -func (pe *ProxyEngine) msgTry(socksString string) {
     123 +func (pe *Swamp) msgTry(socksString string) {
    124 124   if !pe.DebugEnabled() {
    125 125   return
    126 126   }
    skipped 3 lines
    130 130   pe.dbgPrint(buf)
    131 131  }
    132 132   
    133  -func (pe *ProxyEngine) msgCantGetLock(socksString string, putback bool) {
     133 +func (pe *Swamp) msgCantGetLock(socksString string, putback bool) {
    134 134   if !pe.DebugEnabled() {
    135 135   return
    136 136   }
    skipped 6 lines
    143 143   pe.dbgPrint(buf)
    144 144  }
    145 145   
    146  -func (pe *ProxyEngine) msgGotLock(socksString string) {
     146 +func (pe *Swamp) msgGotLock(socksString string) {
    147 147   if !pe.DebugEnabled() {
    148 148   return
    149 149   }
    skipped 3 lines
    153 153   pe.dbgPrint(buf)
    154 154  }
    155 155   
    156  -func (pe *ProxyEngine) msgChecked(sock *Proxy, success bool) {
     156 +func (pe *Swamp) msgChecked(sock *Proxy, success bool) {
    157 157   if !pe.DebugEnabled() {
    158 158   return
    159 159   }
    skipped 12 lines
    172 172   pe.dbgPrint(buf)
    173 173  }
    174 174   
    175  -func (pe *ProxyEngine) msgBadProxRate(sock *Proxy) {
     175 +func (pe *Swamp) msgBadProxRate(sock *Proxy) {
    176 176   if !pe.DebugEnabled() {
    177 177   return
    178 178   }
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    defs.go
    skipped 24 lines
    25 25   HTTP chan *Proxy
    26 26  }
    27 27   
    28  -// ProxyEngine represents a proxy pool
    29  -type ProxyEngine struct {
     28 +// Swamp represents a proxy pool
     29 +type Swamp struct {
    30 30   Valids ProxyChannels
    31 31   DebugLogger logger.Logger
    32 32   
    skipped 65 lines
    98 98   return sm
    99 99  }
    100 100   
    101  -// config holds our configuration for ProxyEngine instances.
     101 +// config holds our configuration for Swamp instances.
    102 102  // This is implemented as a pointer, and should be interacted with via the setter and getter functions.
    103 103  type config struct {
    104 104   // stale is the amount of time since verification that qualifies a proxy going stale.
    skipped 30 lines
    135 135   *sync.RWMutex
    136 136  }
    137 137   
    138  -// NewProxyEngine returns a ProxyEngine with default options.
    139  -// After calling this you may use the various "setters" to change the options before calling ProxyEngine.Start().
    140  -func NewProxyEngine() *ProxyEngine {
    141  - pe := &ProxyEngine{
     138 +// NewProxyEngine returns a Swamp with default options.
     139 +// After calling this you may use the various "setters" to change the options before calling Swamp.Start().
     140 +func NewProxyEngine() *Swamp {
     141 + pe := &Swamp{
    142 142   stats: &statistics{birthday: time.Now()},
    143 143   DebugLogger: &basicPrinter{},
    144 144   
    skipped 43 lines
    188 188   return pe
    189 189  }
    190 190   
    191  -func newSwampMap(pe *ProxyEngine) swampMap {
     191 +func newSwampMap(pe *Swamp) swampMap {
    192 192   return swampMap{
    193 193   plot: make(map[string]*Proxy),
    194 194   mu: &sync.RWMutex{},
    skipped 1 lines
    196 196   }
    197 197  }
    198 198   
    199  -func (pe *ProxyEngine) pondPanic(p interface{}) {
     199 +func (pe *Swamp) pondPanic(p interface{}) {
    200 200   panic(p)
    201 201   // pe.dbgPrint("Worker panic: " + fmt.Sprintf("%v", p))
    202 202  }
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    dispense.go
    skipped 9 lines
    10 10   
    11 11  // Socks5Str gets a SOCKS5 proxy that we have fully verified (dialed and then retrieved our IP address from a what-is-my-ip endpoint.
    12 12  // Will block if one is not available!
    13  -func (pe *ProxyEngine) Socks5Str() string {
     13 +func (pe *Swamp) Socks5Str() string {
    14 14   for {
    15 15   select {
    16 16   case sock := <-pe.Valids.SOCKS5:
    skipped 10 lines
    27 27   
    28 28  // Socks4Str gets a SOCKS4 proxy that we have fully verified.
    29 29  // Will block if one is not available!
    30  -func (pe *ProxyEngine) Socks4Str() string {
     30 +func (pe *Swamp) Socks4Str() string {
    31 31   defer pe.stats.dispense()
    32 32   for {
    33 33   select {
    skipped 10 lines
    44 44   
    45 45  // Socks4aStr gets a SOCKS4 proxy that we have fully verified.
    46 46  // Will block if one is not available!
    47  -func (pe *ProxyEngine) Socks4aStr() string {
     47 +func (pe *Swamp) Socks4aStr() string {
    48 48   defer pe.stats.dispense()
    49 49   for {
    50 50   select {
    skipped 12 lines
    63 63  // For now, this function does not loop forever like the GetAnySOCKS does.
    64 64  // Alternatively it can be included within the for loop by passing true to GetAnySOCKS.
    65 65  // If there is an HTTP proxy available, ok will be true. If not, it will return false without delay.
    66  -func (pe *ProxyEngine) GetHTTPTunnel() (p *Proxy, ok bool) {
     66 +func (pe *Swamp) GetHTTPTunnel() (p *Proxy, ok bool) {
    67 67   select {
    68 68   case httptunnel := <-pe.Valids.HTTP:
    69 69   return httptunnel, true
    skipped 5 lines
    75 75  // GetAnySOCKS retrieves any version SOCKS proxy as a Proxy type
    76 76  // Will block if one is not available!
    77 77  // StateNew/Temporary: Pass a true boolean to this to also receive HTTP proxies.
    78  -func (pe *ProxyEngine) GetAnySOCKS(acceptHTTP bool) *Proxy {
     78 +func (pe *Swamp) GetAnySOCKS(acceptHTTP bool) *Proxy {
    79 79   defer pe.stats.dispense()
    80 80   for {
    81 81   var sock *Proxy
    skipped 14 lines
    96 96   }
    97 97  }
    98 98   
    99  -func (pe *ProxyEngine) stillGood(sock *Proxy) bool {
     99 +func (pe *Swamp) stillGood(sock *Proxy) bool {
    100 100   if sock == nil {
    101 101   return false
    102 102   }
    skipped 35 lines
  • ■ ■ ■ ■
    example/main.go
    skipped 12 lines
    13 13  )
    14 14   
    15 15  var (
    16  - swamp *prox5.ProxyEngine
     16 + swamp *prox5.Swamp
    17 17   quit chan bool
    18 18   t *tty.TTY
    19 19  )
    skipped 139 lines
  • ■ ■ ■ ■ ■ ■
    getters.go
    skipped 9 lines
    10 10   
    11 11  // GetStatistics returns all current statistics.
    12 12  // * This is a pointer, do not modify it!
    13  -func (pe *ProxyEngine) GetStatistics() *statistics {
     13 +func (pe *Swamp) GetStatistics() *statistics {
    14 14   return pe.stats
    15 15  }
    16 16   
    17 17  // RandomUserAgent retrieves a random user agent from our list in string form.
    18  -func (pe *ProxyEngine) RandomUserAgent() string {
     18 +func (pe *Swamp) RandomUserAgent() string {
    19 19   pe.mu.RLock()
    20 20   defer pe.mu.RUnlock()
    21 21   return entropy.RandomStrChoice(pe.swampopt.userAgents)
    22 22  }
    23 23   
    24  -// GetRandomEndpoint returns a random whatismyip style endpoint from our ProxyEngine's options
    25  -func (pe *ProxyEngine) GetRandomEndpoint() string {
     24 +// GetRandomEndpoint returns a random whatismyip style endpoint from our Swamp's options
     25 +func (pe *Swamp) GetRandomEndpoint() string {
    26 26   pe.mu.RLock()
    27 27   defer pe.mu.RUnlock()
    28 28   return entropy.RandomStrChoice(pe.swampopt.checkEndpoints)
    29 29  }
    30 30   
    31 31  // GetStaleTime returns the duration of time after which a proxy will be considered "stale".
    32  -func (pe *ProxyEngine) GetStaleTime() time.Duration {
     32 +func (pe *Swamp) GetStaleTime() time.Duration {
    33 33   pe.swampopt.RLock()
    34 34   defer pe.swampopt.RLock()
    35 35   return pe.swampopt.stale
    36 36  }
    37 37   
    38 38  // GetValidationTimeout returns the current value of validationTimeout.
    39  -func (pe *ProxyEngine) GetValidationTimeout() time.Duration {
     39 +func (pe *Swamp) GetValidationTimeout() time.Duration {
    40 40   pe.swampopt.RLock()
    41 41   defer pe.swampopt.RLock()
    42 42   return pe.swampopt.validationTimeout
    43 43  }
    44 44   
    45 45  // GetValidationTimeoutStr returns the current value of validationTimeout (in seconds string).
    46  -func (pe *ProxyEngine) GetValidationTimeoutStr() string {
     46 +func (pe *Swamp) GetValidationTimeoutStr() string {
    47 47   pe.swampopt.RLock()
    48 48   defer pe.swampopt.RLock()
    49 49   timeout := pe.swampopt.validationTimeout
    skipped 1 lines
    51 51  }
    52 52   
    53 53  // GetServerTimeout returns the current value of serverTimeout.
    54  -func (pe *ProxyEngine) GetServerTimeout() time.Duration {
     54 +func (pe *Swamp) GetServerTimeout() time.Duration {
    55 55   pe.swampopt.RLock()
    56 56   defer pe.swampopt.RLock()
    57 57   return pe.swampopt.serverTimeout
    58 58  }
    59 59   
    60 60  // GetServerTimeoutStr returns the current value of serverTimeout (in seconds string).
    61  -func (pe *ProxyEngine) GetServerTimeoutStr() string {
     61 +func (pe *Swamp) GetServerTimeoutStr() string {
    62 62   pe.swampopt.RLock()
    63 63   defer pe.swampopt.RLock()
    64 64   timeout := pe.swampopt.serverTimeout
    skipped 4 lines
    69 69  }
    70 70   
    71 71  // GetMaxWorkers returns maximum amount of workers that validate proxies concurrently. Note this is read-only during runtime.
    72  -func (pe *ProxyEngine) GetMaxWorkers() int {
     72 +func (pe *Swamp) GetMaxWorkers() int {
    73 73   return pe.pool.Cap()
    74 74  }
    75 75   
    76 76  // IsRunning returns true if our background goroutines defined in daemons.go are currently operational
    77  -func (pe *ProxyEngine) IsRunning() bool {
     77 +func (pe *Swamp) IsRunning() bool {
    78 78   return atomic.LoadInt32(&pe.runningdaemons) == 2
    79 79  }
    80 80   
    81 81  // GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.
    82  -func (pe *ProxyEngine) GetRecyclingStatus() bool {
     82 +func (pe *Swamp) GetRecyclingStatus() bool {
    83 83   pe.swampopt.RLock()
    84 84   defer pe.swampopt.RLock()
    85 85   return pe.swampopt.recycle
    skipped 1 lines
    87 87   
    88 88  // GetWorkers retrieves pond worker statistics:
    89 89  // - return MaxWorkers, RunningWorkers, IdleWorkers
    90  -func (pe *ProxyEngine) GetWorkers() (maxWorkers, runningWorkers, idleWorkers int) {
     90 +func (pe *Swamp) GetWorkers() (maxWorkers, runningWorkers, idleWorkers int) {
    91 91   pe.mu.RLock()
    92 92   defer pe.mu.RUnlock()
    93 93   return pe.pool.Cap(), pe.pool.Running(), pe.pool.Free()
    skipped 1 lines
    95 95   
    96 96  // GetRemoveAfter retrieves the removeafter policy, the amount of times a recycled proxy is marked as bad until it is removed entirely.
    97 97  // - returns -1 if recycling is disabled.
    98  -func (pe *ProxyEngine) GetRemoveAfter() int {
     98 +func (pe *Swamp) GetRemoveAfter() int {
    99 99   pe.mu.RLock()
    100 100   defer pe.mu.RUnlock()
    101 101   if !pe.swampopt.recycle {
    skipped 3 lines
    105 105  }
    106 106   
    107 107  // GetDialerBailout retrieves the dialer bailout policy. See SetDialerBailout for more info.
    108  -func (pe *ProxyEngine) GetDialerBailout() int {
     108 +func (pe *Swamp) GetDialerBailout() int {
    109 109   pe.mu.RLock()
    110 110   defer pe.mu.RUnlock()
    111 111   return pe.swampopt.dialerBailout
    skipped 1 lines
    113 113   
    114 114  // TODO: Document middleware concept
    115 115   
    116  -func (pe *ProxyEngine) GetDispenseMiddleware() func(*Proxy) (*Proxy, bool) {
     116 +func (pe *Swamp) GetDispenseMiddleware() func(*Proxy) (*Proxy, bool) {
    117 117   pe.mu.RLock()
    118 118   defer pe.mu.RUnlock()
    119 119   return pe.dispenseMiddleware
    120 120  }
    121 121   
    122  -func (pe *ProxyEngine) GetShuffleStatus() bool {
     122 +func (pe *Swamp) GetShuffleStatus() bool {
    123 123   pe.mu.RLock()
    124 124   defer pe.mu.RUnlock()
    125 125   return pe.swampopt.shuffle
    skipped 2 lines
  • ■ ■ ■ ■ ■ ■
    list_management.go
    skipped 23 lines
    24 24  // * yeet.com:1080:user:pass
    25 25  // * [fe80::2ef0:5dff:fe7f:c299]:1080
    26 26  // * [fe80::2ef0:5dff:fe7f:c299]:1080:user:pass
    27  -func (pe *ProxyEngine) LoadProxyTXT(seedFile string) (count int) {
     27 +func (pe *Swamp) LoadProxyTXT(seedFile string) (count int) {
    28 28   f, err := os.Open(seedFile)
    29 29   if err != nil {
    30 30   pe.dbgPrint(simpleString(err.Error()))
    skipped 24 lines
    55 55  // * yeet.com:1080:user:pass
    56 56  // * [fe80::2ef0:5dff:fe7f:c299]:1080
    57 57  // * [fe80::2ef0:5dff:fe7f:c299]:1080:user:pass
    58  -func (pe *ProxyEngine) LoadSingleProxy(sock string) (ok bool) {
     58 +func (pe *Swamp) LoadSingleProxy(sock string) (ok bool) {
    59 59   if sock, ok = filter(sock); !ok {
    60 60   return
    61 61   }
    skipped 1 lines
    63 63   return
    64 64  }
    65 65   
    66  -func (pe *ProxyEngine) loadSingleProxy(sock string) {
     66 +func (pe *Swamp) loadSingleProxy(sock string) {
    67 67   for {
    68 68   select {
    69 69   case inChan <- sock:
    skipped 12 lines
    82 82  // * yeet.com:1080:user:pass
    83 83  // * [fe80::2ef0:5dff:fe7f:c299]:1080
    84 84  // * [fe80::2ef0:5dff:fe7f:c299]:1080:user:pass
    85  -func (pe *ProxyEngine) LoadMultiLineString(socks string) int {
     85 +func (pe *Swamp) LoadMultiLineString(socks string) int {
    86 86   var count int
    87 87   scan := bufio.NewScanner(strings.NewReader(socks))
    88 88   for scan.Scan() {
    skipped 6 lines
    95 95   
    96 96  // ClearSOCKSList clears the map of proxies that we have on record.
    97 97  // Other operations (proxies that are still in buffered channels) will continue.
    98  -func (pe *ProxyEngine) ClearSOCKSList() {
     98 +func (pe *Swamp) ClearSOCKSList() {
    99 99   pe.swampmap.clear()
    100 100  }
    101 101   
  • ■ ■ ■ ■ ■ ■
    mr_worldwide.go
    skipped 7 lines
    8 8  )
    9 9   
    10 10  // GetHTTPClient retrieves a pointer to an http.Client powered by MysteryDialer.
    11  -func (pe *ProxyEngine) GetHTTPClient() *http.Client {
     11 +func (pe *Swamp) GetHTTPClient() *http.Client {
    12 12   // var htp func(*http.Request) (*url.URL, error)
    13 13   var dctx func(ctx context.Context, network string, addr string) (net.Conn, error)
    14 14   // if httun, htok := pe.GetHTTPTunnel(); htok {
    skipped 22 lines
    37 37  }
    38 38   
    39 39  // RoundTrip is Mr. WorldWide. Obviously. See: https://pkg.go.dev/net/http#RoundTripper
    40  -func (pe *ProxyEngine) RoundTrip(req *http.Request) (*http.Response, error) {
     40 +func (pe *Swamp) RoundTrip(req *http.Request) (*http.Response, error) {
    41 41   return pe.GetHTTPClient().Do(req)
    42 42  }
    43 43   
  • ■ ■ ■ ■ ■ ■
    mystery_dialer.go
    skipped 13 lines
    14 14  )
    15 15   
    16 16  // DialContext is a simple stub adapter to implement a net.Dialer.
    17  -func (pe *ProxyEngine) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
     17 +func (pe *Swamp) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
    18 18   return pe.MysteryDialer(ctx, network, addr)
    19 19  }
    20 20   
    21 21  // Dial is a simple stub adapter to implement a net.Dialer.
    22  -func (pe *ProxyEngine) Dial(network, addr string) (net.Conn, error) {
     22 +func (pe *Swamp) Dial(network, addr string) (net.Conn, error) {
    23 23   return pe.MysteryDialer(context.Background(), network, addr)
    24 24  }
    25 25   
    26 26  // DialTimeout is a simple stub adapter to implement a net.Dialer with a timeout.
    27  -func (pe *ProxyEngine) DialTimeout(network, addr string, timeout time.Duration) (net.Conn, error) {
     27 +func (pe *Swamp) DialTimeout(network, addr string, timeout time.Duration) (net.Conn, error) {
    28 28   ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(timeout))
    29 29   go func() { // this is a goroutine that calls cancel() upon the deadline expiring to avoid context leaks
    30 30   <-ctx.Done()
    skipped 2 lines
    33 33   return pe.MysteryDialer(ctx, network, addr)
    34 34  }
    35 35   
    36  -func (pe *ProxyEngine) addTimeout(socksString string) string {
     36 +func (pe *Swamp) addTimeout(socksString string) string {
    37 37   tout := pools.CopABuffer.Get().(*strings.Builder)
    38 38   tout.WriteString(socksString)
    39 39   tout.WriteString("?timeout=")
    skipped 4 lines
    44 44   return socksString
    45 45  }
    46 46   
    47  -func (pe *ProxyEngine) popSockAndLockIt(ctx context.Context) (*Proxy, error) {
     47 +func (pe *Swamp) popSockAndLockIt(ctx context.Context) (*Proxy, error) {
    48 48   sock := pe.GetAnySOCKS(false)
    49 49   socksString := sock.String()
    50 50   select {
    skipped 16 lines
    67 67  }
    68 68   
    69 69  // MysteryDialer is a dialer function that will use a different proxy for every request.
    70  -func (pe *ProxyEngine) MysteryDialer(ctx context.Context, network, addr string) (net.Conn, error) {
     70 +func (pe *Swamp) MysteryDialer(ctx context.Context, network, addr string) (net.Conn, error) {
    71 71   // pull down proxies from channel until we get a proxy good enough for our spoiled asses
    72 72   var count = 0
    73 73   for {
    skipped 39 lines
  • ■ ■ ■ ■
    mystery_resolver.go
    skipped 11 lines
    12 12   
    13 13  var dnsCache = make(map[string]dnsCacheEntry)
    14 14   
    15  -func (pe *ProxyEngine) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) {
     15 +func (pe *Swamp) Resolve(ctx context.Context, name string) (context.Context, net.IP, error) {
    16 16   var result net.IP
    17 17   for {
    18 18   select {
    skipped 7 lines
  • ■ ■ ■ ■
    proxy.go
    skipped 39 lines
    40 40   // timesBad is the amount of times the proxy has been marked as bad.
    41 41   timesBad int64
    42 42   
    43  - parent *ProxyEngine
     43 + parent *Swamp
    44 44   lock uint32
    45 45  }
    46 46   
    skipped 34 lines
  • ■ ■ ■ ■ ■ ■
    setters.go
    skipped 6 lines
    7 7  )
    8 8   
    9 9  // AddUserAgents appends to the list of useragents we randomly choose from during proxied requests
    10  -func (pe *ProxyEngine) AddUserAgents(uagents []string) {
     10 +func (pe *Swamp) AddUserAgents(uagents []string) {
    11 11   pe.mu.Lock()
    12 12   defer pe.mu.Unlock()
    13 13   pe.swampopt.userAgents = append(pe.swampopt.userAgents, uagents...)
    14 14  }
    15 15   
    16 16  // SetUserAgents sets the list of useragents we randomly choose from during proxied requests
    17  -func (pe *ProxyEngine) SetUserAgents(uagents []string) {
     17 +func (pe *Swamp) SetUserAgents(uagents []string) {
    18 18   pe.mu.Lock()
    19 19   defer pe.mu.Unlock()
    20 20   pe.swampopt.userAgents = uagents
    21 21  }
    22 22   
    23 23  // SetCheckEndpoints replaces the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
    24  -func (pe *ProxyEngine) SetCheckEndpoints(newendpoints []string) {
     24 +func (pe *Swamp) SetCheckEndpoints(newendpoints []string) {
    25 25   pe.mu.Lock()
    26 26   defer pe.mu.Unlock()
    27 27   pe.swampopt.checkEndpoints = newendpoints
    28 28  }
    29 29   
    30 30  // AddCheckEndpoints appends entries to the running list of whatismyip style endpoitns for validation. (must return only the WAN IP)
    31  -func (pe *ProxyEngine) AddCheckEndpoints(endpoints []string) {
     31 +func (pe *Swamp) AddCheckEndpoints(endpoints []string) {
    32 32   pe.mu.Lock()
    33 33   defer pe.mu.Unlock()
    34 34   pe.swampopt.checkEndpoints = append(pe.swampopt.checkEndpoints, endpoints...)
    35 35  }
    36 36   
    37 37  // SetStaleTime replaces the duration of time after which a proxy will be considered "stale". stale proxies will be skipped upon retrieval.
    38  -func (pe *ProxyEngine) SetStaleTime(newtime time.Duration) {
     38 +func (pe *Swamp) SetStaleTime(newtime time.Duration) {
    39 39   pe.swampopt.Lock()
    40 40   defer pe.swampopt.Unlock()
    41 41   pe.swampopt.stale = newtime
    42 42  }
    43 43   
    44 44  // SetValidationTimeout sets the validationTimeout option.
    45  -func (pe *ProxyEngine) SetValidationTimeout(timeout time.Duration) {
     45 +func (pe *Swamp) SetValidationTimeout(timeout time.Duration) {
    46 46   pe.swampopt.Lock()
    47 47   defer pe.swampopt.Unlock()
    48 48   pe.swampopt.validationTimeout = timeout
    skipped 2 lines
    51 51  // SetServerTimeout sets the serverTimeout option.
    52 52  // * serverTimeout defines the timeout for outgoing connections made with the MysteryDialer.
    53 53  // * To disable timeout on outgoing MysteryDialer connections, set this to time.Duration(0).
    54  -func (pe *ProxyEngine) SetServerTimeout(timeout time.Duration) {
     54 +func (pe *Swamp) SetServerTimeout(timeout time.Duration) {
    55 55   pe.swampopt.Lock()
    56 56   defer pe.swampopt.Unlock()
    57 57   pe.swampopt.serverTimeout = timeout
    58 58  }
    59 59   
    60 60  // SetMaxWorkers set the maximum workers for proxy checking and clears the current proxy map and worker pool jobs.
    61  -func (pe *ProxyEngine) SetMaxWorkers(num int) {
     61 +func (pe *Swamp) SetMaxWorkers(num int) {
    62 62   pe.pool.Tune(num)
    63 63  }
    64 64   
    65 65  // EnableRecycling enables recycling used proxies back into the pending channel for revalidation after dispensed.
    66  -func (pe *ProxyEngine) EnableRecycling() {
     66 +func (pe *Swamp) EnableRecycling() {
    67 67   pe.swampopt.Lock()
    68 68   defer pe.swampopt.Unlock()
    69 69   pe.swampopt.recycle = true
    70 70  }
    71 71   
    72 72  // DisableRecycling disables recycling used proxies back into the pending channel for revalidation after dispensed.
    73  -func (pe *ProxyEngine) DisableRecycling() {
     73 +func (pe *Swamp) DisableRecycling() {
    74 74   pe.swampopt.Lock()
    75 75   defer pe.swampopt.Unlock()
    76 76   pe.swampopt.recycle = false
    skipped 3 lines
    80 80  // - Default is 10
    81 81  // - To disable deleting entirely, set this value to -1
    82 82  // - Only applies when recycling is enabled
    83  -func (pe *ProxyEngine) SetRemoveAfter(timesfailed int) {
     83 +func (pe *Swamp) SetRemoveAfter(timesfailed int) {
    84 84   pe.swampopt.Lock()
    85 85   defer pe.swampopt.Unlock()
    86 86   pe.swampopt.removeafter = timesfailed
    skipped 1 lines
    88 88   
    89 89  // SetDialerBailout sets the amount of times the MysteryDialer will dial out and fail before it bails out.
    90 90  // - The dialer will attempt to redial a destination with a different proxy a specified amount of times before it gives up
    91  -func (pe *ProxyEngine) SetDialerBailout(dialattempts int) {
     91 +func (pe *Swamp) SetDialerBailout(dialattempts int) {
    92 92   pe.swampopt.Lock()
    93 93   defer pe.swampopt.Unlock()
    94 94   pe.swampopt.dialerBailout = dialattempts
    skipped 2 lines
    97 97  // SetDispenseMiddleware will add a function that sits within the dialing process of the MysteryDialer and anyhing using it.
    98 98  // This means this function will be called mid-dial during connections. Return true to approve proxy, false to skip it.
    99 99  // Take care modiying the proxy in-flight as it is a pointer.
    100  -func (pe *ProxyEngine) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) {
     100 +func (pe *Swamp) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) {
    101 101   pe.mu.Lock()
    102 102   defer pe.mu.Unlock()
    103 103   pe.dispenseMiddleware = f
    104 104  }
    105 105   
    106  -// SetDebugLogger sets the debug logger for the ProxyEngine. See the Logger interface for implementation details.
    107  -func (pe *ProxyEngine) SetDebugLogger(l logger.Logger) {
     106 +// SetDebugLogger sets the debug logger for the Swamp. See the Logger interface for implementation details.
     107 +func (pe *Swamp) SetDebugLogger(l logger.Logger) {
    108 108   debugHardLock.Lock()
    109 109   pe.mu.Lock()
    110 110   pe.DebugLogger = l
    skipped 1 lines
    112 112   debugHardLock.Unlock()
    113 113  }
    114 114   
    115  -func (pe *ProxyEngine) SetShuffle(shuffle bool) {
     115 +func (pe *Swamp) SetShuffle(shuffle bool) {
    116 116   pe.mu.Lock()
    117 117   defer pe.mu.Unlock()
    118 118   pe.swampopt.shuffle = shuffle
    skipped 2 lines
  • ■ ■ ■ ■
    socks5_server.go
    skipped 23 lines
    24 24  // StartSOCKS5Server starts our rotating proxy SOCKS5 server.
    25 25  // listen is standard Go listen string, e.g: "127.0.0.1:1080".
    26 26  // username and password are used for authenticatig to the SOCKS5 server.
    27  -func (pe *ProxyEngine) StartSOCKS5Server(listen, username, password string) error {
     27 +func (pe *Swamp) StartSOCKS5Server(listen, username, password string) error {
    28 28   
    29 29   conf := &socks5.Config{
    30 30   Credentials: socksCreds{username: username, password: password},
    skipped 18 lines
  • ■ ■ ■ ■
    stats.go
    skipped 48 lines
    49 49  }
    50 50   
    51 51  // GetTotalValidated retrieves our grand total validated proxy count.
    52  -func (pe *ProxyEngine) GetTotalValidated() int {
     52 +func (pe *Swamp) GetTotalValidated() int {
    53 53   stats := pe.GetStatistics()
    54 54   return int(stats.Valid4a + stats.Valid4 + stats.Valid5 + stats.ValidHTTP)
    55 55  }
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    validator_engine.go
    skipped 17 lines
    18 18   "git.tcp.direct/kayos/prox5/internal/pools"
    19 19  )
    20 20   
    21  -func (pe *ProxyEngine) prepHTTP() (*http.Client, *http.Transport, *http.Request, error) {
     21 +func (pe *Swamp) prepHTTP() (*http.Client, *http.Transport, *http.Request, error) {
    22 22   req, err := http.NewRequest("GET", pe.GetRandomEndpoint(), bytes.NewBuffer([]byte("")))
    23 23   if err != nil {
    24 24   return nil, nil, nil, err
    skipped 26 lines
    51 51   sock.lastValidated = time.Now()
    52 52  }
    53 53   
    54  -func (pe *ProxyEngine) bakeHTTP(hmd *HandMeDown) (client *http.Client, req *http.Request, err error) {
     54 +func (pe *Swamp) bakeHTTP(hmd *HandMeDown) (client *http.Client, req *http.Request, err error) {
    55 55   builder := pools.CopABuffer.Get().(*strings.Builder)
    56 56   builder.WriteString(hmd.protoCheck.String())
    57 57   builder.WriteString("://")
    skipped 25 lines
    83 83   return
    84 84  }
    85 85   
    86  -func (pe *ProxyEngine) validate(hmd *HandMeDown) (string, error) {
     86 +func (pe *Swamp) validate(hmd *HandMeDown) (string, error) {
    87 87   var (
    88 88   client *http.Client
    89 89   req *http.Request
    skipped 15 lines
    105 105   return string(rbody), err
    106 106  }
    107 107   
    108  -func (pe *ProxyEngine) anothaOne() {
     108 +func (pe *Swamp) anothaOne() {
    109 109   pe.stats.Checked++
    110 110  }
    111 111   
    skipped 14 lines
    126 126   return hmd.conn, nil
    127 127  }
    128 128   
    129  -func (pe *ProxyEngine) singleProxyCheck(sock *Proxy, protocol ProxyProtocol) error {
     129 +func (pe *Swamp) singleProxyCheck(sock *Proxy, protocol ProxyProtocol) error {
    130 130   defer pe.anothaOne()
    131 131   split := strings.Split(sock.Endpoint, "@")
    132 132   endpoint := split[0]
    skipped 80 lines
    213 213   pe.tally(sock)
    214 214  }
    215 215   
    216  -func (pe *ProxyEngine) tally(sock *Proxy) {
     216 +func (pe *Swamp) tally(sock *Proxy) {
    217 217   switch sock.protocol.Get() {
    218 218   case ProtoSOCKS4:
    219 219   pe.stats.v4()
    skipped 15 lines
Please wait...
Page is in error, reload to recover