annotate mod_turn_external/mod_turn_external.lua @ 5416:2393dbae51ed

mod_http_oauth2: Add option for specifying TTL of registered clients Meant to simplify configuration, since TTL vs ignoring expiration is expected to be the main thing one would want to configure. Unsure what the implications of having unlimited lifetime of clients are, given no way to revoke them currently, short of rotating the signing secret. On one hand, it would be annoying to have the client expire. On the other hand, it is trivial to re-register it.
author Kim Alvefur <zash@zash.se>
date Thu, 04 May 2023 18:41:33 +0200
parents 2542fd80cd15
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4894
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local set = require "util.set";
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local secret = module:get_option_string("turn_external_secret");
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local host = module:get_option_string("turn_external_host", module.host);
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local user = module:get_option_string("turn_external_user");
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local port = module:get_option_number("turn_external_port", 3478);
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local ttl = module:get_option_number("turn_external_ttl", 86400);
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local tcp = module:get_option_boolean("turn_external_tcp", false);
4895
2542fd80cd15 mod_turn_external: Fix type of config option (thanks mirux)
Kim Alvefur <zash@zash.se>
parents: 4894
diff changeset
9 local tls_port = module:get_option_number("turn_external_tls_port");
4894
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local services = set.new({ "stun-udp"; "turn-udp" });
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 if tcp then
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 services:add("stun-tcp");
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 services:add("turn-tcp");
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 if tls_port then
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 services:add("turns-tcp");
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 end
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 module:depends "external_services";
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 for _, type in ipairs({ "stun"; "turn"; "turns" }) do
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 for _, transport in ipairs({"udp"; "tcp"}) do
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 if services:contains(type .. "-" .. transport) then
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 module:add_item("external_service", {
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 type = type;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 transport = transport;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 host = host;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 port = type == "turns" and tls_port or port;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 username = type == "turn" and user or nil;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 secret = type == "turn" and secret or nil;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 ttl = type == "turn" and ttl or nil;
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 })
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 end
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 end
bfa2cca2bdd5 mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 end