MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / getStatus

Method getStatus

warp/warp.ts:135–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 SystemExecutor.run("systemctl is-active wireproxy"),
134 SystemExecutor.run("ss -tlnp | grep -i wireproxy | head -1"),
135 SystemExecutor.run(`test -f ${WIREPROXY_CONFIG_FILE}`),
136 SystemExecutor.run(`test -f ${WIREPROXY_BINARY}`),
137 SystemExecutor.run(`test -f ${WARP_CONFIG_FILE}`),
138 SystemExecutor.run("systemctl is-active dnsmasq"),
139 SystemExecutor.run("command -v iptables"),
140 SystemExecutor.run("command -v ipset"),
141 SystemExecutor.run("lsmod | grep -w wireguard"),
142 ]);
143
144 const svcStatus = svc.success ? svc.output : "inactive";
145 const portMatch = socks.success ? socks.output.match(/:(\d+)\b/) : null;
146 const port = portMatch ? parseInt(portMatch[1], 10) : 0;
147
148 // 检查代理配置状态
149 let proxyInfo = "";
150 if (svcStatus === "active" && port) {
151 const pwdResult = await SystemExecutor.run("pwd");
152 if (pwdResult.success) {
153 const programDir = pwdResult.output.trim();
154 let tgProxyStatus = "❌ 未配置";
155 let musicProxyStatus = "❌ 未配置";
156
157 // 检查 Telegram 代理
158 const tgConfigPath = `${programDir}/config.json`;
159 const tgConfigCheck = await SystemExecutor.run(`test -f ${tgConfigPath}`);
160 if (tgConfigCheck.success) {
161 const readResult = await SystemExecutor.run(`cat ${tgConfigPath}`);
162 if (readResult.success) {
163 try {
164 const config = JSON.parse(readResult.output);
165 if (config.proxy && config.proxy.port === port) {
166 tgProxyStatus = `✅ 已配置 (端口: ${port})`;
167 }
168 } catch {
169 tgProxyStatus = "❓ 配置文件解析失败";
170 }
171 }
172 }
173
174 // 检查 Music 代理
175 const musicConfigPath = `${programDir}/assets/music/music_config.json`;
176 const musicConfigCheck = await SystemExecutor.run(`test -f ${musicConfigPath}`);
177 if (musicConfigCheck.success) {
178 const readResult = await SystemExecutor.run(`cat ${musicConfigPath}`);
179 if (readResult.success) {
180 try {
181 const musicConfig = JSON.parse(readResult.output);
182 const musicProxy = musicConfig["music_ytdlp_proxy"];
183 if (musicProxy && musicProxy.includes(`:${port}`)) {
184 musicProxyStatus = `✅ 已配置 (端口: ${port})`;
185 }
186 } catch {
187 musicProxyStatus = "❓ 配置文件解析失败";
188 }
189 }
190 }
191
192 proxyInfo = `\n<b>代理状态</b>\n- Telegram 代理: ${tgProxyStatus}\n- Music 代理: ${musicProxyStatus}`;

Callers 1

handleWarpMethod · 0.80

Calls 2

runMethod · 0.80
htmlEscapeFunction · 0.70

Tested by

no test coverage detected