Use upstream remote_ip package
This commit is contained in:
parent
2db3a9c04d
commit
c92d233233
7 changed files with 85 additions and 10 deletions
|
|
@ -106,4 +106,38 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
|
|||
|
||||
assert conn.remote_ip == {1, 1, 1, 1}
|
||||
end
|
||||
|
||||
test "reserved ranges are configurable" do
|
||||
clear_config([RemoteIp, :reserved], [])
|
||||
|
||||
conn =
|
||||
conn(:get, "/")
|
||||
|> put_req_header("x-forwarded-for", "1.1.1.1, 10.0.0.3")
|
||||
|> RemoteIp.call(nil)
|
||||
|
||||
assert conn.remote_ip == {10, 0, 0, 3}
|
||||
end
|
||||
|
||||
test "clients override reserved ranges" do
|
||||
clear_config([RemoteIp, :clients], ["10.0.0.0/8"])
|
||||
|
||||
conn =
|
||||
conn(:get, "/")
|
||||
|> put_req_header("x-forwarded-for", "1.1.1.1, 10.0.0.3")
|
||||
|> RemoteIp.call(nil)
|
||||
|
||||
assert conn.remote_ip == {10, 0, 0, 3}
|
||||
end
|
||||
|
||||
test "clients override proxies" do
|
||||
clear_config([RemoteIp, :clients], ["10.0.0.3"])
|
||||
clear_config([RemoteIp, :proxies], ["10.0.0.0/8"])
|
||||
|
||||
conn =
|
||||
conn(:get, "/")
|
||||
|> put_req_header("x-forwarded-for", "1.1.1.1, 10.0.0.3")
|
||||
|> RemoteIp.call(nil)
|
||||
|
||||
assert conn.remote_ip == {10, 0, 0, 3}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue