GOTTA GO FAST
This commit is contained in:
förälder
5a8059b5a2
incheckning
431c3b0f19
|
@ -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()
|
||||
|
|
6
debug.go
6
debug.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
11
stats.go
11
stats.go
|
@ -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++
|
||||
}
|
||||
|
||||
|
|
Laddar…
Referens i nytt ärende