MCPcopy
hub / github.com/cpaczek/skylight / testHostname

Function testHostname

server/src/allowed-hosts.ts:95–107  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

93 const allowPrivateLan = (env.ALLOW_PRIVATE_LAN ?? "1") !== "0";
94
95 function testHostname(host: string): boolean {
96 const h = host.toLowerCase();
97 if (h === "localhost") return true;
98 if (isLoopbackV4(h)) return true;
99 if (LOOPBACK_V6.test(h)) return true;
100 if (MDNS.test(h)) return true;
101 if (allowPrivateLan) {
102 if (isPrivateOrLoopbackV4(h)) return true;
103 if (ULA_V6.test(h)) return true;
104 if (LINK_LOCAL_V6.test(h)) return true;
105 }
106 return matchExtra(h, extras);
107 }
108
109 return {
110 test(rawHost: string | undefined): boolean {

Callers 1

testFunction · 0.85

Calls 4

isLoopbackV4Function · 0.85
isPrivateOrLoopbackV4Function · 0.85
matchExtraFunction · 0.85
testMethod · 0.80

Tested by 1

testFunction · 0.68