diff options
-rw-r--r-- | lib/pleroma/gun/connections.ex | 17 | ||||
-rw-r--r-- | lib/pleroma/http/http.ex | 13 |
2 files changed, 26 insertions, 4 deletions
diff --git a/lib/pleroma/gun/connections.ex b/lib/pleroma/gun/connections.ex index a3f1b0351..b8cf2f9b5 100644 --- a/lib/pleroma/gun/connections.ex +++ b/lib/pleroma/gun/connections.ex @@ -11,6 +11,20 @@ defmodule Pleroma.Gun.Connections do conns: %{domain() => conn()} } + @gun_keys [ + :connect_timeout, + :http_opts, + :http2_opts, + :protocols, + :retry, + :retry_timeout, + :trace, + :transport, + :tls_opts, + :tcp_opts, + :ws_opts + ] + defstruct conns: %{} def start_link(name \\ __MODULE__) do @@ -81,7 +95,8 @@ defmodule Pleroma.Gun.Connections do {:noreply, state} nil -> - {:ok, conn} = Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, opts) + {:ok, conn} = + Pleroma.Gun.API.open(to_charlist(uri.host), uri.port, Map.take(opts, @gun_keys)) state = put_in(state.conns[key], %Pleroma.Gun.Conn{ diff --git a/lib/pleroma/http/http.ex b/lib/pleroma/http/http.ex index 6a09b8260..a7f42d0c0 100644 --- a/lib/pleroma/http/http.ex +++ b/lib/pleroma/http/http.ex @@ -62,7 +62,7 @@ defmodule Pleroma.HTTP do end defp get_conn_for_gun(url, options) do - case Pleroma.Gun.Connections.get_conn(url) do + case Pleroma.Gun.Connections.get_conn(url, options) do nil -> options @@ -86,8 +86,15 @@ defmodule Pleroma.HTTP do host = uri.host |> to_charlist() case uri.scheme do - "https" -> options ++ [ssl: [server_name_indication: host]] - _ -> options + "https" -> + tls_opts = + Keyword.get(options, :tls_opts, []) + |> Keyword.put(:server_name_indication, host) + + Keyword.put(options, :tls_opts, tls_opts) ++ [ssl: [server_name_indication: host]] + + _ -> + options end end |