aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-07-07 09:23:11 +0400
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2014-07-07 09:40:01 +0400
commitee40c0e9a791f9e10b9ec3e88d4cea2b3f3dcd4c (patch)
tree9f9e3247d8a4a486af7b27399e0b66fc12627462 /src
parentMerge pull request #243 from matwey/master (diff)
Add new option support: always_record_route
Diffstat (limited to 'src')
-rw-r--r--src/mod_sip_proxy.erl27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/mod_sip_proxy.erl b/src/mod_sip_proxy.erl
index b08a8d929..bf26c9944 100644
--- a/src/mod_sip_proxy.erl
+++ b/src/mod_sip_proxy.erl
@@ -277,13 +277,19 @@ add_via(#sip_socket{type = Transport}, LServer, #sip{hdrs = Hdrs} = Req) ->
add_record_route_and_set_uri(URI, LServer, #sip{hdrs = Hdrs} = Req) ->
case is_request_within_dialog(Req) of
false ->
- RR_URI = get_configured_record_route(LServer),
- {MSecs, Secs, _} = now(),
- TS = list_to_binary(integer_to_list(MSecs*1000000 + Secs)),
- Sign = make_sign(TS, Hdrs),
- NewRR_URI = RR_URI#uri{user = <<TS/binary, $-, Sign/binary>>},
- Hdrs1 = [{'record-route', [{<<>>, NewRR_URI, []}]}|Hdrs],
- Req#sip{uri = URI, hdrs = Hdrs1};
+ case need_record_route(LServer) of
+ true ->
+ RR_URI = get_configured_record_route(LServer),
+ {MSecs, Secs, _} = now(),
+ TS = list_to_binary(integer_to_list(MSecs*1000000 + Secs)),
+ Sign = make_sign(TS, Hdrs),
+ User = <<TS/binary, $-, Sign/binary>>,
+ NewRR_URI = RR_URI#uri{user = User},
+ Hdrs1 = [{'record-route', [{<<>>, NewRR_URI, []}]}|Hdrs],
+ Req#sip{uri = URI, hdrs = Hdrs1};
+ false ->
+ Req
+ end;
true ->
Req
end.
@@ -292,6 +298,13 @@ is_request_within_dialog(#sip{hdrs = Hdrs}) ->
{_, _, Params} = esip:get_hdr('to', Hdrs),
esip:has_param(<<"tag">>, Params).
+need_record_route(LServer) ->
+ gen_mod:get_module_opt(
+ LServer, mod_sip, always_record_route,
+ fun(true) -> true;
+ (false) -> false
+ end, true).
+
make_sign(TS, Hdrs) ->
{_, #uri{user = FUser, host = FServer}, FParams} = esip:get_hdr('from', Hdrs),
{_, #uri{user = TUser, host = TServer}, _} = esip:get_hdr('to', Hdrs),