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

Function parseIPv4

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

Source from the content-addressed store, hash-verified

23const MDNS = /\.local$/i;
24
25function parseIPv4(host: string): [number, number, number, number] | null {
26 const m = IPV4_SHAPE.exec(host);
27 if (!m) return null;
28 const parts: number[] = [];
29 for (let i = 1; i <= 4; i++) {
30 const n = Number(m[i]);
31 if (!Number.isInteger(n) || n < 0 || n > 255) return null;
32 parts.push(n);
33 }
34 return parts as [number, number, number, number];
35}
36
37function isPrivateOrLoopbackV4(host: string): boolean {
38 const ip = parseIPv4(host);

Callers 2

isPrivateOrLoopbackV4Function · 0.85
isLoopbackV4Function · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected