src.nth.io/

summaryrefslogtreecommitdiff
path: root/scrypted/diagnostic.ts
blob: e7a3ba3789482121eccc3f0c7bcc798ed9c6542b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Paste into the diagnostic / probe Scrypted script. Save + Run.
// Tells us which Node/mDNS modules the scriptedEval sandbox lets us
// require() — drives whether the auto-discovery feature can use a
// proper library or has to fall back to raw multicast UDP.

declare const require: any;

console.log("------ scriptedEval require() probe ------");
for (const mod of [
    "dns",              // built-in; we already use this for dns.lookup
    "dgram",            // built-in; needed for raw mDNS multicast UDP
    "multicast-dns",
    "bonjour",
    "bonjour-service",
    "mdns",
]) {
    try {
        const m = require(mod);
        const top = Object.keys(m || {}).slice(0, 8).join(",");
        console.log(`  ${mod.padEnd(16)} -> ok; top keys: ${top}`);
    } catch (e: any) {
        console.log(`  ${mod.padEnd(16)} -> ${e?.code || "ERR"}: ${e?.message || e}`);
    }
}