Projects STRLCPY prox5 Commits 033d14bb
🤬
  • ■ ■ ■ ■ ■ ■
    daemons.go
    skipped 93 lines
    94 94   } else {
    95 95   pe.Pending <- p
    96 96   }
     97 + default:
     98 + pe.recycling()
    97 99   }
    98 100   }
    99 101   }()
    skipped 20 lines
    120 122   return 0
    121 123   case pe.Pending <- sock:
    122 124   count++
     125 + default:
     126 + continue
    123 127   }
    124 128   }
    125 129   
    skipped 41 lines
  • ■ ■ ■ ■ ■ ■
    defs.go
    skipped 58 lines
    59 59  }
    60 60   
    61 61  var (
    62  - defaultStaleTime = 1 * time.Hour
    63  - defaultWorkerCount = 50
    64  - defaultBailout = 15
     62 + defaultStaleTime = 30 * time.Minute
     63 + defaultWorkerCount = 20
     64 + defaultBailout = 20
    65 65   defaultRemoveAfter = 25
    66 66   // Note: I've chosen to use https here exclusively assuring all validated proxies are SSL capable.
    67 67   defaultChecks = []string{
    skipped 25 lines
    93 93   maxWorkers: defaultWorkerCount,
    94 94   redact: true,
    95 95   }
    96  - sm.validationTimeout = time.Duration(12) * time.Second
     96 + sm.validationTimeout = time.Duration(18) * time.Second
    97 97   sm.serverTimeout = time.Duration(180) * time.Second
    98 98   return sm
    99 99  }
    skipped 56 lines
    156 156   
    157 157   chans := []*chan *Proxy{&pe.Valids.SOCKS5, &pe.Valids.SOCKS4, &pe.Valids.SOCKS4a, &pe.Valids.HTTP, &pe.Pending}
    158 158   for _, c := range chans {
    159  - *c = make(chan *Proxy, 250)
     159 + *c = make(chan *Proxy, 500)
    160 160   }
    161 161   
    162 162   pe.dispenseMiddleware = func(p *Proxy) (*Proxy, bool) {
    skipped 65 lines
  • ■ ■ ■ ■ ■ ■
    dispense.go
    skipped 4 lines
    5 5   "sync/atomic"
    6 6   "time"
    7 7   
    8  - "git.tcp.direct/kayos/common/entropy"
    9  - 
    10 8   "git.tcp.direct/kayos/prox5/internal/pools"
    11 9  )
    12 10   
    skipped 8 lines
    21 19   }
    22 20   pe.stats.dispense()
    23 21   return sock.Endpoint
     22 + default:
     23 + pe.recycling()
    24 24   }
    25 25   }
    26 26  }
    skipped 9 lines
    36 36   continue
    37 37   }
    38 38   return sock.Endpoint
     39 + default:
     40 + pe.recycling()
    39 41   }
    40 42   }
    41 43  }
    skipped 9 lines
    51 53   continue
    52 54   }
    53 55   return sock.Endpoint
     56 + default:
     57 + pe.recycling()
    54 58   }
    55 59   }
    56 60  }
    skipped 26 lines
    83 87   case sock = <-pe.Valids.SOCKS5:
    84 88   break
    85 89   default:
    86  - if !acceptHTTP {
    87  - continue
    88  - }
    89  - if httptun, htok := pe.GetHTTPTunnel(); htok {
    90  - sock = httptun
    91  - break
    92  - }
     90 + pe.recycling()
    93 91   }
    94 92   if pe.stillGood(sock) {
    95 93   return sock
    skipped 3 lines
    99 97  }
    100 98   
    101 99  func (pe *ProxyEngine) stillGood(sock *Proxy) bool {
    102  - for !atomic.CompareAndSwapUint32(&sock.lock, stateUnlocked, stateLocked) {
    103  - entropy.RandSleepMS(200)
     100 + if sock == nil {
     101 + return false
     102 + }
     103 + if !atomic.CompareAndSwapUint32(&sock.lock, stateUnlocked, stateLocked) {
     104 + return false
    104 105   }
    105 106   defer atomic.StoreUint32(&sock.lock, stateUnlocked)
    106 107   
    skipped 30 lines
  • ■ ■ ■ ■ ■ ■
    validator_engine.go
    skipped 159 lines
    160 160  var protoMap = map[ProxyProtocol]string{
    161 161   ProtoSOCKS4: "4", ProtoSOCKS4a: "4a",
    162 162   ProtoSOCKS5: "5", ProtoHTTP: "http",
    163  - ProtoSOCKS5h: "5h",
     163 + ProtoSOCKS5h: "5h", protoNULL: "null",
    164 164  }
    165 165   
    166 166  func getProtoStr(protocol ProxyProtocol) string {
    skipped 4 lines
    171 171  }
    172 172   
    173 173  func (sock *Proxy) validate() {
    174  - atomic.StoreUint32(&sock.lock, stateLocked)
     174 + if !atomic.CompareAndSwapUint32(&sock.lock, stateUnlocked, stateLocked) {
     175 + return
     176 + }
    175 177   defer atomic.StoreUint32(&sock.lock, stateUnlocked)
    176 178   
    177 179   pe := sock.parent
    skipped 10 lines
    188 190   
    189 191   // TODO: consider giving the option for verbose logging of this stuff?
    190 192   
    191  - // try to use the proxy with all 3 SOCKS versions
    192  - for proto := range protoMap {
    193  - select {
    194  - case <-pe.ctx.Done():
    195  - return
    196  - default:
    197  - sock.proto = proto
    198  - if err := pe.singleProxyCheck(sock); err != nil {
    199  - // if the proxy is no good, we continue on to the next.
    200  - continue
     193 + if sock.timesValidated == 0 || sock.proto == protoNULL {
     194 + // try to use the proxy with all 3 SOCKS versions
     195 + for proto := range protoMap {
     196 + select {
     197 + case <-pe.ctx.Done():
     198 + return
     199 + default:
     200 + sock.proto = proto
     201 + if err := pe.singleProxyCheck(sock); err != nil {
     202 + // if the proxy is no good, we continue on to the next.
     203 + continue
     204 + }
     205 + break
    201 206   }
    202  - break
     207 + }
     208 + } else {
     209 + if err := pe.singleProxyCheck(sock); err != nil {
     210 + sock.bad()
     211 + pe.badProx.Check(sock)
     212 + return
    203 213   }
    204 214   }
    205 215   
    skipped 33 lines
Please wait...
Page is in error, reload to recover