Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NoProxyPattern.php

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\Util

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal