       end
     end
 
-    defp format_host(string) do
-      charlist = to_charlist(string)
+    defp domain_or_fallback(host) do
+      case domain_or_ip(host) do
+        {:domain, domain} -> domain
+        {:ip, _ip} -> to_charlist(host)
+      end
+    end
+
+    defp domain_or_ip(host) do
+      charlist = to_charlist(host)
 
       case :inet.parse_address(charlist) do
         {:error, :einval} ->

    end

    defp tunnel_opts(uri) do
      {_type, host} = format_host(uri.host)
      %{host: host, port: uri.port}
    end


        |> Map.put(:tls_opts, tls_opts)
        |> Map.put(:tcp_opts, tcp_opts)

      {_type, host} = domain_or_ip(uri.host)

      with {:ok, pid} <- :gun.open(host, uri.port, opts_with_master_keys) do
        {:ok, pid}
