2021-09-13 08:30:49 +00:00
|
|
|
package pxndscvm
|
|
|
|
|
2021-09-13 16:01:19 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2021-09-13 09:37:59 +00:00
|
|
|
|
|
|
|
// RandomUserAgent retrieves a random user agent from our list in string form
|
|
|
|
func (s *Swamp) RandomUserAgent() string {
|
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
2021-09-18 13:47:19 +00:00
|
|
|
return randStrChoice(s.swampopt.userAgents)
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
2021-09-13 11:26:18 +00:00
|
|
|
|
2021-09-13 15:36:30 +00:00
|
|
|
// GetRandomEndpoint returns a random whatismyip style endpoint from our Swamp's options
|
|
|
|
func (s *Swamp) GetRandomEndpoint() string {
|
2021-09-13 16:32:07 +00:00
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
2021-09-13 15:36:30 +00:00
|
|
|
return randStrChoice(s.swampopt.CheckEndpoints)
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:32:07 +00:00
|
|
|
// GetStaleTime returns the duration of time after which a proxy will be considered "stale".
|
|
|
|
func (s *Swamp) GetStaleTime() time.Duration {
|
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
2021-09-18 13:47:19 +00:00
|
|
|
return s.swampopt.stale
|
2021-09-13 16:32:07 +00:00
|
|
|
}
|
|
|
|
|
2021-09-18 13:47:19 +00:00
|
|
|
// GetValidationTimeout returns the current value of validationTimeout (in seconds).
|
2021-09-13 17:40:23 +00:00
|
|
|
func (s *Swamp) GetValidationTimeout() int {
|
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
2021-09-18 13:47:19 +00:00
|
|
|
return s.swampopt.validationTimeout
|
2021-09-13 17:40:23 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 16:32:07 +00:00
|
|
|
// GetMaxWorkers returns maximum amount of workers that validate proxies concurrently. Note this is read-only during runtime.
|
|
|
|
func (s *Swamp) GetMaxWorkers() int {
|
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
2021-09-18 13:47:19 +00:00
|
|
|
return s.swampopt.maxWorkers
|
2021-09-13 16:32:07 +00:00
|
|
|
}
|
2021-09-20 05:57:42 +00:00
|
|
|
|
2021-09-20 01:23:18 +00:00
|
|
|
// IsRunning returns true if our background goroutines defined in daemons.go are currently operational
|
|
|
|
func (s *Swamp) IsRunning() bool {
|
|
|
|
if s.runningdaemons == 2 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-09-20 07:05:21 +00:00
|
|
|
// GetRecyclingStatus retrieves the current recycling status, see EnableRecycling.
|
|
|
|
func (s *Swamp) GetRecyclingStatus() bool {
|
|
|
|
s.mu.RLock()
|
|
|
|
defer s.mu.RUnlock()
|
|
|
|
return s.swampopt.recycle
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-13 16:32:07 +00:00
|
|
|
// TODO: Implement ways to access worker pool (pond) statistics
|