Software /
code /
prosody
Annotate
plugins/mod_turn_external.lua @ 11869:d52a73425eba
util.startup: Show brief usage on `prosody -h|-?|--help`
Seems more suitable than asking if prosodyctl was meant to be used, or
going ahead and starting.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 25 Oct 2021 15:46:01 +0200 |
parent | 11599:ed405b6357a8 |
child | 12282:fe5a87b5972f |
rev | line source |
---|---|
11599
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local secret = module:get_option_string("turn_external_secret"); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local host = module:get_option_string("turn_external_host", module.host); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local user = module:get_option_string("turn_external_user"); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local port = module:get_option_number("turn_external_port", 3478); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local ttl = module:get_option_number("turn_external_ttl", 86400); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local services = module:get_option_set("turn_external_services", {"stun-udp"; "turn-udp"}); |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 module:depends "external_services"; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 for _, type in ipairs({"stun"; "turn"}) do |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 for _, transport in ipairs({"udp"; "tcp"}) do |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 if services:contains(type .. "-" .. transport) then |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 module:add_item("external_service", { |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 type = type; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 transport = transport; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 host = host; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 port = port; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 username = type == "turn" and user or nil; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 secret = type == "turn" and secret or nil; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 ttl = type == "turn" and ttl or nil; |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 }) |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 end |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
ed405b6357a8
mod_turn_external: Simple module to offer TURN(+STUN) via mod_external_services
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 end |