fix: improve VLESS link compatibility and add Reality repair script
Only encode SNI dots, keep pbk/sid raw, copy links via API, prefer xray keygen, and add repair-reality.sh for server-side fixes. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+33
-3
@@ -45,6 +45,20 @@ function copyText(text) {
|
||||
});
|
||||
}
|
||||
|
||||
let nodeLinksCache = null;
|
||||
|
||||
async function fetchNodeLinks() {
|
||||
if (nodeLinksCache) {
|
||||
return nodeLinksCache;
|
||||
}
|
||||
const res = await fetch(apiUrl("/api/nodes"), { credentials: "same-origin" });
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
nodeLinksCache = await res.json();
|
||||
return nodeLinksCache;
|
||||
}
|
||||
|
||||
document.querySelectorAll(".copy-row").forEach((row) => {
|
||||
const input = row.querySelector(".copy-input");
|
||||
const btn = row.querySelector(".copy-btn");
|
||||
@@ -56,17 +70,33 @@ document.querySelectorAll(".copy-row").forEach((row) => {
|
||||
});
|
||||
|
||||
btn.addEventListener("click", async () => {
|
||||
const text = input.value;
|
||||
const card = row.closest(".node-card");
|
||||
const nodeId = card?.dataset.id;
|
||||
const kind = btn.dataset.linkKind || input.dataset.linkKind || "vless";
|
||||
let text = input.value;
|
||||
|
||||
if (nodeId) {
|
||||
try {
|
||||
const nodes = await fetchNodeLinks();
|
||||
const node = nodes.find((item) => String(item.id) === String(nodeId));
|
||||
if (node?.links) {
|
||||
text = kind === "hy2" ? node.links.hy2 : node.links.vless;
|
||||
}
|
||||
} catch {
|
||||
/* fall back to input.value */
|
||||
}
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
toast("没有可复制的内容");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
input.select();
|
||||
input.setSelectionRange(0, text.length);
|
||||
await copyText(text);
|
||||
toast("已复制到剪贴板");
|
||||
} catch {
|
||||
input.select();
|
||||
input.setSelectionRange(0, text.length);
|
||||
toast("复制失败,请选中上方链接后 Ctrl+C");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,6 +85,13 @@ input.copy-input {
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
|
||||
.link-hint {
|
||||
margin: 6px 0 0;
|
||||
font-size: 0.78rem;
|
||||
line-height: 1.45;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border: 1px solid var(--border);
|
||||
background: #111827;
|
||||
|
||||
Reference in New Issue
Block a user