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

Method setPort

warp/warp.ts:384–404  ·  view source on GitHub ↗
(port: number)

Source from the content-addressed store, hash-verified

382
383 try {
384 const updateResult = await SystemExecutor.runSudo(`sed -i 's/BindAddress.*/BindAddress = 127.0.0.1:${port}/g' ${WIREPROXY_CONFIG_FILE}`);
385 if (!updateResult.success) {
386 throw new Error(`配置更新失败: ${updateResult.error}`);
387 }
388
389 const restartResult = await SystemExecutor.runSudo("systemctl restart wireproxy");
390 if (!restartResult.success) {
391 throw new Error(`服务重启失败: ${restartResult.error}`);
392 }
393
394 return `✅ 端口已更新为 ${port} 并重启服务`;
395 } catch (error: any) {
396 return `❌ 端口更新失败: ${htmlEscape(error.message)}`;
397 }
398 }
399
400 static async uninstall(): Promise<string> {
401 try {
402 // 第一步:停止所有服务(忽略错误)
403 await SystemExecutor.runSudo("systemctl stop wireproxy 2>/dev/null || true");
404 await SystemExecutor.runSudo("systemctl stop dnsmasq 2>/dev/null || true");
405 await SystemExecutor.runSudo("wg-quick down warp 2>/dev/null || true");
406
407 // 第二步:禁用服务(忽略错误)

Callers 1

handleWarpMethod · 0.80

Calls 2

runSudoMethod · 0.80
htmlEscapeFunction · 0.70

Tested by

no test coverage detected