25
1
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:
Paweł Chmielowski 2022-08-29 11:26:31 +02:00
parent cfc8746d29
commit fba651822d

View File

@ -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}.