timeout = $timeout; } public function nameToIPs(string $name): ?array { $ret = shell_exec_error("host -W {$this->timeout} {$name}"); if ($ret === false) { return null; } $ipv4 = self::matchOrEmpty('/has address ([^\s]+)/', $ret); $ipv6 = self::matchOrEmpty('/has IPv6 address ([^\s]+)/', $ret); return \array_merge($ipv4, $ipv6); } public function IPToNames(string $ip): ?array { $ret = shell_exec_error("host -W {$this->timeout} {$ip}"); if ($ret === false) { return null; } $names = self::matchOrEmpty('/domain name pointer ([^\s]+)\./', $ret); return \array_map(fn($n) => \strtolower(\rtrim($n, '.')), $names); } }