Software /
code /
prosody
Comparison
plugins/mod_turn_external.lua @ 12283:b5686debb497
mod_turn_external: Add option to enable TURN over TLS
Usually on port 443 to avoid restrictive firewalls.
Thanks to Holger for discussion
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 10 Feb 2022 15:41:47 +0100 |
parent | 12282:fe5a87b5972f |
child | 12290:aa7a8aa64d3f |
comparison
equal
deleted
inserted
replaced
12282:fe5a87b5972f | 12283:b5686debb497 |
---|---|
4 local host = module:get_option_string("turn_external_host", module.host); | 4 local host = module:get_option_string("turn_external_host", module.host); |
5 local user = module:get_option_string("turn_external_user"); | 5 local user = module:get_option_string("turn_external_user"); |
6 local port = module:get_option_number("turn_external_port", 3478); | 6 local port = module:get_option_number("turn_external_port", 3478); |
7 local ttl = module:get_option_number("turn_external_ttl", 86400); | 7 local ttl = module:get_option_number("turn_external_ttl", 86400); |
8 local tcp = module:get_option_boolean("turn_external_tcp", false); | 8 local tcp = module:get_option_boolean("turn_external_tcp", false); |
9 local tls_port = module:get_option_boolean("turn_external_tls_port"); | |
9 | 10 |
10 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end | 11 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end |
11 | 12 |
12 local services = set.new({ "stun-udp"; "turn-udp" }); | 13 local services = set.new({ "stun-udp"; "turn-udp" }); |
13 if tcp then | 14 if tcp then |
14 services:add("stun-tcp"); | 15 services:add("stun-tcp"); |
15 services:add("turn-tcp"); | 16 services:add("turn-tcp"); |
16 end | 17 end |
18 if tls_port then | |
19 services:add("turns-tcp"); | |
20 end | |
17 | 21 |
18 module:depends "external_services"; | 22 module:depends "external_services"; |
19 | 23 |
20 for _, type in ipairs({"stun"; "turn"}) do | 24 for _, type in ipairs({ "stun"; "turn"; "turns" }) do |
21 for _, transport in ipairs({"udp"; "tcp"}) do | 25 for _, transport in ipairs({"udp"; "tcp"}) do |
22 if services:contains(type .. "-" .. transport) then | 26 if services:contains(type .. "-" .. transport) then |
23 module:add_item("external_service", { | 27 module:add_item("external_service", { |
24 type = type; | 28 type = type; |
25 transport = transport; | 29 transport = transport; |
26 host = host; | 30 host = host; |
27 port = port; | 31 port = type == "turns" and tls_port or port; |
28 | 32 |
29 username = type == "turn" and user or nil; | 33 username = type == "turn" and user or nil; |
30 secret = type == "turn" and secret or nil; | 34 secret = type == "turn" and secret or nil; |
31 ttl = type == "turn" and ttl or nil; | 35 ttl = type == "turn" and ttl or nil; |
32 }) | 36 }) |