Commit 599b75b1 authored by kaniini's avatar kaniini Committed by Alexander Strizhakov

purge all remaining hackney usage and references from the tree

parent d6ccfe06
......@@ -56,20 +56,6 @@
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 @@
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
]
]
......
......@@ -39,7 +39,6 @@ def start(_type, _args) do
Pleroma.ActivityExpirationWorker
] ++
cachex_children() ++
hackney_pool_children() ++
gun_pools() ++
[
Pleroma.Web.Federator.RetryQueue,
......@@ -96,20 +95,6 @@ defp setup_instrumenters 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()),
......@@ -159,13 +144,6 @@ defp chat_child(_env, true) 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
......
# 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 @@ def call(conn, _, _) 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 @@ defp do_convert(entity) when is_map(entity) 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 @@ defp do_transform(%{"tuple" => [":dispatch", [entity]]}) 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
......
# 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 @@ test "with content-disposition header", %{conn: conn} 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)
......
......@@ -1778,8 +1778,7 @@ test "common config example", %{conn: conn} 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]}
]
}
]
......@@ -1795,8 +1794,7 @@ test "common config example", %{conn: conn} 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 @@ test "simple keyword" 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([
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment