From 3ff083f15709c8d1ea51f0abec0ef09fdf4b57b6 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Thu, 30 Mar 2023 12:44:12 -0400 Subject: [PATCH] Use only hostname check in tor plug --- lib/philomena_web/plugs/tor_plug.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/philomena_web/plugs/tor_plug.ex b/lib/philomena_web/plugs/tor_plug.ex index 484e0d22..1cd51f70 100644 --- a/lib/philomena_web/plugs/tor_plug.ex +++ b/lib/philomena_web/plugs/tor_plug.ex @@ -19,18 +19,17 @@ defmodule PhilomenaWeb.TorPlug do def call(conn, _opts) do onion? = onion?(conn.host) user = conn.assigns.current_user - ip = conn.remote_ip - maybe_redirect(conn, user, ip, onion?) + maybe_redirect(conn, user, onion?) end - def maybe_redirect(conn, nil, {127, 0, 0, 1}, true) do + def maybe_redirect(conn, nil, true) do conn |> Controller.redirect(to: Routes.session_path(conn, :new)) |> Conn.halt() end - def maybe_redirect(conn, _user, _ip, _onion?), do: conn + def maybe_redirect(conn, _user, _onion?), do: conn # This is allowed, because nginx won't forward the request # to the appserver if the hostname isn't in a specific list