-
Notifications
You must be signed in to change notification settings - Fork 32
/
proxy.go
61 lines (51 loc) · 1.19 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
59
60
61
package chrome
import "github.com/gopherjs/gopherjs/js"
type Proxy struct {
o *js.Object
Settings *js.Object
}
func NewProxy(proxyObj *js.Object) *Proxy {
p := new(Proxy)
p.o = proxyObj
if proxyObj.String() != "undefined" {
p.Settings = proxyObj.Get("settings")
}
return p
}
/*
* Types
*/
type ProxyServer struct {
*js.Object
Scheme string `js:"scheme"`
Host string `js:"host"`
Port int `js:"port"`
}
type ProxyRules struct {
*js.Object
SingleProxy ProxyServer `js:"singleProxy"`
ProxyForHttp ProxyServer `js:"proxyForHttp"`
ProxyForHttps ProxyServer `js:"proxyForHttps"`
ProxyForFtp ProxyServer `js:"proxyForFtp"`
FallbackProxy ProxyServer `js:"fallbackProxy"`
BypassList []string `js:"bypassList"`
}
type PacScript struct {
*js.Object
Url string `js:"url"`
Data string `js:"data"`
Mandatory bool `js:"mandatory"`
}
type ProxyConfig struct {
*js.Object
Rules ProxyRules `js:"rules"`
PacScript PacScript `js:"pacScript"`
Mode string `js:"mode"`
}
/*
* Events
*/
// OnProxyError notifies about proxy errors.
func (p *Proxy) OnProxyError(callback func(details Object)) {
p.o.Get("onProxyError").Call("addListener", callback)
}