From 26859c549c58901bbcc9dde009fd1cb81f6eb292 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Fri, 18 Sep 2020 17:49:15 -0500 Subject: [PATCH 1/2] Add user agent to fedsocket requests --- lib/pleroma/web/fed_sockets/outgoing_handler.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/fed_sockets/outgoing_handler.ex b/lib/pleroma/web/fed_sockets/outgoing_handler.ex index 6ddef17fe..3ff4a85e3 100644 --- a/lib/pleroma/web/fed_sockets/outgoing_handler.ex +++ b/lib/pleroma/web/fed_sockets/outgoing_handler.ex @@ -7,6 +7,7 @@ defmodule Pleroma.Web.FedSockets.OutgoingHandler do require Logger + alias Pleroma.Application alias Pleroma.Web.ActivityPub.InternalFetchActor alias Pleroma.Web.FedSockets alias Pleroma.Web.FedSockets.FedRegistry @@ -87,7 +88,10 @@ def initiate_connection(uri) do with {:ok, conn_pid} <- :gun.open(to_charlist(host), port), {:ok, _} <- :gun.await_up(conn_pid), - reference <- :gun.get(conn_pid, to_charlist(path)), + reference <- + :gun.get(conn_pid, to_charlist(path), [ + {'user-agent', to_charlist(Application.user_agent())} + ]), {:response, :fin, 204, _} <- :gun.await(conn_pid, reference), headers <- build_headers(uri), ref <- :gun.ws_upgrade(conn_pid, to_charlist(path), headers, %{silence_pings: false}) do @@ -132,7 +136,8 @@ defp build_headers(uri) do {'date', date}, {'digest', to_charlist(digest)}, {'content-length', to_charlist("#{shake_size}")}, - {to_charlist("(request-target)"), to_charlist(shake)} + {to_charlist("(request-target)"), to_charlist(shake)}, + {'user-agent', to_charlist(Application.user_agent())} ] end From 8afdbcdb1c012c37cde3a3d2bea147f95c5111b0 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Mon, 21 Sep 2020 10:13:41 -0500 Subject: [PATCH 2/2] Force HTTP for fedsockets --- lib/pleroma/web/fed_sockets/outgoing_handler.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/web/fed_sockets/outgoing_handler.ex b/lib/pleroma/web/fed_sockets/outgoing_handler.ex index 3ff4a85e3..e235a7c43 100644 --- a/lib/pleroma/web/fed_sockets/outgoing_handler.ex +++ b/lib/pleroma/web/fed_sockets/outgoing_handler.ex @@ -86,7 +86,7 @@ def initiate_connection(uri) do %{host: host, port: port, path: path} = URI.parse(ws_uri) - with {:ok, conn_pid} <- :gun.open(to_charlist(host), port), + with {:ok, conn_pid} <- :gun.open(to_charlist(host), port, %{protocols: [:http]}), {:ok, _} <- :gun.await_up(conn_pid), reference <- :gun.get(conn_pid, to_charlist(path), [