forked from opusb/tpclash2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
constant.go
161 lines (142 loc) · 4.71 KB
/
constant.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
package main
const logo = `
████████╗██████╗ ██████╗██╗ █████╗ ███████╗██╗ ██╗
╚══██╔══╝██╔══██╗██╔════╝██║ ██╔══██╗██╔════╝██║ ██║
██║ ██████╔╝██║ ██║ ███████║███████╗███████║
██║ ██╔═══╝ ██║ ██║ ██╔══██║╚════██║██╔══██║
██║ ██║ ╚██████╗███████╗██║ ██║███████║██║ ██║
╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
`
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/capability.h
const (
CAP_NET_BIND_SERVICE = 10
CAP_NET_ADMIN = 12
CAP_NET_RAW = 13
)
const (
ChainDockerUser = "DOCKER-USER" // https://docs.docker.com/network/packet-filtering-firewalls/#docker-on-a-router
)
const (
InternalClashBinName = "xclash"
InternalConfigName = "xclash.yaml"
)
const (
bindAddressPatch = `# TPClash Common Config AutoFix
bind-address: '*'
`
externalControllerPatch = `# TPClash Common Config AutoFix
external-controller: 0.0.0.0:9090
`
secretPatch = `# TPClash Common Config AutoFix
secret: tpclash
`
tunStandardPatch = `# TPClash TUN AutoFix
tun:
enable: true
stack: system
dns-hijack:
- any:53
auto-route: true
auto-redir: true
`
tunEBPFPatch = `# TPClash TUN eBPF AutoFix
tun:
enable: true
stack: system
dns-hijack:
- any:53
auto-route: false
auto-redir: false
`
dnsPatch = `# TPClash DNS AutoFix
dns:
enable: true
listen: 0.0.0.0:1053
enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16
fake-ip-filter:
- '*.lan'
- '*.local'
default-nameserver:
- 223.5.5.5
- 119.29.29.29
nameserver:
- 223.5.5.5
- 119.29.29.29
`
nicPatch = `# TPClash Nic AutoFix
interface-name: {{MainNic}}
`
ebpfPatch = `# TPClash eBPF AutoFix
ebpf:
redirect-to-tun:
- {{MainNic}}
`
routingMarkPatch = `# TPClash routing-mark AutoFix
routing-mark: 666
`
)
const systemdTpl = `[Unit]
Description=Transparent proxy tool for Clash
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/usr/local/bin/tpclash%s
RestartSec=10s
TimeoutStopSec=30s
[Install]
WantedBy=multi-user.target
`
const (
installDir = "/usr/local/bin"
systemdDir = "/etc/systemd/system"
)
const (
lokiImage = "grafana/loki:2.8.0"
vectorImage = "timberio/vector:0.X-alpine"
trafficScraperImage = "vi0oss/websocat:0.10.0"
tracingScraperImage = "vi0oss/websocat:0.10.0"
grafanaImage = "grafana/grafana-oss:latest"
lokiContainerName = "tpclash-loki"
vectorContainerName = "tpclash-vector"
trafficScraperContainerName = "tpclash-traffic-scraper"
tracingScraperContainerName = "tpclash-tracing-scraper"
grafanaContainerName = "tpclash-grafana"
)
const installedMessage = logo + ` 👌 TPClash 安装完成, 您可以使用以下命令启动:
● 启动服务: systemctl start tpclash
● 停止服务: systemctl stop tpclash
● 重启服务: systemctl restart tpclash
● 开启自启动: systemctl enable tpclash
● 关闭自启动: systemctl disable tpclash
● 查看日志: journalctl -fu tpclash
● 重载服务配置: systemctl daemon-reload
`
const reinstallMessage = `
❗监测到您可能执行了重新安装, 重新启动前请执行重载服务配置.
`
const uninstallMessage = `
❗️在卸载前请务必先停止 TPClash
❗️如果尚未停止请按 Ctrl+c 终止卸载
❗️本卸序将会在 30s 后继续执行卸载命令
`
const uninstalledMessage = logo + ` 👌 TPClash 已卸载, 如有任何问题请开启 issue 或从 Telegram 讨论组反馈
● 官方仓库: https://github.com/mritd/tpclash
● Telegram: https://t.me/tpclash
`
const (
githubLatestApi = "https://api.github.com/repos/mritd/tpclash/releases/latest"
githubUpgradeAddr = "https://github.com/mritd/tpclash/releases/download/v%s/%s"
ghProxyAddr = "https://ghproxy.com/"
)
const upgradedMessage = logo + ` 👌 TPClash 已升级完成, 请重新启动以应用更改
● 启动服务: systemctl start tpclash
● 停止服务: systemctl stop tpclash
● 重启服务: systemctl restart tpclash
● 开启自启动: systemctl enable tpclash
● 关闭自启动: systemctl disable tpclash
● 查看日志: journalctl -fu tpclash
● 重载服务配置: systemctl daemon-reload
`