添加 index.html
This commit is contained in:
158
index.html
Normal file
158
index.html
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>最快IP查找工具</title>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||||
|
padding: 20px;
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #f5f5f5;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
background: white;
|
||||||
|
padding: 30px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
h1 { margin-bottom: 20px; color: #333; }
|
||||||
|
button {
|
||||||
|
background: #0066cc;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 12px 24px;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 16px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
button:hover { background: #0052a3; }
|
||||||
|
button:disabled { background: #ccc; cursor: not-allowed; }
|
||||||
|
#status {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 15px;
|
||||||
|
background: #f0f0f0;
|
||||||
|
border-radius: 5px;
|
||||||
|
min-height: 60px;
|
||||||
|
}
|
||||||
|
.result {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
background: #e8f5e9;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-left: 4px solid #4caf50;
|
||||||
|
}
|
||||||
|
.result h2 { color: #2e7d32; margin-bottom: 10px; }
|
||||||
|
.ip { font-size: 24px; font-weight: bold; color: #1976d2; }
|
||||||
|
.latency { color: #666; margin-top: 5px; }
|
||||||
|
.progress { color: #666; font-size: 14px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1>🚀 最快IP查找工具</h1>
|
||||||
|
<p>自动从 GitHub 获取 Cloudflare IP 列表并测试最快连接</p>
|
||||||
|
<button onclick="startTest()" id="startBtn">开始测试</button>
|
||||||
|
<div id="status"></div>
|
||||||
|
<div id="result"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let testing = false;
|
||||||
|
|
||||||
|
async function startTest() {
|
||||||
|
if (testing) return;
|
||||||
|
testing = true;
|
||||||
|
|
||||||
|
const btn = document.getElementById('startBtn');
|
||||||
|
const status = document.getElementById('status');
|
||||||
|
const result = document.getElementById('result');
|
||||||
|
|
||||||
|
btn.disabled = true;
|
||||||
|
result.innerHTML = '';
|
||||||
|
status.innerHTML = '正在获取IP列表...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('https://gh-proxy.org/raw.githubusercontent.com/ymyuuu/IPDB/refs/heads/main/BestCF/bestcfv4.txt');
|
||||||
|
const text = await response.text();
|
||||||
|
const ips = text.split('\n').filter(ip => ip.trim() && /^\d+\.\d+\.\d+\.\d+$/.test(ip.trim()));
|
||||||
|
|
||||||
|
if (ips.length === 0) {
|
||||||
|
status.innerHTML = '❌ 未找到有效IP';
|
||||||
|
btn.disabled = false;
|
||||||
|
testing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
status.innerHTML = `找到 ${ips.length} 个IP,开始测试...`;
|
||||||
|
|
||||||
|
let fastest = null;
|
||||||
|
let minLatency = Infinity;
|
||||||
|
let tested = 0;
|
||||||
|
|
||||||
|
for (const ip of ips) {
|
||||||
|
const latency = await testIP(ip.trim());
|
||||||
|
tested++;
|
||||||
|
|
||||||
|
status.innerHTML = `<div class="progress">测试进度: ${tested}/${ips.length}</div>`;
|
||||||
|
|
||||||
|
if (latency > 0 && latency < minLatency) {
|
||||||
|
minLatency = latency;
|
||||||
|
fastest = ip.trim();
|
||||||
|
result.innerHTML = `
|
||||||
|
<div class="result">
|
||||||
|
<h2>🎯 当前最快IP</h2>
|
||||||
|
<div class="ip">${fastest}</div>
|
||||||
|
<div class="latency">延迟: ${minLatency}ms</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status.innerHTML = `✅ 测试完成!共测试 ${tested} 个IP`;
|
||||||
|
|
||||||
|
if (!fastest) {
|
||||||
|
result.innerHTML = '<div style="color: #d32f2f; margin-top: 20px;">未找到可用IP</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
status.innerHTML = `❌ 错误: ${error.message}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
btn.disabled = false;
|
||||||
|
testing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testIP(ip, timeout = 3000) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const start = performance.now();
|
||||||
|
const img = new Image();
|
||||||
|
let done = false;
|
||||||
|
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (!done) {
|
||||||
|
done = true;
|
||||||
|
img.src = '';
|
||||||
|
resolve(-1);
|
||||||
|
}
|
||||||
|
}, timeout);
|
||||||
|
|
||||||
|
img.onload = img.onerror = () => {
|
||||||
|
if (!done) {
|
||||||
|
done = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
const latency = Math.round(performance.now() - start);
|
||||||
|
resolve(latency < timeout ? latency : -1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
img.src = `http://${ip}/cdn-cgi/trace?t=${Date.now()}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user