mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Add new option support: always_record_route
This commit is contained in:
parent
9a55ffba7a
commit
ee40c0e9a7
@ -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) ->
|
add_record_route_and_set_uri(URI, LServer, #sip{hdrs = Hdrs} = Req) ->
|
||||||
case is_request_within_dialog(Req) of
|
case is_request_within_dialog(Req) of
|
||||||
false ->
|
false ->
|
||||||
RR_URI = get_configured_record_route(LServer),
|
case need_record_route(LServer) of
|
||||||
{MSecs, Secs, _} = now(),
|
true ->
|
||||||
TS = list_to_binary(integer_to_list(MSecs*1000000 + Secs)),
|
RR_URI = get_configured_record_route(LServer),
|
||||||
Sign = make_sign(TS, Hdrs),
|
{MSecs, Secs, _} = now(),
|
||||||
NewRR_URI = RR_URI#uri{user = <<TS/binary, $-, Sign/binary>>},
|
TS = list_to_binary(integer_to_list(MSecs*1000000 + Secs)),
|
||||||
Hdrs1 = [{'record-route', [{<<>>, NewRR_URI, []}]}|Hdrs],
|
Sign = make_sign(TS, Hdrs),
|
||||||
Req#sip{uri = URI, hdrs = Hdrs1};
|
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 ->
|
true ->
|
||||||
Req
|
Req
|
||||||
end.
|
end.
|
||||||
@ -292,6 +298,13 @@ is_request_within_dialog(#sip{hdrs = Hdrs}) ->
|
|||||||
{_, _, Params} = esip:get_hdr('to', Hdrs),
|
{_, _, Params} = esip:get_hdr('to', Hdrs),
|
||||||
esip:has_param(<<"tag">>, Params).
|
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) ->
|
make_sign(TS, Hdrs) ->
|
||||||
{_, #uri{user = FUser, host = FServer}, FParams} = esip:get_hdr('from', Hdrs),
|
{_, #uri{user = FUser, host = FServer}, FParams} = esip:get_hdr('from', Hdrs),
|
||||||
{_, #uri{user = TUser, host = TServer}, _} = esip:get_hdr('to', Hdrs),
|
{_, #uri{user = TUser, host = TServer}, _} = esip:get_hdr('to', Hdrs),
|
||||||
|
Loading…
Reference in New Issue
Block a user