Projects STRLCPY prox5 Commits 209deae9
🤬
  • ■ ■ ■ ■ ■ ■
    conductor.go
    skipped 18 lines
    19 19  )
    20 20   
    21 21  // Start starts our proxy pool operations. Trying to start a running Swamp will return an error.
    22  -func (pe *Swamp) Start() error {
    23  - if atomic.LoadUint32(&pe.Status) != uint32(StateNew) {
    24  - return pe.Resume()
     22 +func (p5 *Swamp) Start() error {
     23 + if atomic.LoadUint32(&p5.Status) != uint32(StateNew) {
     24 + return p5.Resume()
    25 25   }
    26  - pe.startDaemons()
     26 + p5.startDaemons()
    27 27   return nil
    28 28  }
    29 29   
    skipped 4 lines
    34 34   - Options may be changed and proxy lists may be loaded when paused.
    35 35   - Pausing an already paused Swamp is a nonop.
    36 36  */
    37  -func (pe *Swamp) Pause() error {
    38  - if !pe.IsRunning() {
     37 +func (p5 *Swamp) Pause() error {
     38 + if !p5.IsRunning() {
    39 39   return errors.New("not running")
    40 40   }
    41 41   
    42  - pe.dbgPrint(simpleString("pausing proxy pool"))
     42 + p5.dbgPrint(simpleString("pausing proxy pool"))
    43 43   
    44  - pe.quit()
     44 + p5.quit()
    45 45   
    46  - atomic.StoreUint32(&pe.Status, uint32(StatePaused))
     46 + atomic.StoreUint32(&p5.Status, uint32(StatePaused))
    47 47   return nil
    48 48  }
    49 49   
    50  -func (pe *Swamp) startDaemons() {
    51  - go pe.mapBuilder()
    52  - <-pe.conductor
    53  - pe.svcUp()
    54  - go pe.jobSpawner()
     50 +func (p5 *Swamp) startDaemons() {
     51 + go p5.mapBuilder()
     52 + <-p5.conductor
     53 + p5.svcUp()
     54 + go p5.jobSpawner()
    55 55   
    56 56   for {
    57  - if pe.IsRunning() {
    58  - atomic.StoreUint32(&pe.Status, uint32(StateRunning))
     57 + if p5.IsRunning() {
     58 + atomic.StoreUint32(&p5.Status, uint32(StateRunning))
    59 59   break
    60 60   }
    61 61   }
    62 62  }
    63 63   
    64 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  - if pe.IsRunning() {
     65 +func (p5 *Swamp) Resume() error {
     66 + if p5.IsRunning() {
    67 67   return errors.New("already running")
    68 68   }
    69  - pe.ctx, pe.quit = context.WithCancel(context.Background())
    70  - pe.startDaemons()
     69 + p5.ctx, p5.quit = context.WithCancel(context.Background())
     70 + p5.startDaemons()
    71 71   return nil
    72 72  }
    73 73   
  • ■ ■ ■ ■ ■ ■
    debug.go
    skipped 45 lines
    46 46  }
    47 47   
    48 48  // DebugEnabled returns the current state of our debug switch.
    49  -func (pe *Swamp) DebugEnabled() bool {
     49 +func (p5 *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 *Swamp) EnableDebug() {
     56 +func (p5 *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 *Swamp) DisableDebug() {
     62 +func (p5 *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 *Swamp) dbgPrint(builder *strings.Builder) {
     72 +func (p5 *Swamp) dbgPrint(builder *strings.Builder) {
    73 73   defer pools.DiscardBuffer(builder)
    74  - if !pe.DebugEnabled() {
     74 + if !p5.DebugEnabled() {
    75 75   return
    76 76   }
    77  - pe.DebugLogger.Print(builder.String())
     77 + p5.DebugLogger.Print(builder.String())
    78 78   return
    79 79  }
    80 80   
    81  -func (pe *Swamp) msgUnableToReach(socksString, target string, err error) {
    82  - if !pe.DebugEnabled() {
     81 +func (p5 *Swamp) msgUnableToReach(socksString, target string, err error) {
     82 + if !p5.DebugEnabled() {
    83 83   return
    84 84   }
    85 85   buf := pools.CopABuffer.Get().(*strings.Builder)
    86 86   buf.WriteString("unable to reach ")
    87  - if pe.swampopt.redact {
     87 + if p5.swampopt.redact {
    88 88   buf.WriteString("[redacted]")
    89 89   } else {
    90 90   buf.WriteString(target)
    91 91   }
    92 92   buf.WriteString(" with ")
    93 93   buf.WriteString(socksString)
    94  - if !pe.swampopt.redact {
     94 + if !p5.swampopt.redact {
    95 95   buf.WriteString(": ")
    96 96   buf.WriteString(err.Error())
    97 97   }
    98 98   buf.WriteString(", cycling...")
    99  - pe.dbgPrint(buf)
     99 + p5.dbgPrint(buf)
    100 100  }
    101 101   
    102  -func (pe *Swamp) msgUsingProxy(socksString string) {
    103  - if !pe.DebugEnabled() {
     102 +func (p5 *Swamp) msgUsingProxy(socksString string) {
     103 + if !p5.DebugEnabled() {
    104 104   return
    105 105   }
    106 106   buf := pools.CopABuffer.Get().(*strings.Builder)
    107 107   buf.WriteString("MysteryDialer using socks: ")
    108 108   buf.WriteString(socksString)
    109  - pe.dbgPrint(buf)
     109 + p5.dbgPrint(buf)
    110 110  }
    111 111   
    112  -func (pe *Swamp) msgFailedMiddleware(socksString string) {
    113  - if !pe.DebugEnabled() {
     112 +func (p5 *Swamp) msgFailedMiddleware(socksString string) {
     113 + if !p5.DebugEnabled() {
    114 114   return
    115 115   }
    116 116   buf := pools.CopABuffer.Get().(*strings.Builder)
    117 117   buf.WriteString("failed middleware check, ")
    118 118   buf.WriteString(socksString)
    119 119   buf.WriteString(", cycling...")
    120  - pe.dbgPrint(buf)
     120 + p5.dbgPrint(buf)
    121 121  }
    122 122   
    123  -func (pe *Swamp) msgTry(socksString string) {
    124  - if !pe.DebugEnabled() {
     123 +func (p5 *Swamp) msgTry(socksString string) {
     124 + if !p5.DebugEnabled() {
    125 125   return
    126 126   }
    127 127   buf := pools.CopABuffer.Get().(*strings.Builder)
    128 128   buf.WriteString("try dial with: ")
    129 129   buf.WriteString(socksString)
    130  - pe.dbgPrint(buf)
     130 + p5.dbgPrint(buf)
    131 131  }
    132 132   
    133  -func (pe *Swamp) msgCantGetLock(socksString string, putback bool) {
    134  - if !pe.DebugEnabled() {
     133 +func (p5 *Swamp) msgCantGetLock(socksString string, putback bool) {
     134 + if !p5.DebugEnabled() {
    135 135   return
    136 136   }
    137 137   buf := pools.CopABuffer.Get().(*strings.Builder)
    skipped 2 lines
    140 140   if putback {
    141 141   buf.WriteString(", putting back in queue")
    142 142   }
    143  - pe.dbgPrint(buf)
     143 + p5.dbgPrint(buf)
    144 144  }
    145 145   
    146  -func (pe *Swamp) msgGotLock(socksString string) {
    147  - if !pe.DebugEnabled() {
     146 +func (p5 *Swamp) msgGotLock(socksString string) {
     147 + if !p5.DebugEnabled() {
    148 148   return
    149 149   }
    150 150   buf := pools.CopABuffer.Get().(*strings.Builder)
    151 151   buf.WriteString("got lock for ")
    152 152   buf.WriteString(socksString)
    153  - pe.dbgPrint(buf)
     153 + p5.dbgPrint(buf)
    154 154  }
    155 155   
    156  -func (pe *Swamp) msgChecked(sock *Proxy, success bool) {
    157  - if !pe.DebugEnabled() {
     156 +func (p5 *Swamp) msgChecked(sock *Proxy, success bool) {
     157 + if !p5.DebugEnabled() {
    158 158   return
    159 159   }
    160 160   buf := pools.CopABuffer.Get().(*strings.Builder)
    skipped 3 lines
    164 164   buf.WriteString(" as ")
    165 165   buf.WriteString(sock.protocol.Get().String())
    166 166   buf.WriteString(" proxy")
    167  - pe.dbgPrint(buf)
     167 + p5.dbgPrint(buf)
    168 168   return
    169 169   }
    170 170   buf.WriteString("failed to verify: ")
    171 171   buf.WriteString(sock.Endpoint)
    172  - pe.dbgPrint(buf)
     172 + p5.dbgPrint(buf)
    173 173  }
    174 174   
    175  -func (pe *Swamp) msgBadProxRate(sock *Proxy) {
    176  - if !pe.DebugEnabled() {
     175 +func (p5 *Swamp) msgBadProxRate(sock *Proxy) {
     176 + if !p5.DebugEnabled() {
    177 177   return
    178 178   }
    179 179   buf := pools.CopABuffer.Get().(*strings.Builder)
    180 180   buf.WriteString("badProx ratelimited: ")
    181 181   buf.WriteString(sock.Endpoint)
    182  - pe.dbgPrint(buf)
     182 + p5.dbgPrint(buf)
    183 183  }
    184 184   
  • ■ ■ ■ ■ ■ ■
    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 *Swamp) GetStatistics() *statistics {
    14  - return pe.stats
     13 +func (p5 *Swamp) GetStatistics() *statistics {
     14 + return p5.stats
    15 15  }
    16 16   
    17 17  // RandomUserAgent retrieves a random user agent from our list in string form.
    18  -func (pe *Swamp) RandomUserAgent() string {
    19  - pe.mu.RLock()
    20  - defer pe.mu.RUnlock()
    21  - return entropy.RandomStrChoice(pe.swampopt.userAgents)
     18 +func (p5 *Swamp) RandomUserAgent() string {
     19 + p5.mu.RLock()
     20 + defer p5.mu.RUnlock()
     21 + return entropy.RandomStrChoice(p5.swampopt.userAgents)
    22 22  }
    23 23   
    24 24  // GetRandomEndpoint returns a random whatismyip style endpoint from our Swamp's options
    25  -func (pe *Swamp) GetRandomEndpoint() string {
    26  - pe.mu.RLock()
    27  - defer pe.mu.RUnlock()
    28  - return entropy.RandomStrChoice(pe.swampopt.checkEndpoints)
     25 +func (p5 *Swamp) GetRandomEndpoint() string {
     26 + p5.mu.RLock()
     27 + defer p5.mu.RUnlock()
     28 + return entropy.RandomStrChoice(p5.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 *Swamp) GetStaleTime() time.Duration {
    33  - pe.swampopt.RLock()
    34  - defer pe.swampopt.RLock()
    35  - return pe.swampopt.stale
     32 +func (p5 *Swamp) GetStaleTime() time.Duration {
     33 + p5.swampopt.RLock()
     34 + defer p5.swampopt.RLock()
     35 + return p5.swampopt.stale
    36 36  }
    37 37   
    38 38  // GetValidationTimeout returns the current value of validationTimeout.
    39  -func (pe *Swamp) GetValidationTimeout() time.Duration {
    40  - pe.swampopt.RLock()
    41  - defer pe.swampopt.RLock()
    42  - return pe.swampopt.validationTimeout
     39 +func (p5 *Swamp) GetValidationTimeout() time.Duration {
     40 + p5.swampopt.RLock()
     41 + defer p5.swampopt.RLock()
     42 + return p5.swampopt.validationTimeout
    43 43  }
    44 44   
    45 45  // GetValidationTimeoutStr returns the current value of validationTimeout (in seconds string).
    46  -func (pe *Swamp) GetValidationTimeoutStr() string {
    47  - pe.swampopt.RLock()
    48  - defer pe.swampopt.RLock()
    49  - timeout := pe.swampopt.validationTimeout
     46 +func (p5 *Swamp) GetValidationTimeoutStr() string {
     47 + p5.swampopt.RLock()
     48 + defer p5.swampopt.RLock()
     49 + timeout := p5.swampopt.validationTimeout
    50 50   return strconv.Itoa(int(timeout / time.Second))
    51 51  }
    52 52   
    53 53  // GetServerTimeout returns the current value of serverTimeout.
    54  -func (pe *Swamp) GetServerTimeout() time.Duration {
    55  - pe.swampopt.RLock()
    56  - defer pe.swampopt.RLock()
    57  - return pe.swampopt.serverTimeout
     54 +func (p5 *Swamp) GetServerTimeout() time.Duration {
     55 + p5.swampopt.RLock()
     56 + defer p5.swampopt.RLock()
     57 + return p5.swampopt.serverTimeout
    58 58  }
    59 59   
    60 60  // GetServerTimeoutStr returns the current value of serverTimeout (in seconds string).
    61  -func (pe *Swamp) GetServerTimeoutStr() string {
    62  - pe.swampopt.RLock()
    63  - defer pe.swampopt.RLock()
    64  - timeout := pe.swampopt.serverTimeout
     61 +func (p5 *Swamp) GetServerTimeoutStr() string {
     62 + p5.swampopt.RLock()
     63 + defer p5.swampopt.RLock()
     64 + timeout := p5.swampopt.serverTimeout
    65 65   if timeout == time.Duration(0) {
    66 66   return "-1"
    67 67   }
    skipped 1 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 *Swamp) GetMaxWorkers() int {
    73  - return pe.pool.Cap()
     72 +func (p5 *Swamp) GetMaxWorkers() int {
     73 + return p5.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 *Swamp) IsRunning() bool {
    78  - return atomic.LoadInt32(&pe.runningdaemons) == 2
     77 +func (p5 *Swamp) IsRunning() bool {
     78 + return atomic.LoadInt32(&p5.runningdaemons) == 2
    79 79  }
    80 80   
    81 81  // GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.
    82  -func (pe *Swamp) GetRecyclingStatus() bool {
    83  - pe.swampopt.RLock()
    84  - defer pe.swampopt.RLock()
    85  - return pe.swampopt.recycle
     82 +func (p5 *Swamp) GetRecyclingStatus() bool {
     83 + p5.swampopt.RLock()
     84 + defer p5.swampopt.RLock()
     85 + return p5.swampopt.recycle
    86 86  }
    87 87   
    88 88  // GetWorkers retrieves pond worker statistics:
    89 89  // - return MaxWorkers, RunningWorkers, IdleWorkers
    90  -func (pe *Swamp) GetWorkers() (maxWorkers, runningWorkers, idleWorkers int) {
    91  - pe.mu.RLock()
    92  - defer pe.mu.RUnlock()
    93  - return pe.pool.Cap(), pe.pool.Running(), pe.pool.Free()
     90 +func (p5 *Swamp) GetWorkers() (maxWorkers, runningWorkers, idleWorkers int) {
     91 + p5.mu.RLock()
     92 + defer p5.mu.RUnlock()
     93 + return p5.pool.Cap(), p5.pool.Running(), p5.pool.Free()
    94 94  }
    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 *Swamp) GetRemoveAfter() int {
    99  - pe.mu.RLock()
    100  - defer pe.mu.RUnlock()
    101  - if !pe.swampopt.recycle {
     98 +func (p5 *Swamp) GetRemoveAfter() int {
     99 + p5.mu.RLock()
     100 + defer p5.mu.RUnlock()
     101 + if !p5.swampopt.recycle {
    102 102   return -1
    103 103   }
    104  - return pe.swampopt.removeafter
     104 + return p5.swampopt.removeafter
    105 105  }
    106 106   
    107 107  // GetDialerBailout retrieves the dialer bailout policy. See SetDialerBailout for more info.
    108  -func (pe *Swamp) GetDialerBailout() int {
    109  - pe.mu.RLock()
    110  - defer pe.mu.RUnlock()
    111  - return pe.swampopt.dialerBailout
     108 +func (p5 *Swamp) GetDialerBailout() int {
     109 + p5.mu.RLock()
     110 + defer p5.mu.RUnlock()
     111 + return p5.swampopt.dialerBailout
    112 112  }
    113 113   
    114 114  // TODO: Document middleware concept
    115 115   
    116  -func (pe *Swamp) GetDispenseMiddleware() func(*Proxy) (*Proxy, bool) {
    117  - pe.mu.RLock()
    118  - defer pe.mu.RUnlock()
    119  - return pe.dispenseMiddleware
     116 +func (p5 *Swamp) GetDispenseMiddleware() func(*Proxy) (*Proxy, bool) {
     117 + p5.mu.RLock()
     118 + defer p5.mu.RUnlock()
     119 + return p5.dispenseMiddleware
    120 120  }
    121 121   
    122  -func (pe *Swamp) GetShuffleStatus() bool {
    123  - pe.mu.RLock()
    124  - defer pe.mu.RUnlock()
    125  - return pe.swampopt.shuffle
     122 +func (p5 *Swamp) GetShuffleStatus() bool {
     123 + p5.mu.RLock()
     124 + defer p5.mu.RUnlock()
     125 + return p5.swampopt.shuffle
    126 126  }
    127 127   
  • ■ ■ ■ ■ ■
    go.mod
    skipped 9 lines
    10 10   github.com/mattn/go-tty v0.0.4
    11 11   github.com/miekg/dns v1.1.50
    12 12   github.com/ooni/oohttp v0.3.0
     13 + github.com/panjf2000/ants/v2 v2.5.0
    13 14   github.com/refraction-networking/utls v1.1.2
    14 15   github.com/yunginnanet/Rate5 v1.1.0
    15 16   golang.org/x/net v0.0.0-20220921203646-d300de134e69
    skipped 18 lines
  • ■ ■ ■ ■ ■ ■
    go.sum
    skipped 5 lines
    6 6  git.tcp.direct/kayos/socks v0.0.0-20220828111753-f9f7cd3e7ee7/go.mod h1:KmN5oa1od8tMHmRIr9GOqWKx9MR0oGZVtAj+ARxiPwo=
    7 7  github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
    8 8  github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
     9 +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
    9 10  github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
    10 11  github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI=
    11 12  github.com/haxii/socks5 v1.0.0 h1:78BIzd4lHibdRNOKdMwKCnnsgYLW9SeotqU+nMhWSSo=
    skipped 11 lines
    23 24  github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
    24 25  github.com/ooni/oohttp v0.3.0 h1:75OsZKelkLXl6p2UD53dTJyIv+9owWqaL6sMT26LN8w=
    25 26  github.com/ooni/oohttp v0.3.0/go.mod h1:fgNDPYw+nsgEKCDBpT/4R06bgnrCRtvgNmAWOCmm4JE=
     27 +github.com/panjf2000/ants/v2 v2.5.0 h1:1rWGWSnxCsQBga+nQbA4/iY6VMeNoOIAM0ZWh9u3q2Q=
     28 +github.com/panjf2000/ants/v2 v2.5.0/go.mod h1:cU93usDlihJZ5CfRGNDYsiBYvoilLvBF5Qp/BT2GNRE=
    26 29  github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
    27 30  github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
    28 31  github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
     32 +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
    29 33  github.com/refraction-networking/utls v1.1.2 h1:a7GQauRt72VG+wtNm0lnrAaCGlyX47gEi1++dSsDBpw=
    30 34  github.com/refraction-networking/utls v1.1.2/go.mod h1:+D89TUtA8+NKVFj1IXWr0p3tSdX1+SqUB7rL0QnGqyg=
     35 +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
    31 36  github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
    32 37  github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
    33 38  github.com/yunginnanet/Rate5 v1.1.0 h1:FGp+IwKju0cTrrM3VffZGZiFgRt1jFXOWRCPwB1HPek=
    skipped 54 lines
    88 93  golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
    89 94  golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    90 95  golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
     96 +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
    91 97  inet.af/netaddr v0.0.0-20220811202034-502d2d690317 h1:U2fwK6P2EqmopP/hFLTOAjWTki0qgd4GMJn5X8wOleU=
    92 98  inet.af/netaddr v0.0.0-20220811202034-502d2d690317/go.mod h1:OIezDfdzOgFhuw4HuWapWq2e9l0H9tK4F1j+ETRtF3k=
    93 99   
  • ■ ■ ■ ■ ■ ■
    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 *Swamp) GetHTTPClient() *http.Client {
    12  - // var htp func(*http.Request) (*url.URL, error)
     11 +func (p5 *Swamp) GetHTTPClient() *http.Client {
    13 12   var dctx func(ctx context.Context, network string, addr string) (net.Conn, error)
    14  - // if httun, htok := pe.GetHTTPTunnel(); htok {
    15  - // httprox, uerr := url.Parse("http://" + httun.Endpoint)
    16  - // if uerr == nil {
    17  - // htp = http.ProxyURL(httprox)
    18  - // }
    19  - // }
    20  - // if htp == nil {
    21  - dctx = pe.DialContext
    22  - // }
     13 + dctx = p5.DialContext
    23 14   return &http.Client{
    24 15   Transport: &http.Transport{
    25 16   // Proxy: htp,
    26 17   DialContext: dctx,
    27 18   TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
    28  - TLSHandshakeTimeout: pe.GetServerTimeout(),
     19 + TLSHandshakeTimeout: p5.GetServerTimeout(),
    29 20   DisableKeepAlives: true,
    30 21   DisableCompression: false,
    31 22   MaxIdleConnsPerHost: 5,
    32  - IdleConnTimeout: pe.GetServerTimeout(),
    33  - ResponseHeaderTimeout: pe.GetServerTimeout(),
     23 + IdleConnTimeout: p5.GetServerTimeout(),
     24 + ResponseHeaderTimeout: p5.GetServerTimeout(),
    34 25   },
    35  - Timeout: pe.GetServerTimeout(),
     26 + Timeout: p5.GetServerTimeout(),
    36 27   }
    37 28  }
    38 29   
    39 30  // RoundTrip is Mr. WorldWide. Obviously. See: https://pkg.go.dev/net/http#RoundTripper
    40  -func (pe *Swamp) RoundTrip(req *http.Request) (*http.Response, error) {
    41  - return pe.GetHTTPClient().Do(req)
     31 +func (p5 *Swamp) RoundTrip(req *http.Request) (*http.Response, error) {
     32 + return p5.GetHTTPClient().Do(req)
    42 33  }
    43 34   
  • ■ ■ ■ ■
    mystery_dialer.go
    skipped 44 lines
    45 45  }
    46 46   
    47 47  func (p5 *Swamp) popSockAndLockIt(ctx context.Context) (*Proxy, error) {
    48  - sock := p5.GetAnySOCKS(false)
     48 + sock := p5.GetAnySOCKS()
    49 49   socksString := sock.String()
    50 50   select {
    51 51   case <-ctx.Done():
    skipped 61 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 *Swamp) AddUserAgents(uagents []string) {
    11  - pe.mu.Lock()
    12  - defer pe.mu.Unlock()
    13  - pe.swampopt.userAgents = append(pe.swampopt.userAgents, uagents...)
     10 +func (p5 *Swamp) AddUserAgents(uagents []string) {
     11 + p5.mu.Lock()
     12 + defer p5.mu.Unlock()
     13 + p5.swampopt.userAgents = append(p5.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 *Swamp) SetUserAgents(uagents []string) {
    18  - pe.mu.Lock()
    19  - defer pe.mu.Unlock()
    20  - pe.swampopt.userAgents = uagents
     17 +func (p5 *Swamp) SetUserAgents(uagents []string) {
     18 + p5.mu.Lock()
     19 + defer p5.mu.Unlock()
     20 + p5.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 *Swamp) SetCheckEndpoints(newendpoints []string) {
    25  - pe.mu.Lock()
    26  - defer pe.mu.Unlock()
    27  - pe.swampopt.checkEndpoints = newendpoints
     24 +func (p5 *Swamp) SetCheckEndpoints(newendpoints []string) {
     25 + p5.mu.Lock()
     26 + defer p5.mu.Unlock()
     27 + p5.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 *Swamp) AddCheckEndpoints(endpoints []string) {
    32  - pe.mu.Lock()
    33  - defer pe.mu.Unlock()
    34  - pe.swampopt.checkEndpoints = append(pe.swampopt.checkEndpoints, endpoints...)
     31 +func (p5 *Swamp) AddCheckEndpoints(endpoints []string) {
     32 + p5.mu.Lock()
     33 + defer p5.mu.Unlock()
     34 + p5.swampopt.checkEndpoints = append(p5.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 *Swamp) SetStaleTime(newtime time.Duration) {
    39  - pe.swampopt.Lock()
    40  - defer pe.swampopt.Unlock()
    41  - pe.swampopt.stale = newtime
     38 +func (p5 *Swamp) SetStaleTime(newtime time.Duration) {
     39 + p5.swampopt.Lock()
     40 + defer p5.swampopt.Unlock()
     41 + p5.swampopt.stale = newtime
    42 42  }
    43 43   
    44 44  // SetValidationTimeout sets the validationTimeout option.
    45  -func (pe *Swamp) SetValidationTimeout(timeout time.Duration) {
    46  - pe.swampopt.Lock()
    47  - defer pe.swampopt.Unlock()
    48  - pe.swampopt.validationTimeout = timeout
     45 +func (p5 *Swamp) SetValidationTimeout(timeout time.Duration) {
     46 + p5.swampopt.Lock()
     47 + defer p5.swampopt.Unlock()
     48 + p5.swampopt.validationTimeout = timeout
    49 49  }
    50 50   
    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 *Swamp) SetServerTimeout(timeout time.Duration) {
    55  - pe.swampopt.Lock()
    56  - defer pe.swampopt.Unlock()
    57  - pe.swampopt.serverTimeout = timeout
     54 +func (p5 *Swamp) SetServerTimeout(timeout time.Duration) {
     55 + p5.swampopt.Lock()
     56 + defer p5.swampopt.Unlock()
     57 + p5.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 *Swamp) SetMaxWorkers(num int) {
    62  - pe.pool.Tune(num)
     61 +func (p5 *Swamp) SetMaxWorkers(num int) {
     62 + p5.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 *Swamp) EnableRecycling() {
    67  - pe.swampopt.Lock()
    68  - defer pe.swampopt.Unlock()
    69  - pe.swampopt.recycle = true
     66 +func (p5 *Swamp) EnableRecycling() {
     67 + p5.swampopt.Lock()
     68 + defer p5.swampopt.Unlock()
     69 + p5.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 *Swamp) DisableRecycling() {
    74  - pe.swampopt.Lock()
    75  - defer pe.swampopt.Unlock()
    76  - pe.swampopt.recycle = false
     73 +func (p5 *Swamp) DisableRecycling() {
     74 + p5.swampopt.Lock()
     75 + defer p5.swampopt.Unlock()
     76 + p5.swampopt.recycle = false
    77 77  }
    78 78   
    79 79  // SetRemoveAfter sets the removeafter policy, the amount of times a recycled proxy is marked as bad before it is removed entirely.
    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 *Swamp) SetRemoveAfter(timesfailed int) {
    84  - pe.swampopt.Lock()
    85  - defer pe.swampopt.Unlock()
    86  - pe.swampopt.removeafter = timesfailed
     83 +func (p5 *Swamp) SetRemoveAfter(timesfailed int) {
     84 + p5.swampopt.Lock()
     85 + defer p5.swampopt.Unlock()
     86 + p5.swampopt.removeafter = timesfailed
    87 87  }
    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 *Swamp) SetDialerBailout(dialattempts int) {
    92  - pe.swampopt.Lock()
    93  - defer pe.swampopt.Unlock()
    94  - pe.swampopt.dialerBailout = dialattempts
     91 +func (p5 *Swamp) SetDialerBailout(dialattempts int) {
     92 + p5.swampopt.Lock()
     93 + defer p5.swampopt.Unlock()
     94 + p5.swampopt.dialerBailout = dialattempts
    95 95  }
    96 96   
    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 *Swamp) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) {
    101  - pe.mu.Lock()
    102  - defer pe.mu.Unlock()
    103  - pe.dispenseMiddleware = f
     100 +func (p5 *Swamp) SetDispenseMiddleware(f func(*Proxy) (*Proxy, bool)) {
     101 + p5.mu.Lock()
     102 + defer p5.mu.Unlock()
     103 + p5.dispenseMiddleware = f
    104 104  }
    105 105   
    106 106  // SetDebugLogger sets the debug logger for the Swamp. See the Logger interface for implementation details.
    107  -func (pe *Swamp) SetDebugLogger(l logger.Logger) {
     107 +func (p5 *Swamp) SetDebugLogger(l logger.Logger) {
    108 108   debugHardLock.Lock()
    109  - pe.mu.Lock()
    110  - pe.DebugLogger = l
    111  - pe.mu.Unlock()
     109 + p5.mu.Lock()
     110 + p5.DebugLogger = l
     111 + p5.mu.Unlock()
    112 112   debugHardLock.Unlock()
    113 113  }
    114 114   
    115  -func (pe *Swamp) SetShuffle(shuffle bool) {
    116  - pe.mu.Lock()
    117  - defer pe.mu.Unlock()
    118  - pe.swampopt.shuffle = shuffle
     115 +func (p5 *Swamp) SetShuffle(shuffle bool) {
     116 + p5.mu.Lock()
     117 + defer p5.mu.Unlock()
     118 + p5.swampopt.shuffle = shuffle
    119 119  }
    120 120   
  • ■ ■ ■ ■ ■ ■
    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 *Swamp) StartSOCKS5Server(listen, username, password string) error {
     27 +func (p5 *Swamp) StartSOCKS5Server(listen, username, password string) error {
    28 28   
    29 29   conf := &socks5.Config{
    30 30   Credentials: socksCreds{username: username, password: password},
    31  - Logger: pe.DebugLogger,
    32  - Dial: pe.MysteryDialer,
     31 + Logger: p5.DebugLogger,
     32 + Dial: p5.MysteryDialer,
    33 33   // Resolver: pe.MysteryResolver,
    34 34   }
    35 35   
    36 36   buf := pools.CopABuffer.Get().(*strings.Builder)
    37 37   buf.WriteString("listening for SOCKS5 connections on ")
    38 38   buf.WriteString(listen)
    39  - pe.dbgPrint(buf)
     39 + p5.dbgPrint(buf)
    40 40   
    41 41   server, err := socks5.New(conf)
    42 42   if err != nil {
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    stats.go
    skipped 48 lines
    49 49  }
    50 50   
    51 51  // GetTotalValidated retrieves our grand total validated proxy count.
    52  -func (pe *Swamp) GetTotalValidated() int {
    53  - stats := pe.GetStatistics()
     52 +func (p5 *Swamp) GetTotalValidated() int {
     53 + stats := p5.GetStatistics()
    54 54   return int(stats.Valid4a + stats.Valid4 + stats.Valid5 + stats.ValidHTTP)
    55 55  }
    56 56   
    skipped 5 lines
  • ■ ■ ■ ■ ■ ■
    validator_engine.go
    skipped 17 lines
    18 18   "git.tcp.direct/kayos/prox5/internal/pools"
    19 19  )
    20 20   
    21  -func (pe *Swamp) prepHTTP() (*http.Client, *http.Transport, *http.Request, error) {
    22  - req, err := http.NewRequest("GET", pe.GetRandomEndpoint(), bytes.NewBuffer([]byte("")))
     21 +func (p5 *Swamp) prepHTTP() (*http.Client, *http.Transport, *http.Request, error) {
     22 + req, err := http.NewRequest("GET", p5.GetRandomEndpoint(), bytes.NewBuffer([]byte("")))
    23 23   if err != nil {
    24 24   return nil, nil, nil, err
    25 25   }
    26 26   headers := make(map[string]string)
    27  - headers["User-Agent"] = pe.RandomUserAgent()
     27 + headers["User-Agent"] = p5.RandomUserAgent()
    28 28   headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
    29 29   headers["Accept-Language"] = "en-US,en;q=0.5"
    30 30   headers["'Accept-Encoding'"] = "gzip, deflate, br"
    skipped 5 lines
    36 36   var transporter = &http.Transport{
    37 37   DisableKeepAlives: true,
    38 38   TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
    39  - TLSHandshakeTimeout: pe.GetValidationTimeout(),
     39 + TLSHandshakeTimeout: p5.GetValidationTimeout(),
    40 40   }
    41 41   
    42 42   return client, transporter, req, err
    skipped 8 lines
    51 51   sock.lastValidated = time.Now()
    52 52  }
    53 53   
    54  -func (pe *Swamp) bakeHTTP(hmd *HandMeDown) (client *http.Client, req *http.Request, err error) {
     54 +func (p5 *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("://")
    58 58   builder.WriteString(hmd.sock.Endpoint)
    59 59   builder.WriteString("/?timeout=")
    60  - builder.WriteString(pe.GetValidationTimeoutStr())
     60 + builder.WriteString(p5.GetValidationTimeoutStr())
    61 61   builder.WriteString("s")
    62 62   dialSocks := socks.DialWithConn(builder.String(), hmd.conn)
    63 63   pools.DiscardBuffer(builder)
    skipped 3 lines
    67 67   transport *http.Transport
    68 68   )
    69 69   
    70  - if client, transport, req, err = pe.prepHTTP(); err != nil {
     70 + if client, transport, req, err = p5.prepHTTP(); err != nil {
    71 71   return
    72 72   }
    73 73   
    skipped 9 lines
    83 83   return
    84 84  }
    85 85   
    86  -func (pe *Swamp) validate(hmd *HandMeDown) (string, error) {
     86 +func (p5 *Swamp) validate(hmd *HandMeDown) (string, error) {
    87 87   var (
    88 88   client *http.Client
    89 89   req *http.Request
    90 90   err error
    91 91   )
    92 92   
    93  - client, req, err = pe.bakeHTTP(hmd)
     93 + client, req, err = p5.bakeHTTP(hmd)
    94 94   if err != nil {
    95 95   return "", err
    96 96   }
    skipped 8 lines
    105 105   return string(rbody), err
    106 106  }
    107 107   
    108  -func (pe *Swamp) anothaOne() {
    109  - pe.stats.Checked++
     108 +func (p5 *Swamp) anothaOne() {
     109 + p5.stats.Checked++
    110 110  }
    111 111   
    112 112  type HandMeDown struct {
    skipped 13 lines
    126 126   return hmd.conn, nil
    127 127  }
    128 128   
    129  -func (pe *Swamp) singleProxyCheck(sock *Proxy, protocol ProxyProtocol) error {
    130  - defer pe.anothaOne()
     129 +func (p5 *Swamp) singleProxyCheck(sock *Proxy, protocol ProxyProtocol) error {
     130 + defer p5.anothaOne()
    131 131   split := strings.Split(sock.Endpoint, "@")
    132 132   endpoint := split[0]
    133 133   if len(split) == 2 {
    134 134   endpoint = split[1]
    135 135   }
    136  - conn, err := net.DialTimeout("tcp", endpoint, pe.GetValidationTimeout())
     136 + conn, err := net.DialTimeout("tcp", endpoint, p5.GetValidationTimeout())
    137 137   if err != nil {
    138 138   return err
    139 139   }
    140 140   
    141 141   hmd := &HandMeDown{sock: sock, conn: conn, under: proxy.Direct, protoCheck: protocol}
    142 142   
    143  - resp, err := pe.validate(hmd)
     143 + resp, err := p5.validate(hmd)
    144 144   if err != nil {
    145  - pe.badProx.Check(sock)
     145 + p5.badProx.Check(sock)
    146 146   return err
    147 147   }
    148 148   
    149 149   if newip := net.ParseIP(resp); newip == nil {
    150  - pe.badProx.Check(sock)
     150 + p5.badProx.Check(sock)
    151 151   return errors.New("bad response from http request: " + resp)
    152 152   }
    153 153   
    skipped 59 lines
    213 213   pe.tally(sock)
    214 214  }
    215 215   
    216  -func (pe *Swamp) tally(sock *Proxy) {
     216 +func (p5 *Swamp) tally(sock *Proxy) {
    217 217   switch sock.protocol.Get() {
    218 218   case ProtoSOCKS4:
    219  - pe.stats.v4()
    220  - pe.Valids.SOCKS4 <- sock
     219 + p5.stats.v4()
     220 + p5.Valids.SOCKS4 <- sock
    221 221   case ProtoSOCKS4a:
    222  - pe.stats.v4a()
    223  - pe.Valids.SOCKS4a <- sock
     222 + p5.stats.v4a()
     223 + p5.Valids.SOCKS4a <- sock
    224 224   case ProtoSOCKS5:
    225  - pe.stats.v5()
    226  - pe.Valids.SOCKS5 <- sock
     225 + p5.stats.v5()
     226 + p5.Valids.SOCKS5 <- sock
    227 227   case ProtoHTTP:
    228  - pe.stats.http()
    229  - pe.Valids.HTTP <- sock
     228 + p5.stats.http()
     229 + p5.Valids.HTTP <- sock
    230 230   default:
    231 231   return
    232 232   }
    skipped 2 lines
Please wait...
Page is in error, reload to recover