/
sslproxies.go
71 lines (61 loc) · 1.91 KB
/
sslproxies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package targets
import (
"strconv"
"strings"
"github.com/PuerkitoBio/goquery"
"github.com/agux/roprox/internal/types"
)
// SSLProxies fetches proxy server from https://www.sslproxies.org/
type SSLProxies struct {
defaultFetcherSpec
}
// UID returns the unique identifier for this spec.
func (f SSLProxies) UID() string {
return "sslproxies"
}
// Urls return the server urls that provide the free proxy server lists.
func (f SSLProxies) Urls() []string {
return []string{`https://www.sslproxies.org/`}
}
// IsGBK returns wheter the web page is GBK encoded.
func (f SSLProxies) IsGBK() bool {
return false
}
// ProxyMode returns whether the fetcher needs a master proxy server
// to access the free proxy list provider.
func (f SSLProxies) ProxyMode() types.ProxyMode {
return types.MasterProxy
}
// ListSelector returns the jQuery selector for searching the proxy server list/table.
func (f SSLProxies) ListSelector() []string {
return []string{
"#proxylisttable tbody tr",
}
}
// RefreshInterval determines how often the list should be refreshed, in minutes.
func (f SSLProxies) RefreshInterval() int {
return 30
}
// ScanItem process each item found in the table determined by ListSelector().
func (f SSLProxies) ScanItem(i, urlIdx int, s *goquery.Selection) (ps *types.ProxyServer) {
lchk := strings.TrimSpace(s.Find("td:nth-child(8)").Text())
if strings.HasSuffix(lchk, "minutes ago") {
m := lchk[:strings.Index(lchk, " ")]
if i, e := strconv.ParseInt(m, 10, 64); e == nil {
if int(i) > 50 {
return
}
} else {
log.Errorf("failed to parse proxy last check string: %s, %+v", m, e)
return
}
}
anon := strings.TrimSpace(s.Find("td:nth-child(5)").Text())
if strings.EqualFold(anon, `transparent`) {
return
}
host := strings.TrimSpace(s.Find("td:nth-child(1)").Text())
port := strings.TrimSpace(s.Find("td:nth-child(2)").Text())
ps = types.NewProxyServer(f.UID(), host, port, "http", "")
return
}