()
| 360 | return `❌ WireProxy 未安装,无法重启。请先使用 <code>${htmlEscape(mainPrefix)}warp w</code> 安装。`; |
| 361 | } |
| 362 | |
| 363 | try { |
| 364 | const restartResult = await SystemExecutor.runSudo("systemctl restart wireproxy"); |
| 365 | if (!restartResult.success) { |
| 366 | if (restartResult.error?.includes("not found")) { |
| 367 | return `❌ WireProxy 服务未找到。可能安装不完整,请尝试重新安装: <code>${htmlEscape(mainPrefix)}warp w</code>`; |
| 368 | } |
| 369 | throw new Error(restartResult.error); |
| 370 | } |
| 371 | |
| 372 | return "✅ WireProxy 已重启,IP 已更换"; |
| 373 | } catch (e: any) { |
| 374 | return `❌ 重启失败: ${htmlEscape(e?.message || e)}`; |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | static async setPort(port: number): Promise<string> { |
| 379 | if (!Number.isFinite(port) || port < 1 || port > 65535) { |
| 380 | return "❌ 端口无效"; |
| 381 | } |
| 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) { |
no test coverage detected