projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ListController: DRY up stuff.
[akkoma]
/
lib
/
pleroma
/
plugs
/
remote_ip.ex
diff --git
a/lib/pleroma/plugs/remote_ip.ex
b/lib/pleroma/plugs/remote_ip.ex
index 1cd5af48adeecf7f9a5f09edb90f08ee507d48cd..0ac9050d0764149e2361811016179f1282b20c82 100644
(file)
--- a/
lib/pleroma/plugs/remote_ip.ex
+++ b/
lib/pleroma/plugs/remote_ip.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Plugs.RemoteIp do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Plugs.RemoteIp do
@@
-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.
"""
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[
@behaviour Plug
@headers ~w[
@@
-26,11
+28,12
@@
defmodule Pleroma.Plugs.RemoteIp do
def init(_), do: nil
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
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
else
conn
end