-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
78 lines (64 loc) · 1.96 KB
/
config.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
72
73
74
75
76
77
78
package config
import (
"encoding/json"
"io"
)
var c Config
func C() Config {
return c
}
// Load read config from reader, and update the global config instance
func Load(r io.Reader) (Config, error) {
err := json.NewDecoder(r).Decode(&c)
if err != nil {
return Config{}, err
}
return c, nil
}
type Config struct {
Inbounds Inbounds `json:"inbounds,omitempty"` // 入站代理
Outbounds []*YeagerClient `json:"outbounds,omitempty"` // 出站代理
Rules []string `json:"rules,omitempty"` // 路由规则
// verbose logging
Verbose bool `json:"verbose,omitempty`
// 如何预估连接池大小,参考 proxy/yeager/transport/grpc/pool.go
ConnectionPoolSize int `json:"connectionPoolSize,omitempty"`
// expose runtime metrics for debugging and profiling, developers only
Debug bool `json:"debug,omitempty"`
}
type Inbounds struct {
SOCKS *struct {
Listen string `json:"listen"`
} `json:"socks,omitempty"`
HTTP *struct {
Listen string `json:"listen"`
} `json:"http,omitempty"`
Yeager *YeagerServer `json:"yeager,omitempty"`
}
type Transport string
const (
TransTCP Transport = "tcp" // plain text
TransGRPC Transport = "grpc"
TransQUIC Transport = "quic"
// deprecated. Infrequently used
// TransTLS Transport = "tls"
)
type MutualTLS struct {
CertFile string `json:"certFile"`
CertPEM []byte `json:"-"`
KeyFile string `json:"keyFile"`
KeyPEM []byte `json:"-"`
CAFile string `json:"caFile"`
CAPEM []byte `json:"-"`
}
type YeagerServer struct {
Listen string `json:"listen"`
Transport Transport `json:"transport"`
MutualTLS MutualTLS `json:"mtls,omitempty"` // unavailable when transport is tcp
}
type YeagerClient struct {
Tag string `json:"tag"` // 出站标记,用于路由规则指定出站代理
Address string `json:"address"` // server address to be connected
Transport Transport `json:"transport"`
MutualTLS MutualTLS `json:"mtls,omitempty"` // unavailable when transport is tcp
}