MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / checkNetworkConnectivity

Function checkNetworkConnectivity

speedtest/speedtest.ts:970–986  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

968}
969
970async function checkNetworkConnectivity(): Promise<{ connected: boolean; message: string }> {
971 try {
972 // 测试基本网络连接
973 await axios.get('https://www.speedtest.net', { timeout: 10000 });
974 return { connected: true, message: "网络连接正常" };
975 } catch (error: any) {
976 if (error.code === 'ENOTFOUND') {
977 return { connected: false, message: "DNS解析失败,请检查DNS设置" };
978 } else if (error.code === 'ECONNREFUSED') {
979 return { connected: false, message: "连接被拒绝,可能存在防火墙阻止" };
980 } else if (error.code === 'ETIMEDOUT') {
981 return { connected: false, message: "连接超时,网络可能较慢或不稳定" };
982 } else {
983 return { connected: false, message: `网络连接异常: ${error.message}` };
984 }
985 }
986}
987
988async function saveSpeedtestImage(url: string): Promise<string | null> {
989 try {

Callers 1

speedtestFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected