Returns a Hostname or a IPAddress object depending on passed value

@param $domain
@return Hostname|IPAddress
964084
public static function specifyType($domain)
    {
        if (false !== filter_var($domain, FILTER_VALIDATE_IP)) {
            return new IPAddress($domain);
        }

        return new Hostname($domain);
    }
486863
public static function parse_host_parts($host) {
		// Tease out the hostname.
		if (false === ($host = static::parse_host($host))) {
			return false;
		}

		$out = static::HOST_PARTS;

		// If this is an IP, we don't have to do anything else.
		if (\filter_var($host, \FILTER_VALIDATE_IP)) {
			$out['host'] = $host;
			$out['domain'] = $host;
			return $out;
		}

		// Now the hard part. See if any parts of the host
		// correspond to a registered suffix.
		$suffixes = data::SUFFIXES;
		$suffix = array();
		$parts = \explode('.', $host);
		$parts = \array_reverse($parts);

		foreach ($parts as $k=>$part) {
			// Override rule.
			if (isset($suffixes[$part], $suffixes[$part]['!'])) {
				break;
			}

			// A match.
			if (isset($suffixes[$part])) {
				\array_unshift($suffix, $part);
				$suffixes = $suffixes[$part];
				unset($parts[$k]);
				continue;
			}

			// A wildcard.
			if (isset($suffixes['*'])) {
				\array_unshift($suffix, $part);
				$suffixes = $suffixes['*'];
				unset($parts[$k]);
				continue;
			}

			// We're done.
			break;
		}

		// The suffix can't be all there is.
		if (! \count($parts)) {
			return false;
		}

		// The domain.
		$parts = \array_reverse($parts);
		$out['domain'] = \array_pop($parts);

		// The subdomain.
		if (\count($parts)) {
			$out['subdomain'] = \implode('.', $parts);
		}

		// The suffix.
		if (\count($suffix)) {
			$out['suffix'] = \implode('.', $suffix);
		}

		$out['host'] = $host;

		return $out;
	}
650980
public function getDomain() : ?string 
    {
        if ( ! $this->hasDomain()) {
            $this->setDomain($this->getDefaultDomain());
        }
        return $this->domain;
    }
1202120
protected function getDnsRecord($domain)
    {
        if (filter_var($domain, FILTER_VALIDATE_URL) === false) {
            $this->eye->logger()->debug('DNS URL not valid', $domain);
            return false;
        }

        try {
            $dns = $this->pollDns($this->parseUrl($domain));
        } catch (Exception $e) {
            $this->eye->logger()->debug('DNS lookup failed', ['domain' => $domain,
                                                              'exception' => $e->getMessage()]);
            return false;
        }

        return $this->stripTtlFromDns($dns);
    }
270091
public function getTranslator($domain = '')
    {
        if (empty($domain)) {
            $domain = $this->default_domain;
        }

        if (! isset($this->domains[$this->locale])) {
            $this->domains[$this->locale] = [];
        }

        if (! isset($this->domains[$this->locale][$domain])) {
            if (isset($this->paths[$domain])) {
                $base = $this->paths[$domain];
            } else {
                $base = './';
            }

            $locale_names = $this->listLocales($this->locale);

            $filename = '';
            foreach ($locale_names as $locale) {
                $filename = "$base/$locale/LC_MESSAGES/$domain.mo";
                if (file_exists($filename)) {
                    break;
                }
            }

            // We don't care about invalid path, we will get fallback
            // translator here
            $this->domains[$this->locale][$domain] = new Translator($filename);
        }

        return $this->domains[$this->locale][$domain];
    }
1248495
public function domain($domain = null)
    {
        if (is_null($domain)) {
            return $this->getDomain();
        }

        $this->action['domain'] = $domain;

        return $this;
    }
829780
public static function getDomainName(string $url): string
    {
        if (isset(self::$cached_url_domains[$url])) {
            return self::$cached_url_domains[$url];
        }

        $parsed_url = parse_url(strtolower($url));
        $host = $parsed_url['host'] ?? '';

        /// Remove www. part
        if (0 === strpos($host, 'www.')) {
            $host = substr($host, 4);
        }

        // Get last part (zone)
        $parts = array_reverse(explode('.', $host));

        if (!$parts || !self::zoneExists($parts[0])) {
            return '';
        }

        if(count($parts)==1){
            $domain = $parts[0];
        }else {
            $zone = '.' . $parts[0];

            // Save parsed url and found zone
            $domain = substr($host, 0, -strlen($zone));
        }

        return self::$cached_url_domains[$url] = $domain;
    }
34373
public function getBind($domain = null)
    {
        if (is_null($domain)) {
            $domain = $this->domain;
        } elseif (true === $domain) {
            return $this->bind;
        } elseif (false === strpos($domain, '.')) {
            $domain .= '.' . $this->request->rootDomain();
        }

        $subDomain = $this->getSubDomain();

        if (strpos($subDomain, '.')) {
            $name = '*' . strstr($subDomain, '.');
        }

        if (isset($this->bind[$domain])) {
            $result = $this->bind[$domain];
        } elseif (isset($name) && isset($this->bind[$name])) {
            $result = $this->bind[$name];
        } elseif (isset($this->bind['*'])) {
            $result = $this->bind['*'];
        } else {
            $result = null;
        }

        return $result;
    }
62511
public static function getSecondDomain() {
        $serverName = filter_input(INPUT_SERVER, 'SERVER_NAME');
        $serverArr = explode('.', $serverName);
        $domain = array_shift($serverArr);

        return $domain;
    }
739842
public function setDomain($domain = self::DEFAULT_DOMAIN)
    {
        $this->domain = $domain;
        if (isset($this->config[$this->domain]) && !empty($this->config[$this->domain])) {
            $this->codes = $this->config[$this->domain];
        } else {
            $this->codes  = $this->config[self::DEFAULT_DOMAIN];
            $this->domain = self::DEFAULT_DOMAIN;
        }
        return $this;
    }
501757
public static function getSysDomain()
    {
        static $ret = null;

        if ($ret !== null) {
            return $ret;
        }

        $host    = Typo3GeneralUtility::getIndpEnv('HTTP_HOST');
        $rootPid = self::getRootPid();

        $query = 'SELECT *
                    FROM sys_domain
                   WHERE pid = ' . (int)$rootPid . '
                     AND domainName = ' . DatabaseUtility::quote($host, 'sys_domain') . '
                     AND hidden = 0';
        $ret   = DatabaseUtility::getRow($query);

        return $ret;
    }
1122053
public function getSiteByDomain($domain)
    {
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('domain, site, primaryDomain')
            ->from(\Rcm\Entity\Domain::class, 'domain')
            ->leftJoin('domain.site', 'site')
            ->leftJoin('domain.primaryDomain', 'primaryDomain')
            ->where('domain.domain = :domainName')
            ->setParameter('domainName', $domain);

        try {
            /** @var \Rcm\Entity\Domain $domain */
            $domain = $queryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            return null;
        }

        if ($domain->getPrimary()) {
            $site = $domain->getPrimary()->getSite();
            $this->_em->detach($site);
            $this->_em->detach($domain);
            $site->setDomain($domain);
        } else {
            $site = $domain->getSite();
        }

        return $site;
    }
939027
public static function getDefault($domain = null)
    {
        // Get by domain if it exists and has a default
        $domainObject = Domain::getByDomain($domain);
        if ($domainObject) {
            $default = $domainObject->DefaultLocale();
            if ($default) {
                return $default;
            }
        }

        // Get explicit or implicit default
        $locales = static::getLocales();
        return $locales->filter('IsGlobalDefault', 1)->first()
            ?: $locales->first();
    }
915711
public static function getHostname($url)
    {
        if (!isset(self::$cache[$url]['hostname'])) {
            self::$cache[$url]['hostname'] = self::parseUrl($url, PHP_URL_HOST);
        }

        return self::$cache[$url]['hostname'];
    }
80649
public static function getByDomain($domain)
    {
        // Map true -> actual domain
        if ($domain === true) {
            $state = FluentState::singleton();
            $domain = $state->getIsDomainMode() ? $state->getDomain() : null;
        }

        // No domain found
        if (!$domain) {
            return null;
        }

        if ($domain instanceof Domain) {
            return $domain;
        }

        // Get filtered domain
        return static::getCached()
            ->filter('Domain', $domain)
            ->first();
    }
339025
public function getDomain($domainName)
    {
        if (isset($this->domainMap[$domainName])) {
            return $this->domainMap[$domainName];
        }

        return null; // just to be explicit
    }
1022719
public static function encodeDomainName($domain): string
    {
        if ('.' === $domain) {
            return chr(0);
        }

        $domain = rtrim($domain, '.').'.';
        $res = '';

        foreach (explode('.', $domain) as $label) {
            $res .= chr(strlen($label)).$label;
        }

        return $res;
    }