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:----HwyKsyQj+lU/cOTpAG9Utb+/Wb5KWGalYM7ELNMu/ZZRdAGGF3tpRRYzMguz4YySD+S7eKNmIyC8Ol7EJGUxy3ehl00T4EqaDiNKxx1YC6iq/6XwvJ0PdcQjCyuLEaUY8m+KkkTAUJzDllUM649W4mXFEw9t+8kJ3reCWQoLoWsdEytYTsQAbezQP6VvuqkFwU8Om3e55KtxZTz4DWV1yUJY7wawN9FTkdYX+CuvGU7SWvpcfgCzlj+tKfV33OARdBz9hwXkqOxXzHRUzP7u2vmkb0jViOMgUcNDV6yR4SS0+ukfMjy2zdifXzj4oTYAXvnDXBR+MAEvc3lC+EIbjSr+wu8MOTy5sXS8bYseN4Iv9Qia1yBy+df5n25SbPZRhwP+ekvnpPlMFDuA/YzmDGEJAdFWkxFfBOz1LORwM0ufT7jJbaHlipdGhKc+h1IS/1uYA+G+CRaF04EFAOzHetYH18jJEXMxmHS2faVQzUkFySXNqDVCBwX4ItsDim4EtxDmgb2vfxFWYPj6+sge+uxLafii6XFm/uyi0xsSRbnWvvVHk61PkQwTftCMxssQtCtgqc4/ZHVvuD0EPDpfiI4nLPXmEzC6B/eQASuT+Vq/UZgmPsFqGM/JjV8S0W2mdDjhHNm10wlZnkQI3COFm3cNhJFFwVOTq5Mub5nN48c=----ATTACHMENT:----Mjc5NDM4MTcyNjUyMTkwNSA3NDgwNDk1NDAyMzA4OTI1IDYzMzk4NDIxMjg4MDA3NzY=