GOTTA GO FAST

This commit is contained in:
kayos@tcp.direct 2021-09-20 05:29:28 -07:00
förälder 5a8059b5a2
incheckning 431c3b0f19
4 ändrade filer med 6 tillägg och 21 borttagningar

Visa fil

@ -25,20 +25,21 @@ Pause will cease the creation of any new proxy validation operations.
* Options may be changed and proxy lists may be loaded when paused.
* Pausing an already paused Swamp is a nonop.
*/
func (s *Swamp) Pause() {
func (s *Swamp) Pause() error {
if s.Status == Paused {
return
return errors.New("already paused")
}
for n := 2; n > 0; n-- {
s.quit <- true
}
s.Status = Paused
return nil
}
// Resume will resume pause proxy pool operations, attempting to resume a running Swamp is a non-op.
func (s *Swamp) Resume() error {
if s.IsRunning() {
return errors.New("already running")
if s.Status != Paused {
return errors.New("not paused")
}
s.Status = Running
go s.mapBuilder()

Visa fil

@ -18,8 +18,6 @@ func init() {
// This will alter the flow of debug messages, they will no longer print to console, they will be pushed into this channel.
// Make sure you pull from the channel eventually to avoid build up of blocked goroutines.
func (s *Swamp) DebugChannel() chan string {
debugMutex.Lock()
defer debugMutex.Unlock()
debugChan = make(chan string, 1000)
useDebugChannel = true
return debugChan
@ -27,8 +25,6 @@ func (s *Swamp) DebugChannel() chan string {
// DebugEnabled returns the current state of our debug switch
func (s *Swamp) DebugEnabled() bool {
debugMutex.RLock()
defer debugMutex.RUnlock()
return s.swampopt.debug
}
@ -56,8 +52,6 @@ func (s *Swamp) DisableDebug() {
}
func (s *Swamp) dbgPrint(str string) {
debugMutex.RLock()
defer debugMutex.RUnlock()
if !s.swampopt.debug {
return
}

Visa fil

@ -105,7 +105,6 @@ func (s *Swamp) GetAnySOCKS() Proxy {
}
func (s *Swamp) stillGood(sock *Proxy) bool {
if !atomic.CompareAndSwapUint32(&sock.lock, stateUnlocked, stateLocked) {
return false
}

Visa fil

@ -27,32 +27,23 @@ type Statistics struct {
}
func (stats *Statistics) dispense() {
stats.mu.Lock()
defer stats.mu.Unlock()
stats.Dispensed++
}
func (stats *Statistics) stale() {
stats.mu.Lock()
defer stats.mu.Unlock()
stats.Stale++
}
func (stats *Statistics) v4() {
stats.mu.Lock()
defer stats.mu.Unlock()
stats.Valid4++
}
func (stats *Statistics) v4a() {
stats.mu.Lock()
defer stats.mu.Unlock()
stats.Valid4a++
}
func (stats *Statistics) v5() {
stats.mu.Lock()
defer stats.mu.Unlock()
stats.Valid5++
}