aboutsummaryrefslogtreecommitdiff
path: root/src/mod_sip.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_sip.erl')
-rw-r--r--src/mod_sip.erl30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/mod_sip.erl b/src/mod_sip.erl
index c018924fc..1572975e9 100644
--- a/src/mod_sip.erl
+++ b/src/mod_sip.erl
@@ -131,6 +131,20 @@ request(Req, SIPSock, TrID, Action) ->
locate(_SIPMsg) ->
ok.
+find(#uri{user = User, host = Host}) ->
+ LUser = jlib:nodeprep(User),
+ LServer = jlib:nameprep(Host),
+ if LUser == <<"">> ->
+ to_me;
+ true ->
+ case mod_sip_registrar:find_sockets(LUser, LServer) of
+ [] ->
+ not_found;
+ [_|_] ->
+ {relay, LServer}
+ end
+ end.
+
%%%===================================================================
%%% Internal functions
%%%===================================================================
@@ -177,13 +191,7 @@ action(#sip{method = Method, hdrs = Hdrs, type = request} = Req, SIPSock) ->
true ->
case at_my_host(ToURI) of
true ->
- case ToURI#uri.user of
- <<"">> ->
- to_me;
- _ ->
- LServer = jlib:nameprep(ToURI#uri.host),
- {relay, LServer}
- end;
+ find(ToURI);
false ->
LServer = jlib:nameprep(FromURI#uri.host),
{relay, LServer}
@@ -194,13 +202,7 @@ action(#sip{method = Method, hdrs = Hdrs, type = request} = Req, SIPSock) ->
false ->
case at_my_host(ToURI) of
true ->
- case ToURI#uri.user of
- <<"">> ->
- to_me;
- _ ->
- LServer = jlib:nameprep(ToURI#uri.host),
- {relay, LServer}
- end;
+ find(ToURI);
false ->
deny
end