mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Do not proxy stray responses statelessly (as per RFC 6026)
This commit is contained in:
parent
e7e4055cbb
commit
a1337cb73f
@ -75,25 +75,8 @@ message_in(_, _) ->
|
|||||||
message_out(_, _) ->
|
message_out(_, _) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
response(Resp, SIPSock) ->
|
response(_Resp, _SIPSock) ->
|
||||||
case action(Resp, SIPSock) of
|
ok.
|
||||||
{relay, LServer} ->
|
|
||||||
case esip:split_hdrs('via', Resp#sip.hdrs) of
|
|
||||||
{[_], _} ->
|
|
||||||
ok;
|
|
||||||
{[_MyVia|Vias], TailHdrs} ->
|
|
||||||
%% TODO: check if MyVia is really my Via
|
|
||||||
NewResp = Resp#sip{hdrs = [{'via', Vias}|TailHdrs]},
|
|
||||||
case esip:connect(NewResp, add_certfile(LServer, [])) of
|
|
||||||
{ok, SIPSockOut} ->
|
|
||||||
esip:send(SIPSockOut, NewResp);
|
|
||||||
{error, _} ->
|
|
||||||
ok
|
|
||||||
end
|
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end.
|
|
||||||
|
|
||||||
request(_Req, _SIPSock) ->
|
request(_Req, _SIPSock) ->
|
||||||
error.
|
error.
|
||||||
@ -151,35 +134,6 @@ locate(_SIPMsg) ->
|
|||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
action(#sip{type = response, hdrs = Hdrs}, _SIPSock) ->
|
|
||||||
{_, ToURI, _} = esip:get_hdr('to', Hdrs),
|
|
||||||
{_, FromURI, _} = esip:get_hdr('from', Hdrs),
|
|
||||||
case at_my_host(FromURI) of
|
|
||||||
true ->
|
|
||||||
case at_my_host(ToURI) of
|
|
||||||
true ->
|
|
||||||
case ToURI#uri.user of
|
|
||||||
<<"">> ->
|
|
||||||
to_me;
|
|
||||||
_ ->
|
|
||||||
{relay, jlib:nameprep(ToURI#uri.host)}
|
|
||||||
end;
|
|
||||||
false ->
|
|
||||||
{relay, jlib:nameprep(FromURI#uri.host)}
|
|
||||||
end;
|
|
||||||
false ->
|
|
||||||
case at_my_host(ToURI) of
|
|
||||||
true ->
|
|
||||||
case ToURI#uri.user of
|
|
||||||
<<"">> ->
|
|
||||||
to_me;
|
|
||||||
_ ->
|
|
||||||
{relay, jlib:nameprep(ToURI#uri.host)}
|
|
||||||
end;
|
|
||||||
false ->
|
|
||||||
pass
|
|
||||||
end
|
|
||||||
end;
|
|
||||||
action(#sip{method = <<"REGISTER">>, type = request, hdrs = Hdrs,
|
action(#sip{method = <<"REGISTER">>, type = request, hdrs = Hdrs,
|
||||||
uri = #uri{user = <<"">>} = URI} = Req, SIPSock) ->
|
uri = #uri{user = <<"">>} = URI} = Req, SIPSock) ->
|
||||||
case at_my_host(URI) of
|
case at_my_host(URI) of
|
||||||
|
Loading…
Reference in New Issue
Block a user