MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / isPrivateIpAddress

Method isPrivateIpAddress

server/src/validator.ts:637–665  ·  view source on GitHub ↗
(address: string)

Source from the content-addressed store, hash-verified

635 }
636
637 private isPrivateIpAddress(address: string): boolean {
638 const ipVersion = net.isIP(address);
639 if (ipVersion === 4) {
640 const octets = address.split(".").map(Number);
641 const [a, b] = octets;
642 return (
643 a === 0 ||
644 a === 10 ||
645 a === 127 ||
646 (a === 169 && b === 254) ||
647 (a === 172 && b >= 16 && b <= 31) ||
648 (a === 192 && b === 168)
649 );
650 }
651
652 if (ipVersion === 6) {
653 const normalized = address.toLowerCase();
654 return (
655 normalized === "::1" ||
656 normalized === "::" ||
657 normalized.startsWith("fc") ||
658 normalized.startsWith("fd") ||
659 normalized.startsWith("fe80:") ||
660 normalized.startsWith("::ffff:127.")
661 );
662 }
663
664 return false;
665 }
666
667 private normalizeScope(scope?: AuthorizationScope): NormalizedScope {
668 if (!scope) {

Callers 1

validateFetchTargetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected