function NoProxyPattern::matchRange
Returns true if the target ip is in the network range
1 call to NoProxyPattern::matchRange()
- NoProxyPattern::match in vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php - Returns true if the url is matched by a rule
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ NoProxyPattern.php, line 140
Class
- NoProxyPattern
- Tests URLs against NO_PROXY patterns
Namespace
Composer\UtilCode
protected function matchRange(stdClass $network, stdClass $target) : bool {
$net = unpack('C*', $network->ip);
$mask = unpack('C*', $network->netmask);
$ip = unpack('C*', $target->ip);
if (false === $net) {
throw new \RuntimeException('Could not parse network IP ' . $network->ip);
}
if (false === $mask) {
throw new \RuntimeException('Could not parse netmask ' . $network->netmask);
}
if (false === $ip) {
throw new \RuntimeException('Could not parse target IP ' . $target->ip);
}
for ($i = 1; $i < 17; ++$i) {
if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
return false;
}
}
return true;
}