diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-12-07 20:09:34 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2020-12-07 20:11:47 +0100 |
commit | e1a2e8b17cca0d9f50b72fcea0ec5ffb8e613db1 (patch) | |
tree | f4246be3d6dc480660310e5d1f58e1c764297b9b /lib | |
parent | ed76323776f2506cfefbe78c369fdb7ccfe3b650 (diff) | |
download | pleroma-e1a2e8b17cca0d9f50b72fcea0ec5ffb8e613db1.tar.gz |
instance: Do not fetch unreachable instances
Closes: https://git.pleroma.social/pleroma/pleroma/-/issues/2346
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/instances/instance.ex | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/pleroma/instances/instance.ex b/lib/pleroma/instances/instance.ex index df471a39d..c9ca3aac7 100644 --- a/lib/pleroma/instances/instance.ex +++ b/lib/pleroma/instances/instance.ex @@ -166,7 +166,8 @@ defmodule Pleroma.Instances.Instance do defp scrape_favicon(%URI{} = instance_uri) do try do - with {:ok, %Tesla.Env{body: html}} <- + with {_, true} <- {:reachable, reachable?(instance_uri.host)}, + {:ok, %Tesla.Env{body: html}} <- Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}], pool: :media), {_, [favicon_rel | _]} when is_binary(favicon_rel) <- {:parse, @@ -175,7 +176,15 @@ defmodule Pleroma.Instances.Instance do {:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do favicon else - _ -> nil + {:reachable, false} -> + Logger.debug( + "Instance.scrape_favicon(\"#{to_string(instance_uri)}\") ignored unreachable host" + ) + + nil + + _ -> + nil end rescue e -> |