-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxy.go
58 lines (47 loc) · 1.45 KB
/
proxy.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
package phantomjs
type ProxyType string
const (
ProxyType_Direct ProxyType = "direct"
ProxyType_Pac = "pac"
ProxyType_AutoDetect = "autodetect"
ProxyType_System = "system"
ProxyType_Manual = "manual"
)
type Proxy struct {
ProxyType ProxyType `json:"proxyType,omitempty"`
// defines the url for a proxy auto-config file if proxyType is equal to "pac"
ProxyAutoconfigUrl string `json:"proxyAutoconfigUrl,omitempty"`
FTPProxy string `json:"ftpProxy,omitempty"`
HTTPProxy string `json:"httpProxy,omitempty"`
SSLProxy string `json:"sslProxy,omitempty"`
SocksProxy string `json:"socksProxy,omitempty"`
SocksVersion int `json:"socksVersion,omitempty"`
SocksUsername string `json:"socksUsername,omitempty"`
SocksPassword string `json:"socksPassword,omitempty"`
}
func NewHTTPProxy(addr string) *Proxy {
proxy := Proxy{}
proxy.ProxyType = ProxyType_Manual
proxy.HTTPProxy = addr
return &proxy
}
func NewSSLProxy(addr string) *Proxy {
proxy := Proxy{}
proxy.ProxyType = ProxyType_Manual
proxy.SSLProxy = addr
return &proxy
}
func NewSocks4Proxy(addr string) *Proxy {
proxy := Proxy{}
proxy.ProxyType = ProxyType_Manual
proxy.SocksProxy = addr
proxy.SocksVersion = 4
return &proxy
}
func NewSocks5Proxy(addr string) *Proxy {
proxy := Proxy{}
proxy.ProxyType = ProxyType_Manual
proxy.SocksProxy = addr
proxy.SocksVersion = 5
return &proxy
}