function NoProxyPattern::ipGetNetwork
Calculates and returns the network and mask
Parameters
string $rangeIp IP in_addr:
int $size Byte size of in_addr:
int $prefix CIDR prefix-length:
Return value
string[] network in_addr, binary mask
1 call to NoProxyPattern::ipGetNetwork()
- NoProxyPattern::ipCheckData in vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php - Creates an object containing IP data if the host is an IP address
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php, line 283
Class
- NoProxyPattern
- Tests URLs against NO_PROXY patterns
Namespace
Composer\UtilCode
private function ipGetNetwork(string $rangeIp, int $size, int $prefix) : array {
$netmask = $this->ipGetMask($prefix, $size);
// Get the network from the address and mask
$mask = unpack('C*', $netmask);
$ip = unpack('C*', $rangeIp);
$net = '';
if (false === $mask) {
throw new \RuntimeException('Could not parse netmask ' . $netmask);
}
if (false === $ip) {
throw new \RuntimeException('Could not parse range IP ' . $rangeIp);
}
for ($i = 1; $i < 17; ++$i) {
$net .= chr($ip[$i] & $mask[$i]);
}
return [
$net,
$netmask,
];
}