mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Catch errors when calling inet:peername in ejabberd_http
This commit is contained in:
parent
6d16029716
commit
f89db30d77
@ -160,7 +160,11 @@ init({SockMod, Socket}, Opts) ->
|
|||||||
default_host = DefaultHost,
|
default_host = DefaultHost,
|
||||||
options = Opts,
|
options = Opts,
|
||||||
request_handlers = RequestHandlers},
|
request_handlers = RequestHandlers},
|
||||||
receive_headers(State).
|
try receive_headers(State) of
|
||||||
|
V -> V
|
||||||
|
catch
|
||||||
|
{error, _} -> State
|
||||||
|
end.
|
||||||
|
|
||||||
become_controller(_Pid) -> ok.
|
become_controller(_Pid) -> ok.
|
||||||
|
|
||||||
@ -427,13 +431,17 @@ process_request(#state{request_method = Method,
|
|||||||
false ->
|
false ->
|
||||||
make_bad_request(State);
|
make_bad_request(State);
|
||||||
{LPath, LQuery, Data} ->
|
{LPath, LQuery, Data} ->
|
||||||
{ok, IPHere} =
|
PeerName =
|
||||||
case SockMod of
|
case SockMod of
|
||||||
gen_tcp ->
|
gen_tcp ->
|
||||||
inet:peername(Socket);
|
inet:peername(Socket);
|
||||||
_ ->
|
_ ->
|
||||||
SockMod:peername(Socket)
|
SockMod:peername(Socket)
|
||||||
end,
|
end,
|
||||||
|
IPHere = case PeerName of
|
||||||
|
{ok, V} -> V;
|
||||||
|
{error, _} = E -> throw(E)
|
||||||
|
end,
|
||||||
XFF = proplists:get_value('X-Forwarded-For', RequestHeaders, []),
|
XFF = proplists:get_value('X-Forwarded-For', RequestHeaders, []),
|
||||||
IP = analyze_ip_xff(IPHere, XFF, Host),
|
IP = analyze_ip_xff(IPHere, XFF, Host),
|
||||||
Request = #request{method = Method,
|
Request = #request{method = Method,
|
||||||
|
Loading…
Reference in New Issue
Block a user