protected function isValidDomain($hostname)
    {
        return preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $hostname)
            && preg_match("/^.{1,253}$/", $hostname)
            && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $hostname)
            && !preg_match("/^\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}$/", $hostname);
    }