diff options
author | rinpatch <rinpatch@sdf.org> | 2020-03-13 21:15:42 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-03-13 21:41:17 +0300 |
commit | fc4496d4fa45b0389f8476b2c2ee00d647a1dfbe (patch) | |
tree | c917ced57828d225ea898ebe26c1d4b0e8205826 /lib/pleroma/plugs/remote_ip.ex | |
parent | 00d17520314e3591caaa7ab4ca39c6227a6bdf15 (diff) | |
download | pleroma-fc4496d4fa45b0389f8476b2c2ee00d647a1dfbe.tar.gz |
rate limiter: disable based on if remote ip was found, not on if the plug was enabled
The current rate limiter disable logic won't trigger when the remote ip
is not forwarded, only when the remoteip plug is not enabled, which is
not the case on most instances since it's enabled by default. This
changes the behavior to warn and disable when the remote ip was not forwarded,
even if the RemoteIP plug is enabled.
Also closes #1620
Diffstat (limited to 'lib/pleroma/plugs/remote_ip.ex')
-rw-r--r-- | lib/pleroma/plugs/remote_ip.ex | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pleroma/plugs/remote_ip.ex b/lib/pleroma/plugs/remote_ip.ex index 2eca4f8f6..0ac9050d0 100644 --- a/lib/pleroma/plugs/remote_ip.ex +++ b/lib/pleroma/plugs/remote_ip.ex @@ -7,6 +7,8 @@ defmodule Pleroma.Plugs.RemoteIp do This is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration. """ + import Plug.Conn + @behaviour Plug @headers ~w[ @@ -26,11 +28,12 @@ defmodule Pleroma.Plugs.RemoteIp do def init(_), do: nil - def call(conn, _) do + def call(%{remote_ip: original_remote_ip} = conn, _) do config = Pleroma.Config.get(__MODULE__, []) if Keyword.get(config, :enabled, false) do - RemoteIp.call(conn, remote_ip_opts(config)) + %{remote_ip: new_remote_ip} = conn = RemoteIp.call(conn, remote_ip_opts(config)) + assign(conn, :remote_ip_found, original_remote_ip != new_remote_ip) else conn end |