Major performance fixup
This commit is contained in:
parent
a7656607c6
commit
1a47b4e181
|
@ -1,4 +1,3 @@
|
|||
/example/proxies.txt
|
||||
/example/socks.list
|
||||
/example/socksold.list
|
||||
.idea/
|
||||
*.txt
|
||||
*.list
|
||||
|
|
26
conductor.go
26
conductor.go
|
@ -1,6 +1,9 @@
|
|||
package prox5
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// SwampStatus represents the current state of our Swamp.
|
||||
type SwampStatus uint32
|
||||
|
@ -17,13 +20,9 @@ const (
|
|||
// Start starts our proxy pool operations. Trying to start a running Swamp will return an error.
|
||||
func (s *Swamp) Start() error {
|
||||
if s.Status.Load().(SwampStatus) != New {
|
||||
return errors.New("this swamp is not new, use resume if it is paused")
|
||||
return s.Resume()
|
||||
}
|
||||
|
||||
s.runningdaemons.Store(0)
|
||||
|
||||
s.getThisDread()
|
||||
|
||||
s.startDaemons()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -41,16 +40,16 @@ func (s *Swamp) Pause() error {
|
|||
|
||||
s.dbgPrint("pausing...")
|
||||
|
||||
s.svcDown()
|
||||
s.svcDown()
|
||||
s.quit()
|
||||
|
||||
s.Status.Store(Paused)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Swamp) getThisDread() {
|
||||
func (s *Swamp) startDaemons() {
|
||||
go s.mapBuilder()
|
||||
<-s.conductor
|
||||
s.svcUp()
|
||||
go s.jobSpawner()
|
||||
|
||||
for {
|
||||
|
@ -64,10 +63,9 @@ func (s *Swamp) getThisDread() {
|
|||
// Resume will resume pause proxy pool operations, attempting to resume a running Swamp is returns an error.
|
||||
func (s *Swamp) Resume() error {
|
||||
if s.IsRunning() {
|
||||
return errors.New("not paused")
|
||||
return errors.New("already running")
|
||||
}
|
||||
|
||||
s.getThisDread()
|
||||
|
||||
s.ctx, s.quit = context.WithCancel(context.Background())
|
||||
s.startDaemons()
|
||||
return nil
|
||||
}
|
||||
|
|
36
daemons.go
36
daemons.go
|
@ -4,18 +4,16 @@ import (
|
|||
"errors"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *Swamp) svcUp() {
|
||||
running := s.runningdaemons.Load().(int)
|
||||
s.runningdaemons.Store(running + 1)
|
||||
atomic.AddInt32(&s.runningdaemons, 1)
|
||||
}
|
||||
|
||||
func (s *Swamp) svcDown() {
|
||||
running := s.runningdaemons.Load().(int)
|
||||
s.quit <- true
|
||||
s.runningdaemons.Store(running - 1)
|
||||
atomic.AddInt32(&s.runningdaemons, -1)
|
||||
}
|
||||
|
||||
type swampMap struct {
|
||||
|
@ -66,32 +64,35 @@ func (sm swampMap) delete(sock string) error {
|
|||
func (sm swampMap) clear() {
|
||||
sm.mu.Lock()
|
||||
defer sm.mu.Unlock()
|
||||
|
||||
sm.plot = make(map[string]*Proxy)
|
||||
for key := range sm.plot {
|
||||
delete(sm.plot, key)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Swamp) mapBuilder() {
|
||||
if s.pool.IsClosed() {
|
||||
s.pool.Reboot()
|
||||
}
|
||||
|
||||
s.dbgPrint("map builder started")
|
||||
defer s.dbgPrint("map builder paused")
|
||||
|
||||
go func() {
|
||||
defer s.dbgPrint("map builder paused")
|
||||
for {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
s.svcDown()
|
||||
return
|
||||
case in := <-inChan:
|
||||
if p, ok := s.swampmap.add(in); !ok {
|
||||
continue
|
||||
} else {
|
||||
s.Pending <- p
|
||||
}
|
||||
default:
|
||||
time.Sleep(25 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
}()
|
||||
s.conductor <- true
|
||||
s.svcUp()
|
||||
<-s.quit
|
||||
}
|
||||
|
||||
func (s *Swamp) recycling() int {
|
||||
|
@ -102,6 +103,7 @@ func (s *Swamp) recycling() int {
|
|||
if len(s.swampmap.plot) < 1 {
|
||||
return 0
|
||||
}
|
||||
|
||||
var count int
|
||||
|
||||
s.swampmap.mu.RLock()
|
||||
|
@ -109,15 +111,13 @@ func (s *Swamp) recycling() int {
|
|||
|
||||
for _, sock := range s.swampmap.plot {
|
||||
select {
|
||||
case <-s.ctx.Done():
|
||||
return 0
|
||||
case s.Pending <- sock:
|
||||
count++
|
||||
default:
|
||||
time.Sleep(25 * time.Millisecond)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,7 @@ func (s *Swamp) jobSpawner() {
|
|||
if s.pool.IsClosed() {
|
||||
s.pool.Reboot()
|
||||
}
|
||||
|
||||
s.dbgPrint("job spawner started")
|
||||
defer s.dbgPrint("job spawner paused")
|
||||
|
||||
|
@ -133,8 +134,9 @@ func (s *Swamp) jobSpawner() {
|
|||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-s.quit:
|
||||
case <-s.ctx.Done():
|
||||
q <- true
|
||||
s.svcDown()
|
||||
return
|
||||
case sock := <-s.Pending:
|
||||
if err := s.pool.Submit(sock.validate); err != nil {
|
||||
|
|
13
defs.go
13
defs.go
|
@ -1,6 +1,7 @@
|
|||
package prox5
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
@ -37,16 +38,17 @@ type Swamp struct {
|
|||
|
||||
socks5ServerAuth socksCreds
|
||||
|
||||
quit chan bool
|
||||
ctx context.Context
|
||||
quit context.CancelFunc
|
||||
|
||||
swampmap swampMap
|
||||
|
||||
reaper sync.Pool
|
||||
// reaper sync.Pool
|
||||
|
||||
mu *sync.RWMutex
|
||||
pool *ants.Pool
|
||||
swampopt *swampOptions
|
||||
runningdaemons atomic.Value
|
||||
runningdaemons int32
|
||||
conductor chan bool
|
||||
}
|
||||
|
||||
|
@ -210,12 +212,13 @@ func NewDefaultSwamp() *Swamp {
|
|||
|
||||
swampopt: defOpt(),
|
||||
|
||||
quit: make(chan bool),
|
||||
conductor: make(chan bool),
|
||||
mu: &sync.RWMutex{},
|
||||
Status: atomic.Value{},
|
||||
}
|
||||
|
||||
s.ctx, s.quit = context.WithCancel(context.Background())
|
||||
|
||||
s.Status.Store(New)
|
||||
|
||||
s.swampmap = swampMap{
|
||||
|
@ -226,7 +229,7 @@ func NewDefaultSwamp() *Swamp {
|
|||
|
||||
s.socksServerLogger = socksLogger{parent: s}
|
||||
|
||||
s.runningdaemons.Store(0)
|
||||
atomic.StoreInt32(&s.runningdaemons, 0)
|
||||
|
||||
s.useProx = rl.NewCustomLimiter(s.swampopt.useProxConfig)
|
||||
s.badProx = rl.NewCustomLimiter(s.swampopt.badProxConfig)
|
||||
|
|
|
@ -2,6 +2,7 @@ package prox5
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -67,10 +68,7 @@ func (s *Swamp) GetMaxWorkers() int {
|
|||
|
||||
// IsRunning returns true if our background goroutines defined in daemons.go are currently operational
|
||||
func (s *Swamp) IsRunning() bool {
|
||||
if s.runningdaemons.Load() == nil {
|
||||
return false
|
||||
}
|
||||
return s.runningdaemons.Load().(int) > 0
|
||||
return atomic.LoadInt32(&s.runningdaemons) == 2
|
||||
}
|
||||
|
||||
// GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.
|
||||
|
|
16
go.mod
16
go.mod
|
@ -1,25 +1,27 @@
|
|||
module git.tcp.direct/kayos/prox5
|
||||
|
||||
go 1.17
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
git.tcp.direct/kayos/common v0.5.4
|
||||
git.tcp.direct/kayos/go-socks5 v1.0.1
|
||||
github.com/mattn/go-tty v0.0.4
|
||||
github.com/miekg/dns v1.1.48
|
||||
github.com/miekg/dns v1.1.49
|
||||
github.com/panjf2000/ants/v2 v2.5.0
|
||||
github.com/yunginnanet/Rate5 v0.4.4
|
||||
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b
|
||||
golang.org/x/net v0.0.0-20220526153639-5463443f8c37
|
||||
h12.io/socks v1.0.3
|
||||
inet.af/netaddr v0.0.0-20210903134321-85fa6c94624e
|
||||
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/mattn/go-isatty v0.0.10 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
|
||||
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
|
||||
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect
|
||||
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 // indirect
|
||||
golang.org/x/mod v0.4.2 // indirect
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
|
||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
nullprogram.com/x/rng v1.1.0 // indirect
|
||||
)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
git.tcp.direct/kayos/common v0.5.4 h1:VCh9hp/YQbSRUarEJnzzzFWxgBbnT5qdrnVZNjMFBLE=
|
||||
git.tcp.direct/kayos/common v0.5.4/go.mod h1:2PenBSSXY/kw0iO7ngPgowlU3OA9vak1obTJlxkO5nk=
|
||||
git.tcp.direct/kayos/go-socks5 v1.0.1 h1:Pe9PlSXofibIJyWkrr9rwWcgyfUxSdUcDCQ//6fAi0U=
|
||||
git.tcp.direct/kayos/go-socks5 v1.0.1/go.mod h1:I9xU/uzFAZKukMJgEgWPrfC6rDlcPQe8wXMibF3qvhE=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
|
||||
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI=
|
||||
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-tty v0.0.4 h1:NVikla9X8MN0SQAqCYzpGyXv0jY7MNl3HOWD2dkle7E=
|
||||
github.com/mattn/go-tty v0.0.4/go.mod h1:u5GGXBtZU6RQoKV8gY5W6UhMudbR5vXnUe7j3pxse28=
|
||||
github.com/miekg/dns v1.1.49 h1:qe0mQU3Z/XpFeE+AEBo2rqaS1IPBJ3anmqZ4XiZJVG8=
|
||||
github.com/miekg/dns v1.1.49/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
|
||||
github.com/panjf2000/ants/v2 v2.5.0 h1:1rWGWSnxCsQBga+nQbA4/iY6VMeNoOIAM0ZWh9u3q2Q=
|
||||
github.com/panjf2000/ants/v2 v2.5.0/go.mod h1:cU93usDlihJZ5CfRGNDYsiBYvoilLvBF5Qp/BT2GNRE=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
|
||||
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yunginnanet/Rate5 v0.4.4 h1:NkQcBK6wD9RQ6AQ/rv+Cp4LasZlB38AkHnrN3X3tHF8=
|
||||
github.com/yunginnanet/Rate5 v0.4.4/go.mod h1:aaaV1FLFmdBk1AD7uGQF53hgfPQg9yfBmIfDxtJuYZs=
|
||||
go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE=
|
||||
go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA=
|
||||
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 h1:Tx9kY6yUkLge/pFG7IEMwDZy6CS2ajFc9TvQdPCW0uA=
|
||||
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 h1:lUkvobShwKsOesNfWWlCS5q7fnbG1MEliIzwu886fn8=
|
||||
golang.org/x/net v0.0.0-20220526153639-5463443f8c37/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2 h1:BonxutuHCTL0rBDnZlKjpGIQFTjyUVTexFOdWkB6Fg0=
|
||||
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
||||
h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo=
|
||||
h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck=
|
||||
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 h1:acCzuUSQ79tGsM/O50VRFySfMm19IoMKL+sZztZkCxw=
|
||||
inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6/go.mod h1:y3MGhcFMlh0KZPMuXXow8mpjxxAk3yoDNsp4cQz54i8=
|
||||
nullprogram.com/x/rng v1.1.0 h1:SMU7DHaQSWtKJNTpNFIFt8Wd/KSmOuSDPXrMFp/UMro=
|
||||
nullprogram.com/x/rng v1.1.0/go.mod h1:glGw6V87vyfawxCzqOABL3WfL95G65az9Z2JZCylCkg=
|
4
stats.go
4
stats.go
|
@ -51,8 +51,8 @@ func (stats *Statistics) http() {
|
|||
}
|
||||
|
||||
// GetTotalValidated retrieves our grand total validated proxy count.
|
||||
func (p *Swamp) GetTotalValidated() int {
|
||||
return p.Stats.Valid4a + p.Stats.Valid4 + p.Stats.Valid5 + p.Stats.ValidHTTP
|
||||
func (s *Swamp) GetTotalValidated() int {
|
||||
return s.Stats.Valid4a + s.Stats.Valid4 + s.Stats.Valid5 + s.Stats.ValidHTTP
|
||||
}
|
||||
|
||||
// GetUptime returns the total lifetime duration of our pool.
|
||||
|
|
19
util.go
19
util.go
|
@ -1,8 +1,7 @@
|
|||
package prox5
|
||||
|
||||
import (
|
||||
quiccmaffs "math/rand"
|
||||
"time"
|
||||
"git.tcp.direct/kayos/common/entropy"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -14,21 +13,9 @@ const (
|
|||
|
||||
// randStrChoice returns a random element from the given string slice.
|
||||
func randStrChoice(choices []string) string {
|
||||
strlen := len(choices)
|
||||
n := uint32(0)
|
||||
if strlen > 0 {
|
||||
n = getRandomUint32() % uint32(strlen)
|
||||
}
|
||||
return choices[n]
|
||||
}
|
||||
|
||||
// getRandomUint32 retrieves a random integer seeded by the current time.
|
||||
func getRandomUint32() uint32 {
|
||||
quiccmaffs.Seed(time.Now().UnixNano())
|
||||
return quiccmaffs.Uint32()
|
||||
return entropy.RandomStrChoice(choices)
|
||||
}
|
||||
|
||||
func randSleep() {
|
||||
quiccmaffs.Seed(time.Now().UnixNano())
|
||||
time.Sleep(time.Duration(quiccmaffs.Intn(200)) * time.Millisecond)
|
||||
entropy.RandSleepMS(200)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue