annotate mod_turn_external/mod_turn_external.lua @ 5511:0860497152af

mod_http_oauth2: Record hash of client_id to allow future verification RFC 6819 section 5.2.2.2 states that refresh tokens MUST be bound to the client. In order to do that, we must record something that can definitely tie the client to the grant. Since the full client_id is so large (why we have this client_subset function), a hash is stored instead.
author Kim Alvefur <zash@zash.se>
date Fri, 02 Jun 2023 10:14:16 +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