-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathflags.go
More file actions
105 lines (101 loc) · 2.93 KB
/
flags.go
File metadata and controls
105 lines (101 loc) · 2.93 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package cli
import (
"github.com/Ehco1996/ehco/internal/constant"
cli "github.com/urfave/cli/v2"
)
var (
LocalAddr string
ListenType constant.RelayType
RemoteAddr string
TransportType constant.RelayType
ConfigPath string
WebPort int
DashboardPass string
ApiToken string
EnablePing bool
SystemFilePath = "/etc/systemd/system/ehco.service"
LogLevel string
ConfigReloadInterval int
BufferSize int
)
var RootFlags = []cli.Flag{
&cli.StringFlag{
Name: "l,local",
Usage: "监听地址,例如 0.0.0.0:1234",
EnvVars: []string{"EHCO_LOCAL_ADDR"},
Destination: &LocalAddr,
},
&cli.StringFlag{
Name: "lt,listen_type",
Value: "raw",
Usage: "监听类型,可选项有 raw,ws,wss",
EnvVars: []string{"EHCO_LISTEN_TYPE"},
Destination: (*string)(&ListenType),
Required: false,
},
&cli.StringFlag{
Name: "r,remote",
Usage: "转发地址,例如 0.0.0.0:5201,通过 ws 隧道转发时应为 ws://0.0.0.0:2443",
EnvVars: []string{"EHCO_REMOTE_ADDR"},
Destination: &RemoteAddr,
},
&cli.StringFlag{
Name: "tt,transport_type",
Value: "raw",
Usage: "传输类型,可选选有 raw,ws,wss",
EnvVars: []string{"EHCO_TRANSPORT_TYPE"},
Destination: (*string)(&TransportType),
},
&cli.StringFlag{
Name: "c,config",
Usage: "配置文件地址,支持文件类型或 http api",
EnvVars: []string{"EHCO_CONFIG_FILE"},
Destination: &ConfigPath,
},
&cli.IntFlag{
Name: "web_port",
Usage: "prometheus web exporter 的监听端口",
EnvVars: []string{"EHCO_WEB_PORT"},
Value: 0,
Destination: &WebPort,
},
&cli.BoolFlag{
Name: "enable_ping",
Usage: "是否打开 ping metrics",
EnvVars: []string{"EHCO_ENABLE_PING"},
Value: true,
Destination: &EnablePing,
},
&cli.StringFlag{
Name: "dashboard_pass",
Usage: "ehco 内置面板登录密码 (留空则关闭面板登录)",
EnvVars: []string{"EHCO_DASHBOARD_PASS"},
Destination: &DashboardPass,
},
&cli.StringFlag{
Name: "api_token",
Usage: "非浏览器调用方走 Authorization: Bearer 时使用的 token",
EnvVars: []string{"EHCO_API_TOKEN"},
Destination: &ApiToken,
},
&cli.StringFlag{
Name: "log_level",
Usage: "log level",
EnvVars: []string{"EHCO_LOG_LEVEL"},
Destination: &LogLevel,
DefaultText: "info",
},
&cli.IntFlag{
Name: "config_reload_interval",
Usage: "config reload interval",
EnvVars: []string{"EHCO_CONFIG_RELOAD_INTERVAL"},
Destination: &ConfigReloadInterval,
DefaultText: "60",
},
&cli.IntFlag{
Name: "buffer_size",
Usage: "set buffer size to when transport data default 20 * 1024(20KB)",
EnvVars: []string{"EHCO_BUFFER_SIZE"},
Destination: &BufferSize,
},
}