// advanced-worker.js export default { async fetch(request) { const testURLs = [ 'https://vl.61999.icu/ray', 'https://104.16.0.1/ray', 'https://108.162.194.1/ray' ]; // 为当前客户端测试各个节点的速度 const results = await Promise.all( testURLs.map(async (url) => { const start = Date.now(); try { await fetch(url, { method: 'HEAD', headers: { 'Host': 'vl.61999.icu' } }); return { url, latency: Date.now() - start }; } catch { return { url, latency: 9999 }; } }) ); // 选择延迟最低的节点 const bestNode = results.reduce((best, current) => current.latency < best.latency ? current : best ); // 提取IP地址 const bestIP = bestNode.url.replace('https://', '').split('/')[0]; return Response.redirect(`https://${bestIP}`, 307); } }