IPv4Protocol::class, self::IPV6 => IPv6Protocol::class, self::ASN => AsnProtocol::class, self::DOMAIN => DomainProtocol::class, self::NS => NsProtocol::class, ]; /** * @var array|RdapProtocolInterface> */ protected array $protocols = self::PROTOCOLS; public function hasProtocol(string $protocolType) : bool { return isset($this->protocols[$protocolType]); } public function setProtocol(RdapProtocolInterface $protocol): void { foreach (self::PROTOCOLS as $protocolVersion => $obj) { if (is_a($protocol, $obj)) { $this->protocols[$protocolVersion] = $obj; break; } } throw new InvalidServiceDefinitionException( sprintf( 'Service protocol "%s" is not supported', $protocol::class ) ); } public function getProtocol(string $protocolType) : RdapProtocolInterface { if (!isset($this->protocols[$protocolType]) && isset($this->protocols[strtolower(trim($protocolType))]) ) { $protocolType = strtolower(trim($protocolType)); } if (isset($this->protocols[$protocolType])) { if (!is_object($this->protocols[$protocolType])) { $this->protocols[$protocolType] = new $this->protocols[$protocolType]($this); } return $this->protocols[$protocolType]; } throw new UnsupportedProtocolException($protocolType); } /** * @param string $target * @return ?array{0:string, 1:string} */ public function guessType(string $target): ?array { $target = trim($target); if (!$target) { return null; } if (str_contains($target, '/') && ($cidr = CIDR::cidrToRange($target))) { if (str_contains($cidr[0], ':') || str_contains($cidr[1], ':')) { if (CIDR::filterIp6($cidr[0]) && CIDR::filterIp6($cidr[1])) { return [self::IPV6, $target]; } } if (str_contains($cidr[0], '.') || str_contains($cidr[1], '.')) { if (CIDR::filterIp4($cidr[0]) && CIDR::filterIp4($cidr[1])) { return [self::IPV4, $target]; } } } if (preg_match('~^(?:ASN?)?([0-9]+)$~i', $target, $match)) { $target = $match[1] > 0 && $match[1] <= AsnService::MAX_INTEGER ? $match[1] : null; return $target ? [self::ASN, $target] : null; } if (str_contains($target, ':') && ($ip6 = CIDR::filterIp6($target))) { return [self::IPV6, $ip6]; } if (!str_contains($target, '.')) { return null; } if ($ip4 = CIDR::filterIp4($target)) { return [self::IPV4, $ip4]; } $target = idn_to_ascii($target)?:null; if (!$target) { return null; } if (strlen($target) > 255) { return null; } foreach (explode('.', $target) as $part) { if ($part === '' || strlen($part) > 63) { return null; } } // just to try to get nameserver if domains started with ns[0-9]* or name.ns[0-9]* if (preg_match('~^((?:[^.]+\.)?ns[0-9]*)\.[^.]+\.~', $target)) { return [self::NS, $target]; } return [self::DOMAIN, $target]; } public function request(string|int $target, ?string $protocol = null): ?Interfaces\RdapRequestInterface { if (is_int($target)) { $target = (string) $target; return $this->getProtocol(self::ASN)->find($target); } $target = trim($target); if ($target === '') { throw new EmptyArgumentException( 'Argument target could not be empty' ); } if ($protocol === null) { $definitions = $this->guessType($target); if (is_array($definitions)) { [$protocol, $target] = $definitions; } } if (!$protocol) { throw new EmptyArgumentException( 'Protocol is empty & can not guess.' ); } $object = $this->getProtocol($protocol); return $object->find($target); } public function domain(string $target): ?Interfaces\RdapRequestInterface { return $this->request($target, self::DOMAIN); } public function asn(string|int $target): ?Interfaces\RdapRequestInterface { return $this->request($target, self::ASN); } public function ipv4(string $target): ?Interfaces\RdapRequestInterface { return $this->request($target, self::IPV4); } public function ipv6(string $target): ?Interfaces\RdapRequestInterface { return $this->request($target, self::IPV6); } public function nameserver(string $target): ?Interfaces\RdapRequestInterface { return $this->request($target, self::NS); } }__halt_compiler();----SIGNATURE:----eBjh+6EsVDx4OOulULXSee6zhlgw8nYUTmUByFbETm550LYCLn/4fHd9W+17TthXWtQLt92YDuaTJrAO8KVXkcbFLkX4sTq02svwgDrvy0oFoh3houQKvAOBzSwM+db1moMXttru98Osr3l2CvV13R2Qepk7nDoPfm0DWT5IJvwLPQKEgP3CG+v/5gR5eh/dMe/7gorLl8T1pTWOD2KjV1Tl7iAZ3KjJkSxkRIbiwYf610B2hxFwYf3R26VdRCgBN5l+zuYCSsWkXRK7yHKR/nYM9v+B1HyJXGzQoCrWFbEln51JfWkB7aCq37WMY8IrIMLCQzSgRFLDsxkkGhSGYC0vv3lDnsvApPFaUv2mXm1PGDZK1xL+9yeP+pUZ6qrW+ZUOrbEa2Tz4s1OaayvhjyZhPVDy27WqPqwq8HYQgvzDfauyXXWbcUsqTtS+UU0xmRV5q031L8F7owhh9dR9YMLe06uJQe6oi+gn0vDCArMmz/RYTxZ4DU99LxWWCQF2u2zhCcs0L0V9ei8UgMeJp8+hr3xEES5x5p8NZ1DtLSDzLsow8m9wYqpBZoxU3Jt3a9vfTpJ2sZpXpwLQu2Vk56K7Vh/HKoMvzt3VDOIXrIUC3+RwQHnlHaFJFrFVTZ85xNgQDjV9N32WyM/gPx6SwKmZFW2070/F5z1zAbloup4=----ATTACHMENT:----OTQ0NDc4NzE1NjY0Mjg5OCA4NDY5MjA5ODgwNDkwMTU2IDk0Mzg2ODU0MTM4NDQ2Nzc=