Comparison

plugins/mod_turn_external.lua @ 12282:fe5a87b5972f

mod_turn_external: Simplify configuration Much harder to get boolean options wrong than accidentally adding something unrecognised to a Set.
author Kim Alvefur <zash@zash.se>
date Thu, 10 Feb 2022 15:39:15 +0100
parent 11599:ed405b6357a8
child 12283:b5686debb497
comparison
equal deleted inserted replaced
12281:9016071867d7 12282:fe5a87b5972f
1 local set = require "util.set";
2
1 local secret = module:get_option_string("turn_external_secret"); 3 local secret = module:get_option_string("turn_external_secret");
2 local host = module:get_option_string("turn_external_host", module.host); 4 local host = module:get_option_string("turn_external_host", module.host);
3 local user = module:get_option_string("turn_external_user"); 5 local user = module:get_option_string("turn_external_user");
4 local port = module:get_option_number("turn_external_port", 3478); 6 local port = module:get_option_number("turn_external_port", 3478);
5 local ttl = module:get_option_number("turn_external_ttl", 86400); 7 local ttl = module:get_option_number("turn_external_ttl", 86400);
6 8 local tcp = module:get_option_boolean("turn_external_tcp", false);
7 local services = module:get_option_set("turn_external_services", {"stun-udp"; "turn-udp"});
8 9
9 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end 10 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end
11
12 local services = set.new({ "stun-udp"; "turn-udp" });
13 if tcp then
14 services:add("stun-tcp");
15 services:add("turn-tcp");
16 end
10 17
11 module:depends "external_services"; 18 module:depends "external_services";
12 19
13 for _, type in ipairs({"stun"; "turn"}) do 20 for _, type in ipairs({"stun"; "turn"}) do
14 for _, transport in ipairs({"udp"; "tcp"}) do 21 for _, transport in ipairs({"udp"; "tcp"}) do