mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Handle invalid values in X-Forwarded-For header more gracefuly
This commit is contained in:
parent
cfc8746d29
commit
fba651822d
@ -535,12 +535,14 @@ analyze_ip_xff({IPLast, Port}, XFF) ->
|
||||
TrustedProxies)
|
||||
of
|
||||
true ->
|
||||
{ok, IPFirst} = inet_parse:address(
|
||||
binary_to_list(ClientIP)),
|
||||
?DEBUG("The IP ~w was replaced with ~w due to "
|
||||
"header X-Forwarded-For: ~ts",
|
||||
[IPLast, IPFirst, XFF]),
|
||||
IPFirst;
|
||||
case inet_parse:address(binary_to_list(ClientIP)) of
|
||||
{ok, IPFirst} ->
|
||||
?DEBUG("The IP ~w was replaced with ~w due to "
|
||||
"header X-Forwarded-For: ~ts",
|
||||
[IPLast, IPFirst, XFF]),
|
||||
IPFirst;
|
||||
E -> throw(E)
|
||||
end;
|
||||
false -> IPLast
|
||||
end,
|
||||
{IPClient, Port}.
|
||||
|
Loading…
Reference in New Issue
Block a user