Mercurial > prosody-hg
comparison plugins/mod_turn_external.lua @ 11599:ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 21 Jan 2021 23:13:37 +0100 |
| parents | |
| children | fe5a87b5972f |
comparison
equal
deleted
inserted
replaced
| 11598:081e550b973a | 11599:ed405b6357a8 |
|---|---|
| 1 local secret = module:get_option_string("turn_external_secret"); | |
| 2 local host = module:get_option_string("turn_external_host", module.host); | |
| 3 local user = module:get_option_string("turn_external_user"); | |
| 4 local port = module:get_option_number("turn_external_port", 3478); | |
| 5 local ttl = module:get_option_number("turn_external_ttl", 86400); | |
| 6 | |
| 7 local services = module:get_option_set("turn_external_services", {"stun-udp"; "turn-udp"}); | |
| 8 | |
| 9 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end | |
| 10 | |
| 11 module:depends "external_services"; | |
| 12 | |
| 13 for _, type in ipairs({"stun"; "turn"}) do | |
| 14 for _, transport in ipairs({"udp"; "tcp"}) do | |
| 15 if services:contains(type .. "-" .. transport) then | |
| 16 module:add_item("external_service", { | |
| 17 type = type; | |
| 18 transport = transport; | |
| 19 host = host; | |
| 20 port = port; | |
| 21 | |
| 22 username = type == "turn" and user or nil; | |
| 23 secret = type == "turn" and secret or nil; | |
| 24 ttl = type == "turn" and ttl or nil; | |
| 25 }) | |
| 26 end | |
| 27 end | |
| 28 end |
