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)
|
TrustedProxies)
|
||||||
of
|
of
|
||||||
true ->
|
true ->
|
||||||
{ok, IPFirst} = inet_parse:address(
|
case inet_parse:address(binary_to_list(ClientIP)) of
|
||||||
binary_to_list(ClientIP)),
|
{ok, IPFirst} ->
|
||||||
?DEBUG("The IP ~w was replaced with ~w due to "
|
?DEBUG("The IP ~w was replaced with ~w due to "
|
||||||
"header X-Forwarded-For: ~ts",
|
"header X-Forwarded-For: ~ts",
|
||||||
[IPLast, IPFirst, XFF]),
|
[IPLast, IPFirst, XFF]),
|
||||||
IPFirst;
|
IPFirst;
|
||||||
|
E -> throw(E)
|
||||||
|
end;
|
||||||
false -> IPLast
|
false -> IPLast
|
||||||
end,
|
end,
|
||||||
{IPClient, Port}.
|
{IPClient, Port}.
|
||||||
|
|
Loading…
Reference in New Issue