purge all remaining hackney usage and references from the tree
This commit is contained in:
parent
8f17204221
commit
dd9446474f
@ -56,20 +56,6 @@ config :pleroma, Pleroma.Captcha,
|
||||
seconds_valid: 60,
|
||||
method: Pleroma.Captcha.Kocaptcha
|
||||
|
||||
config :pleroma, :hackney_pools,
|
||||
federation: [
|
||||
max_connections: 50,
|
||||
timeout: 150_000
|
||||
],
|
||||
media: [
|
||||
max_connections: 50,
|
||||
timeout: 150_000
|
||||
],
|
||||
upload: [
|
||||
max_connections: 25,
|
||||
timeout: 300_000
|
||||
]
|
||||
|
||||
config :pleroma, Pleroma.Captcha.Kocaptcha, endpoint: "https://captcha.kotobank.ch"
|
||||
|
||||
# Upload configuration
|
||||
@ -193,11 +179,11 @@ config :pleroma, :http,
|
||||
proxy_url: nil,
|
||||
send_user_agent: true,
|
||||
adapter: [
|
||||
ssl_options: [
|
||||
# Workaround for remote server certificate chain issues
|
||||
partial_chain: &:hackney_connect.partial_chain/1,
|
||||
# We don't support TLS v1.3 yet
|
||||
versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]
|
||||
tls_opts: [
|
||||
verify: :verify_peer,
|
||||
cacerts: :certifi.cacerts(),
|
||||
depth: 20,
|
||||
reuse_sessions: false
|
||||
]
|
||||
]
|
||||
|
||||
|
@ -38,7 +38,6 @@ defmodule Pleroma.Application do
|
||||
Pleroma.ScheduledActivityWorker
|
||||
] ++
|
||||
cachex_children() ++
|
||||
hackney_pool_children() ++
|
||||
gun_pools() ++
|
||||
[
|
||||
Pleroma.Web.Federator.RetryQueue,
|
||||
@ -95,20 +94,6 @@ defmodule Pleroma.Application do
|
||||
Pleroma.Web.Endpoint.Instrumenter.setup()
|
||||
end
|
||||
|
||||
def enabled_hackney_pools do
|
||||
[:media] ++
|
||||
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
|
||||
[:federation]
|
||||
else
|
||||
[]
|
||||
end ++
|
||||
if Pleroma.Config.get([Pleroma.Upload, :proxy_remote]) do
|
||||
[:upload]
|
||||
else
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
defp cachex_children do
|
||||
[
|
||||
build_cachex("used_captcha", ttl_interval: seconds_valid_interval()),
|
||||
@ -157,13 +142,6 @@ defmodule Pleroma.Application do
|
||||
|
||||
defp chat_child(_, _), do: []
|
||||
|
||||
defp hackney_pool_children do
|
||||
for pool <- enabled_hackney_pools() do
|
||||
options = Pleroma.Config.get([:hackney_pools, pool])
|
||||
:hackney_pool.child_spec(pool, options)
|
||||
end
|
||||
end
|
||||
|
||||
defp gun_pools do
|
||||
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Gun || Mix.env() == :test do
|
||||
for {pool_name, opts} <- Pleroma.Config.get([:gun_pools]) do
|
||||
|
@ -1,21 +0,0 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReverseProxy.Client.Hackney do
|
||||
@behaviour Pleroma.ReverseProxy.Client
|
||||
|
||||
def request(method, url, headers, body, opts \\ []) do
|
||||
:hackney.request(method, url, headers, body, opts)
|
||||
end
|
||||
|
||||
def stream_body(ref) do
|
||||
case :hackney.stream_body(ref) do
|
||||
:done -> :done
|
||||
{:ok, data} -> {:ok, data, ref}
|
||||
{:error, error} -> {:error, error}
|
||||
end
|
||||
end
|
||||
|
||||
def close(ref), do: :hackney.close(ref)
|
||||
end
|
@ -58,7 +58,7 @@ defmodule Pleroma.ReverseProxy do
|
||||
|
||||
* `req_headers`, `resp_headers` additional headers.
|
||||
|
||||
* `http`: options for [hackney](https://github.com/benoitc/hackney).
|
||||
* `http`: options for [gun](https://github.com/ninenines/gun).
|
||||
|
||||
"""
|
||||
@default_options [pool: :media]
|
||||
@ -147,11 +147,11 @@ defmodule Pleroma.ReverseProxy do
|
||||
|> halt()
|
||||
end
|
||||
|
||||
defp request(method, url, headers, hackney_opts) do
|
||||
defp request(method, url, headers, opts) do
|
||||
Logger.debug("#{__MODULE__} #{method} #{url} #{inspect(headers)}")
|
||||
method = method |> String.downcase() |> String.to_existing_atom()
|
||||
|
||||
case client().request(method, url, headers, "", hackney_opts) do
|
||||
case client().request(method, url, headers, "", opts) do
|
||||
{:ok, code, headers, client} when code in @valid_resp_codes ->
|
||||
{:ok, code, downcase_headers(headers), client}
|
||||
|
||||
|
@ -95,7 +95,6 @@ defmodule Pleroma.Web.AdminAPI.Config do
|
||||
end
|
||||
|
||||
defp do_convert({:dispatch, [entity]}), do: %{"tuple" => [":dispatch", [inspect(entity)]]}
|
||||
defp do_convert({:partial_chain, entity}), do: %{"tuple" => [":partial_chain", inspect(entity)]}
|
||||
|
||||
defp do_convert(entity) when is_tuple(entity),
|
||||
do: %{"tuple" => do_convert(Tuple.to_list(entity))}
|
||||
@ -129,11 +128,6 @@ defmodule Pleroma.Web.AdminAPI.Config do
|
||||
{:dispatch, [dispatch_settings]}
|
||||
end
|
||||
|
||||
defp do_transform(%{"tuple" => [":partial_chain", entity]}) do
|
||||
{partial_chain, []} = do_eval(entity)
|
||||
{:partial_chain, partial_chain}
|
||||
end
|
||||
|
||||
defp do_transform(%{"tuple" => entity}) do
|
||||
Enum.reduce(entity, {}, fn val, acc -> Tuple.append(acc, do_transform(val)) end)
|
||||
end
|
||||
|
@ -1,15 +0,0 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReverseProxy.Client.HackneyTest do
|
||||
use Pleroma.ReverseProxyClientCase, client: Pleroma.ReverseProxy.Client.Hackney
|
||||
|
||||
defp check_ref(ref) do
|
||||
assert is_reference(ref)
|
||||
end
|
||||
|
||||
defp close(ref) do
|
||||
Pleroma.ReverseProxy.Client.Hackney.close(ref)
|
||||
end
|
||||
end
|
@ -301,21 +301,6 @@ defmodule Pleroma.ReverseProxyTest do
|
||||
describe "integration tests" do
|
||||
@describetag :integration
|
||||
|
||||
test "with hackney client", %{conn: conn} do
|
||||
client = Pleroma.Config.get([Pleroma.ReverseProxy.Client])
|
||||
Pleroma.Config.put([Pleroma.ReverseProxy.Client], Pleroma.ReverseProxy.Client.Hackney)
|
||||
|
||||
on_exit(fn ->
|
||||
Pleroma.Config.put([Pleroma.ReverseProxy.Client], client)
|
||||
end)
|
||||
|
||||
conn = ReverseProxy.call(conn, "http://httpbin.org/stream-bytes/10")
|
||||
|
||||
assert byte_size(conn.resp_body) == 10
|
||||
assert conn.state == :chunked
|
||||
assert conn.status == 200
|
||||
end
|
||||
|
||||
test "with tesla client with gun adapter", %{conn: conn} do
|
||||
client = Pleroma.Config.get([Pleroma.ReverseProxy.Client])
|
||||
Pleroma.Config.put([Pleroma.ReverseProxy.Client], Pleroma.ReverseProxy.Client.Tesla)
|
||||
|
@ -1551,8 +1551,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
||||
%{"tuple" => [":method", "Pleroma.Captcha.Kocaptcha"]},
|
||||
%{"tuple" => [":seconds_valid", 60]},
|
||||
%{"tuple" => [":path", ""]},
|
||||
%{"tuple" => [":key1", nil]},
|
||||
%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]}
|
||||
%{"tuple" => [":key1", nil]}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -1568,8 +1567,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
||||
%{"tuple" => [":method", "Pleroma.Captcha.Kocaptcha"]},
|
||||
%{"tuple" => [":seconds_valid", 60]},
|
||||
%{"tuple" => [":path", ""]},
|
||||
%{"tuple" => [":key1", nil]},
|
||||
%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]}
|
||||
%{"tuple" => [":key1", nil]}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -238,14 +238,6 @@ defmodule Pleroma.Web.AdminAPI.ConfigTest do
|
||||
assert Config.from_binary(binary) == [key: "value"]
|
||||
end
|
||||
|
||||
test "keyword with partial_chain key" do
|
||||
binary =
|
||||
Config.transform([%{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]}])
|
||||
|
||||
assert binary == :erlang.term_to_binary(partial_chain: &:hackney_connect.partial_chain/1)
|
||||
assert Config.from_binary(binary) == [partial_chain: &:hackney_connect.partial_chain/1]
|
||||
end
|
||||
|
||||
test "keyword" do
|
||||
binary =
|
||||
Config.transform([
|
||||
|
Loading…
Reference in New Issue
Block a user