Archived
Show real IPv6 examples when available
This commit is contained in:
1 parent
9ec3d5c0fb
commit
0fc220b90b
3 files changed
+41
-3
No files matched your search
+39
-1
@@ -234,10 +234,48 @@ VISITOR_IP_JS = """
|
|||||||
replaceInCopyValues(search, replacement);
|
replaceInCopyValues(search, replacement);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateCopyCommand = (button, ipv6Command) => {
|
||||||
|
const value = button.dataset.copy || "";
|
||||||
|
if (!value || value.includes("?myipv6=")) return;
|
||||||
|
const lines = value.split("\\n");
|
||||||
|
const output = [];
|
||||||
|
let inserted = false;
|
||||||
|
lines.forEach((line) => {
|
||||||
|
output.push(line);
|
||||||
|
if (!inserted && line.includes("/api/v1/router/update/") && line.includes("?myip=")) {
|
||||||
|
output.push(ipv6Command);
|
||||||
|
inserted = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (inserted) button.dataset.copy = output.join("\\n");
|
||||||
|
};
|
||||||
|
|
||||||
|
const insertIpv6Examples = (ip) => {
|
||||||
|
if (!ip) return;
|
||||||
|
document.querySelectorAll(".terminal-card.manual-code").forEach((card) => {
|
||||||
|
if (card.textContent.includes("?myipv6=")) return;
|
||||||
|
const lines = [...card.querySelectorAll("code")];
|
||||||
|
const ipv4Line = lines.find((line) => line.textContent.includes("/api/v1/router/update/") && line.textContent.includes("?myip="));
|
||||||
|
if (!ipv4Line) return;
|
||||||
|
const base = ipv4Line.textContent.split("?myip=", 1)[0].replace(/'$/, "");
|
||||||
|
const ipv6Command = `${base}?myipv6=${ip}'`;
|
||||||
|
const code = document.createElement("code");
|
||||||
|
code.textContent = ipv6Command;
|
||||||
|
ipv4Line.after(code);
|
||||||
|
const copyButton = card.querySelector("[data-copy]");
|
||||||
|
if (copyButton) updateCopyCommand(copyButton, ipv6Command);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", async () => {
|
document.addEventListener("DOMContentLoaded", async () => {
|
||||||
const tasks = [];
|
const tasks = [];
|
||||||
if (needsIpv4()) tasks.push(fetchIp("https://api4.ipify.org?format=json").then((ip) => replaceEverywhere(ipv4Placeholder, ip)));
|
if (needsIpv4()) tasks.push(fetchIp("https://api4.ipify.org?format=json").then((ip) => replaceEverywhere(ipv4Placeholder, ip)));
|
||||||
if (needsIpv6()) tasks.push(fetchIp("https://api6.ipify.org?format=json").then((ip) => replaceEverywhere(ipv6Placeholder, ip)));
|
if (needsIpv6() || document.querySelector(".terminal-card.manual-code")) {
|
||||||
|
tasks.push(fetchIp("https://api6.ipify.org?format=json").then((ip) => {
|
||||||
|
replaceEverywhere(ipv6Placeholder, ip);
|
||||||
|
insertIpv6Examples(ip);
|
||||||
|
}));
|
||||||
|
}
|
||||||
await Promise.allSettled(tasks);
|
await Promise.allSettled(tasks);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ def _render_pending_management_page(
|
|||||||
<div>
|
<div>
|
||||||
<h2>Manual updates.</h2>
|
<h2>Manual updates.</h2>
|
||||||
<p class="section-copy">Scripts can send the IP explicitly, or omit it and let KarlDNS use the request IP. Visible examples use your public IP when KarlDNS or your browser can detect it.</p>
|
<p class="section-copy">Scripts can send the IP explicitly, or omit it and let KarlDNS use the request IP. Visible examples use your public IP when KarlDNS or your browser can detect it.</p>
|
||||||
{_code_window(manual_commands, copy_label="manual update commands", class_name="mt-3")}
|
{_code_window(manual_commands, copy_label="manual update commands", class_name="manual-code mt-3")}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2>Use your own DNS name.</h2>
|
<h2>Use your own DNS name.</h2>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ def _render_public_home(
|
|||||||
<div class="container narrow text-center">
|
<div class="container narrow text-center">
|
||||||
<h2>Update from a router or script.</h2>
|
<h2>Update from a router or script.</h2>
|
||||||
<p class="lead mx-auto mt-3">Works with FRITZ!Box, curl, cron, Home Assistant, OpenWrt, pfSense, OPNsense, UniFi, MikroTik, and custom tools.</p>
|
<p class="lead mx-auto mt-3">Works with FRITZ!Box, curl, cron, Home Assistant, OpenWrt, pfSense, OPNsense, UniFi, MikroTik, and custom tools.</p>
|
||||||
{_code_window(manual_demo, copy_label="manual update examples", class_name="text-start mt-4")}
|
{_code_window(manual_demo, copy_label="manual update examples", class_name="manual-code text-start mt-4")}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{_linux_installer_section(base_url)}
|
{_linux_installer_section(base_url)}
|
||||||
|
|||||||
Reference in new issue
Block a user