|
@@ -33,6 +33,12 @@ local roomless_iqs = {};
|
33
|
33
|
-- (e.g. from room1@conference.foo.example.com/res returns (room1, example.com, res, foo))
|
34
|
34
|
local function room_jid_split_subdomain(room_jid)
|
35
|
35
|
local node, host, resource = jid.split(room_jid);
|
|
36
|
+
|
|
37
|
+ -- optimization, skip matching if there is no subdomain or it is not the muc component address at all
|
|
38
|
+ if host == muc_domain or not starts_with(host, muc_domain_prefix) then
|
|
39
|
+ return node, host, resource;
|
|
40
|
+ end
|
|
41
|
+
|
36
|
42
|
local target_subdomain = host and host:match(target_subdomain_pattern);
|
37
|
43
|
return node, host, resource, target_subdomain
|
38
|
44
|
end
|
|
@@ -80,11 +86,13 @@ local function internal_room_jid_match_rewrite(room_jid, stanza)
|
80
|
86
|
|
81
|
87
|
return room_jid;
|
82
|
88
|
end
|
83
|
|
- local target_subdomain, target_node = node:match("^%[([^%]]+)%](.+)$");
|
|
89
|
+
|
|
90
|
+ local target_subdomain, target_node = extract_subdomain(node);
|
84
|
91
|
if not (target_node and target_subdomain) then
|
85
|
92
|
-- module:log("debug", "Not rewriting... unexpected node format: %s", node);
|
86
|
93
|
return room_jid;
|
87
|
94
|
end
|
|
95
|
+
|
88
|
96
|
-- Ok, rewrite room_jid address to pretty format
|
89
|
97
|
local new_node, new_host, new_resource = target_node, muc_domain_prefix..".".. target_subdomain.."."..muc_domain_base, resource;
|
90
|
98
|
room_jid = jid.join(new_node, new_host, new_resource);
|
|
@@ -226,6 +234,17 @@ function is_feature_allowed(session, feature)
|
226
|
234
|
end
|
227
|
235
|
end
|
228
|
236
|
|
|
237
|
+--- Extracts the subdomain and room name from internal jid node [foo]room1
|
|
238
|
+-- @return subdomain(optional, if extracted or nil), the room name
|
|
239
|
+function extract_subdomain(room_node)
|
|
240
|
+ -- optimization, skip matching if there is no subdomain, no [subdomain] part in the beginning of the node
|
|
241
|
+ if not starts_with(room_node, '[') then
|
|
242
|
+ return room_node;
|
|
243
|
+ end
|
|
244
|
+
|
|
245
|
+ return room_node:match("^%[([^%]]+)%](.+)$");
|
|
246
|
+end
|
|
247
|
+
|
229
|
248
|
function starts_with(str, start)
|
230
|
249
|
return str:sub(1, #start) == start
|
231
|
250
|
end
|
|
@@ -306,6 +325,7 @@ function http_get_with_retry(url, retry)
|
306
|
325
|
end
|
307
|
326
|
|
308
|
327
|
return {
|
|
328
|
+ extract_subdomain = extract_subdomain;
|
309
|
329
|
is_feature_allowed = is_feature_allowed;
|
310
|
330
|
is_healthcheck_room = is_healthcheck_room;
|
311
|
331
|
get_room_from_jid = get_room_from_jid;
|