public static function isValid($hostname)
    {
        $hostname = trim($hostname);

        // Strip the wrapping square brackets from IPv6 addresses.

        if (Str::startsWith($hostname, '[') && Str::endsWith($hostname, ']')) {
            $hostname = substr($hostname, 1, -1);
        }

        return (bool)filter_var($hostname, FILTER_VALIDATE_IP);
    }