33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
|
|
// Prove the DNS-independent path: a WS wrapper that FAILS for any hostname URL,
|
|||
|
|
// so a successful .bch resolution can only have come from the pinned IP + SNI.
|
|||
|
|
import WebSocket from "ws";
|
|||
|
|
import { resolveName } from "../../Argus/src/lib/resolver-web.js";
|
|||
|
|
|
|||
|
|
const isIpUrl = (u) => /\/\/\d{1,3}(\.\d{1,3}){3}:/.test(u);
|
|||
|
|
|
|||
|
|
class DnsDeadWS extends WebSocket {
|
|||
|
|
constructor(url, opts) {
|
|||
|
|
if (isIpUrl(url)) {
|
|||
|
|
console.log(" → connecting by IP:", url, "SNI:", opts?.servername);
|
|||
|
|
super(url, opts);
|
|||
|
|
} else {
|
|||
|
|
console.log(" ✗ hostname blocked (simulated dead DNS):", url);
|
|||
|
|
super("wss://127.0.0.1:1"); // unreachable → error → triggers IP fallback
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
console.log("resolving hello.bch with system DNS 'dead' (hostnames blocked)…");
|
|||
|
|
try {
|
|||
|
|
const entry = await resolveName("hello.bch", { WebSocket: DnsDeadWS, directIP: true });
|
|||
|
|
if (entry) {
|
|||
|
|
console.log("\n✅ RESOLVED via pinned IP — DNS-independent path works.");
|
|||
|
|
console.log(" records:", Object.keys(entry.records).join(", "));
|
|||
|
|
} else {
|
|||
|
|
console.log("\n⚠️ connected but hello.bch not found (name may be unregistered) — IP path still worked.");
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
console.log("\n❌ FAILED:", e.message);
|
|||
|
|
}
|
|||
|
|
process.exit(0);
|