Documentation

NoProxyPattern
in package

Tests URLs against NO_PROXY patterns

Table of Contents

$hostNames  : array<string|int, string>
$noproxy  : bool
$rules  : array<string|int, object>
__construct()  : mixed
test()  : bool
Returns true if a URL matches the NO_PROXY pattern
getUrlData()  : bool|stdclass
Returns false is the url cannot be parsed, otherwise a data object
match()  : bool
Returns true if the url is matched by a rule
matchRange()  : bool
Returns true if the target ip is in the network range
getRule()  : mixed
Finds or creates rule data for a hostname
ipCheckData()  : bool
Creates an object containing IP data if the host is an IP address
ipGetAddr()  : array<string|int, mixed>
Returns an array of the IP in_addr and its byte size
ipGetMask()  : string
Returns the binary network mask mapped to IPv6
ipGetNetwork()  : array<string|int, string>
Calculates and returns the network and mask
ipMapTo6()  : string
Maps an IPv4 address to IPv6
makeData()  : stdclass
Creates a rule data object
makeIpData()  : stdclass
Creates an ip data object
splitHostPort()  : array<string|int, mixed>
Splits the hostname into host and port components
validateInt()  : mixed
Wrapper around filter_var FILTER_VALIDATE_INT

Properties

$hostNames

protected array<string|int, string> $hostNames = array()

Methods

__construct()

public __construct(string $pattern) : mixed
Parameters
$pattern : string

NO_PROXY pattern

Return values
mixed

test()

Returns true if a URL matches the NO_PROXY pattern

public test(string $url) : bool
Parameters
$url : string
Return values
bool

getUrlData()

Returns false is the url cannot be parsed, otherwise a data object

protected getUrlData(string $url) : bool|stdclass
Parameters
$url : string
Return values
bool|stdclass

match()

Returns true if the url is matched by a rule

protected match(int $index, string $hostName, string $url) : bool
Parameters
$index : int
$hostName : string
$url : string
Return values
bool

matchRange()

Returns true if the target ip is in the network range

protected matchRange(stdClass $network, stdClass $target) : bool
Parameters
$network : stdClass
$target : stdClass
Return values
bool

getRule()

Finds or creates rule data for a hostname

private getRule(int $index, string $hostName) : mixed
Parameters
$index : int
$hostName : string
Return values
mixed

ipCheckData()

Creates an object containing IP data if the host is an IP address

private ipCheckData(string $host, null|stdclass &$ipdata[, bool $allowPrefix = false ]) : bool
Parameters
$host : string
$ipdata : null|stdclass

Set by method if IP address found

$allowPrefix : bool = false

Whether a CIDR prefix-length is expected

Return values
bool

False if the host contains invalid data

ipGetAddr()

Returns an array of the IP in_addr and its byte size

private ipGetAddr(string $host) : array<string|int, mixed>

IPv4 addresses are always mapped to IPv6, which simplifies handling and comparison.

Parameters
$host : string
Return values
array<string|int, mixed>

in_addr, size

ipGetMask()

Returns the binary network mask mapped to IPv6

private ipGetMask(string $prefix, int $size) : string
Parameters
$prefix : string

CIDR prefix-length

$size : int

Byte size of in_addr

Return values
string

ipGetNetwork()

Calculates and returns the network and mask

private ipGetNetwork(string $rangeIp, int $size, string $prefix) : array<string|int, string>
Parameters
$rangeIp : string

IP in_addr

$size : int

Byte size of in_addr

$prefix : string

CIDR prefix-length

Return values
array<string|int, string>

network in_addr, binary mask

ipMapTo6()

Maps an IPv4 address to IPv6

private ipMapTo6(string $binary, int $size) : string
Parameters
$binary : string

in_addr

$size : int

Byte size of in_addr

Return values
string

Mapped or existing in_addr

makeData()

Creates a rule data object

private makeData(string $host, int $port, null|stdclass $ipdata) : stdclass
Parameters
$host : string
$port : int
$ipdata : null|stdclass
Return values
stdclass

makeIpData()

Creates an ip data object

private makeIpData(string $ip, int $size, null|string $netmask) : stdclass
Parameters
$ip : string

in_addr

$size : int

Byte size of in_addr

$netmask : null|string

Network mask

Return values
stdclass

splitHostPort()

Splits the hostname into host and port components

private splitHostPort(string $hostName) : array<string|int, mixed>
Parameters
$hostName : string
Return values
array<string|int, mixed>

host, port, if there was error

validateInt()

Wrapper around filter_var FILTER_VALIDATE_INT

private validateInt(string $int, int $min, int $max) : mixed
Parameters
$int : string
$min : int
$max : int
Return values
mixed

Search results