public function getPorts(string $address) : array
{
if ($address === '0.0.0.0' || $address === '::') {
$ports = [];
foreach ($this->addressMap as $packedAddress => $port_list) {
if (\strlen($packedAddress) === ($address === '0.0.0.0' ? 4 : 16)) {
$ports = array_merge($ports, $port_list);
}
}
return $ports;
}
$packedAddress = inet_pton($address);
// if this yields a warning, there's something else buggy, but no @ missing.
$wildcard = \strlen($packedAddress) === 4 ? "" : "";
if (!isset($this->addressMap[$wildcard])) {
return $this->addressMap[$packedAddress] ?? [];
} elseif (!isset($this->addressMap[$packedAddress])) {
return $this->addressMap[$wildcard];
} else {
return array_merge($this->addressMap[$wildcard], $this->addressMap[$packedAddress]);
}
}