()
| 790 | } |
| 791 | |
| 792 | async function getAllServers(): Promise<ServerInfo[]> { |
| 793 | try { |
| 794 | if (!fs.existsSync(SPEEDTEST_PATH)) { |
| 795 | await downloadCli(); |
| 796 | } |
| 797 | |
| 798 | const command = `"${SPEEDTEST_PATH}" -f json -L`; |
| 799 | const { stdout } = await execAsync(command, { timeout: 30000 }); |
| 800 | const result = JSON.parse(stdout); |
| 801 | |
| 802 | return result.servers || []; |
| 803 | } catch (error: any) { |
| 804 | console.error("Failed to get servers:", error); |
| 805 | return []; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | /** |
| 810 | * 轻量级服务器ping测试 |
no test coverage detected