2022-05-23 01:05:50 +00:00
|
|
|
package prox5
|
2021-09-13 09:37:59 +00:00
|
|
|
|
2021-09-13 17:55:51 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
2021-09-13 09:37:59 +00:00
|
|
|
|
2022-05-23 01:20:40 +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
|
2022-05-23 01:20:40 +00:00
|
|
|
Valid4 int64
|
2021-09-13 11:26:18 +00:00
|
|
|
// Valid4a is the amount of SOCKS4a proxies validated
|
2022-05-23 01:20:40 +00:00
|
|
|
Valid4a int64
|
2021-09-13 11:26:18 +00:00
|
|
|
// Valid5 is the amount of SOCKS5 proxies validated
|
2022-05-23 01:20:40 +00:00
|
|
|
Valid5 int64
|
2021-09-23 16:06:49 +00:00
|
|
|
// ValidHTTP is the amount of HTTP proxies validated
|
2022-05-23 01:20:40 +00:00
|
|
|
ValidHTTP int64
|
2021-09-13 11:26:18 +00:00
|
|
|
// Dispensed is a simple ticker to keep track of proxies dispensed via our getters
|
2022-05-23 01:20:40 +00:00
|
|
|
Dispensed int64
|
2021-09-18 04:54:42 +00:00
|
|
|
// Stale is the amount of proxies that failed our stale policy upon dispensing
|
2022-05-23 01:20:40 +00:00
|
|
|
Stale int64
|
2021-09-23 07:38:00 +00:00
|
|
|
// Checked is the amount of proxies we've checked.
|
2022-05-23 01:20:40 +00:00
|
|
|
Checked int64
|
2021-09-14 02:47:16 +00:00
|
|
|
// birthday represents the time we started checking proxies with this pool
|
|
|
|
birthday time.Time
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 01:20:40 +00:00
|
|
|
func (stats *statistics) dispense() {
|
2021-09-13 11:26:18 +00:00
|
|
|
stats.Dispensed++
|
|
|
|
}
|
|
|
|
|
2022-05-23 01:20:40 +00:00
|
|
|
func (stats *statistics) stale() {
|
2021-09-18 04:54:42 +00:00
|
|
|
stats.Stale++
|
|
|
|
}
|
|
|
|
|
2022-05-23 01:20:40 +00:00
|
|
|
func (stats *statistics) v4() {
|
2021-09-13 10:08:04 +00:00
|
|
|
stats.Valid4++
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 01:20:40 +00:00
|
|
|
func (stats *statistics) v4a() {
|
2021-09-13 10:08:04 +00:00
|
|
|
stats.Valid4a++
|
2021-09-13 09:37:59 +00:00
|
|
|
}
|
|
|
|
|
2022-05-23 01:20:40 +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
|
|
|
|
2022-05-23 01:20:40 +00:00
|
|
|
func (stats *statistics) http() {
|
2021-09-23 16:06:49 +00:00
|
|
|
stats.ValidHTTP++
|
|
|
|
}
|
|
|
|
|
2021-11-25 08:21:41 +00:00
|
|
|
// GetTotalValidated retrieves our grand total validated proxy count.
|
2022-06-26 02:51:42 +00:00
|
|
|
func (pe *ProxyEngine) GetTotalValidated() int {
|
|
|
|
stats := pe.GetStatistics()
|
|
|
|
return int(stats.Valid4a + stats.Valid4 + stats.Valid5 + stats.ValidHTTP)
|
2021-11-25 08:21:41 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 17:55:51 +00:00
|
|
|
// GetUptime returns the total lifetime duration of our pool.
|
2022-05-23 01:20:40 +00:00
|
|
|
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
|
|
|
}
|