Skip to content

Commit

Permalink
Fix config name for the ip_allowlist, allow old ip_whitelist (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
mworrell authored Mar 20, 2024
1 parent 26ce21a commit f7bbcd1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/cowmachine_proxy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ lower(C) -> C.
Result :: boolean().
is_trusted_proxy(Peer) ->
case application:get_env(cowmachine, proxy_allowlist) of
{ok, ip_whitelist} ->
% Map old config name
is_trusted_proxy(ip_allowlist, Peer);
{ok, ProxyAllowlist} ->
is_trusted_proxy(ProxyAllowlist, Peer);
undefined ->
Expand All @@ -305,7 +308,7 @@ is_trusted_proxy(Peer) ->

-spec is_trusted_proxy(Marker, Peer) -> Result when
Marker :: ProxyMarker | ProxyAllowlist,
ProxyMarker :: any | ip_whitelist | local | none,
ProxyMarker :: any | ip_allowlist | local | none,
ProxyAllowlist :: list() | binary(),
Peer :: inet:ip_address(),
Result :: boolean().
Expand All @@ -315,7 +318,7 @@ is_trusted_proxy(any, _Peer) ->
true;
is_trusted_proxy(local, Peer) ->
z_ip_address:is_local(Peer);
is_trusted_proxy(ip_whitelist, Peer) ->
is_trusted_proxy(ip_allowlist, Peer) ->
case application:get_env(cowmachine, ip_allowlist) of
{ok, Allowlist} ->
z_ip_address:ip_match(Peer, Allowlist);
Expand Down

0 comments on commit f7bbcd1

Please sign in to comment.