Skip to content

Commit

Permalink
Make SIP transport configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
gustawlippa committed Mar 21, 2022
1 parent 9d733e7 commit 094cb04
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions doc/modules/mod_jingle_sip.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ The value used to create SIP URIs (including VIA headers).

The value of the `c=` SDP attribute.

### `modules.mod_jingle_sip.transport`
* **Syntax:** string
* **Default:** `"udp"`
* **Example:** `transport = "tcp"`

The SIP transport parameter used when calling the proxy.

The simplest configuration is the following:

```toml
Expand Down
9 changes: 6 additions & 3 deletions src/jingle_sip/mod_jingle_sip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,17 @@ config_spec() ->
<<"local_host">> => #option{type = string,
validate = network_address},
<<"sdp_origin">> => #option{type = string,
validate = ip_address}
validate = ip_address},
<<"transport">> => #option{type = string,
validate = {enum, ["udp", "tcp"]}}
},
format_items = map,
defaults = #{<<"proxy_host">> => "localhost",
<<"proxy_port">> => 5060,
<<"listen_port">> => 5600,
<<"local_host">> => "localhost",
<<"sdp_origin">> => "127.0.0.1"}
<<"sdp_origin">> => "127.0.0.1",
<<"transport">> => "udp"}
}.
hooks(Host) ->
[{c2s_preprocessing_hook, Host, ?MODULE, intercept_jingle_stanza, 75}].
Expand Down Expand Up @@ -364,7 +367,7 @@ make_user_header({User, _} = US) ->
get_proxy_uri(Server) ->
ProxyHost = gen_mod:get_module_opt(Server, ?MODULE, proxy_host),
ProxyPort = gen_mod:get_module_opt(Server, ?MODULE, proxy_port),
Transport = gen_mod:get_module_opt(Server, ?MODULE, transport, "udp"),
Transport = gen_mod:get_module_opt(Server, ?MODULE, transport),
PortStr = integer_to_list(ProxyPort),
[ProxyHost, ":", PortStr, ";transport=", Transport].

Expand Down
2 changes: 1 addition & 1 deletion test/common/config_parser_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ default_mod_config(mod_inbox) ->
iqdisc => no_queue};
default_mod_config(mod_jingle_sip) ->
#{proxy_host => "localhost", proxy_port => 5060, listen_port => 5600,
local_host => "localhost", sdp_origin => "127.0.0.1"};
local_host => "localhost", sdp_origin => "127.0.0.1", transport => "udp"};
default_mod_config(mod_keystore) ->
#{ram_key_size => 2048, keys => #{}};
default_mod_config(mod_last) ->
Expand Down
2 changes: 2 additions & 0 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,8 @@ mod_jingle_sip(_Config) ->
T(#{<<"local_host">> => <<"localhost">>})),
?cfgh(P ++ [sdp_origin], "127.0.0.1",
T(#{<<"sdp_origin">> => <<"127.0.0.1">>})),
?cfgh(P ++ [transport], "tcp",
T(#{<<"transport">> => <<"tcp">>})),
?errh(T(#{<<"proxy_host">> => 1})),
?errh(T(#{<<"proxy_port">> => 1000000})),
?errh(T(#{<<"listen_port">> => -1})),
Expand Down

0 comments on commit 094cb04

Please sign in to comment.