2021-09-13 09:37:59 +00:00
|
|
|
package pxndscvm
|
|
|
|
|
2021-09-13 17:55:51 +00:00
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
2021-09-13 09:37:59 +00:00
|
|
|
|
|
|
|
// Statistics is used to encapsulate various swampy stats
|
|
|
|
type Statistics struct {
|
2021-09-13 11:26:18 +00:00
|
|
|
// Valid4 is the amount of SOCKS4 proxies validated
|
2021-09-13 15:17:20 +00:00
|
|
|
Valid4 int
|
2021-09-13 11:26:18 +00:00
|
|
|
// Valid4a is the amount of SOCKS4a proxies validated
|
2021-09-13 10:08:04 +00:00
|
|
|
Valid4a int
|
2021-09-13 11:26:18 +00:00
|
|
|
// Valid5 is the amount of SOCKS5 proxies validated
|
2021-09-13 15:17:20 +00:00
|
|
|
Valid5 int
|
2021-09-23 16:06:49 +00:00
|
|
|
// ValidHTTP is the amount of HTTP proxies validated
|
|
|
|
ValidHTTP int
|
2021-09-13 11:26:18 +00:00
|
|
|
// Dispensed is a simple ticker to keep track of proxies dispensed via our getters
|
|
|
|
Dispensed int
|
2021-09-18 04:54:42 +00:00
|
|
|
// Stale is the amount of proxies that failed our stale policy upon dispensing
|
|
|
|
Stale int
|
2021-09-23 07:38:00 +00:00
|
|
|
// Checked is the amount of proxies we've checked.
|
|
|
|
Checked int
|
2021-09-14 02:47:16 +00:00
|
|
|
// birthday represents the time we started checking proxies with this pool
|
|
|
|
birthday time.Time
|
2021-09-21 12:24:30 +00:00
|
|
|
mu *sync.Mutex
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 11:26:18 +00:00
|
|
|
func (stats *Statistics) dispense() {
|
|
|
|
stats.Dispensed++
|
|
|
|
}
|
|
|
|
|
2021-09-18 04:54:42 +00:00
|
|
|
func (stats *Statistics) stale() {
|
|
|
|
stats.Stale++
|
|
|
|
}
|
|
|
|
|
2021-09-13 09:37:59 +00:00
|
|
|
func (stats *Statistics) v4() {
|
2021-09-13 10:08:04 +00:00
|
|
|
stats.Valid4++
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (stats *Statistics) v4a() {
|
2021-09-13 10:08:04 +00:00
|
|
|
stats.Valid4a++
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (stats *Statistics) v5() {
|
2021-09-13 10:08:04 +00:00
|
|
|
stats.Valid5++
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
2021-09-13 17:55:51 +00:00
|
|
|
|
2021-09-23 16:06:49 +00:00
|
|
|
func (stats *Statistics) http() {
|
|
|
|
stats.ValidHTTP++
|
|
|
|
}
|
|
|
|
|
2021-09-13 17:55:51 +00:00
|
|
|
// GetUptime returns the total lifetime duration of our pool.
|
|
|
|
func (stats *Statistics) GetUptime() time.Duration {
|
2021-09-14 02:47:16 +00:00
|
|
|
return time.Since(stats.birthday)
|
2021-09-13 17:55:51 +00:00
|
|
|
}
|