MCPcopy Create free account
hub / github.com/chartbrew/chartbrew / getNat64EmbeddedIpv4

Function getNat64EmbeddedIpv4

server/modules/outboundTargetPolicy.js:140–150  ·  view source on GitHub ↗
(address)

Source from the content-addressed store, hash-verified

138NAT64_BLOCKLIST.addSubnet("64:ff9b:1::", 48, "ipv6");
139
140function getNat64EmbeddedIpv4(address) {
141 if (net.isIP(address) !== 6) return null;
142 if (!NAT64_BLOCKLIST.check(address, "ipv6")) return null;
143
144 // Expand to full hextets and read the trailing 32 bits as IPv4 octets.
145 const groups = expandIpv6(address);
146 if (!groups) return null;
147 const lo = (groups[6] << 16) | groups[7]; // last two 16-bit groups = 32-bit IPv4
148 const ipv4 = [(lo >>> 24) & 0xff, (lo >>> 16) & 0xff, (lo >>> 8) & 0xff, lo & 0xff].join(".");
149 return net.isIP(ipv4) === 4 ? ipv4 : null;
150}
151
152function expandIpv6(address) {
153 // Returns an array of 8 numeric hextets, or null if not a valid IPv6 literal.

Callers 2

isMetadataAddressFunction · 0.85
getMappedIpv4Function · 0.85

Calls 1

expandIpv6Function · 0.85

Tested by

no test coverage detected