 
       # if gun used from master
       opts_with_master_keys =
-        Map.put(gun_opts, :tls_opts, tls_opts)
+        gun_opts
+        |> Map.put(:tls_opts, tls_opts)
         |> Map.put(:tcp_opts, tcp_opts)
 
       host =


    defp do_open_conn(uri, %{proxy: {proxy_host, proxy_port}}, gun_opts, tls_opts) do
      connect_opts =
        tunnel_opts(uri)
        |> tunnel_tls_opts(uri.scheme, tls_opts)

      with {:ok, pid} <- :gun.open(proxy_host, proxy_port, gun_opts),

        end

      socks_opts =
        uri
        |> tunnel_opts()
        |> tunnel_tls_opts(uri.scheme, tls_opts)
        |> Map.put(:version, version)

      gun_opts =
        gun_opts
        |> Map.put(:protocols, [:socks])
        |> Map.update(:socks_opts, socks_opts, &Map.merge(socks_opts, &1))

      with {:ok, pid} <- :gun.open(proxy_host, proxy_port, gun_opts),
