Skip to content

Commit

Permalink
* feat: Stores vpaas check in room object.
Browse files Browse the repository at this point in the history
* feat: Clear queues on destroy for muc rate limit join/leave.

* feat: Stores vpaas check in room object.

* squash: Replace one regexp with starts_with.
  • Loading branch information
damencho authored Jan 22, 2024
1 parent 95ad04b commit 5871e50
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
4 changes: 2 additions & 2 deletions doc/jaas/move-to-jaas.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ apt install token-generator

mkdir -p /etc/jitsi/meet/jaas

VPASS_COOKIE=$(echo -n ${JAAS_KEY_ID}| cut -d/ -f1)
VPAAS_COOKIE=$(echo -n ${JAAS_KEY_ID}| cut -d/ -f1)
cp /usr/share/jitsi-meet-web-config/nginx-jaas.conf /etc/jitsi/meet/jaas
sed -i "s/jaas_magic_cookie/${VPASS_COOKIE}/g" /etc/jitsi/meet/jaas/nginx-jaas.conf
sed -i "s/jaas_magic_cookie/${VPAAS_COOKIE}/g" /etc/jitsi/meet/jaas/nginx-jaas.conf

cp /usr/share/jitsi-meet-web-config/8x8.vc-config.js /etc/jitsi/meet/jaas/
echo "set \$config_js_location /etc/jitsi/meet/jaas/8x8.vc-config.js;" >> /etc/jitsi/meet/jaas/jaas-vars
Expand Down
4 changes: 2 additions & 2 deletions resources/prosody-plugins/mod_fmuc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ module:hook('muc-broadcast-presence', function (event)
local session = sessions[occupant.jid];
local identity = session and session.jitsi_meet_context_user;

if is_vpaas(room.jid) and identity then
-- in case of moderator in vpass meeting we want to do auto-promotion
if is_vpaas(room) and identity then
-- in case of moderator in vpaas meeting we want to do auto-promotion
local is_vpaas_moderator = identity.moderator;
if is_vpaas_moderator == 'true' or is_vpaas_moderator == true then
is_moderator = true;
Expand Down
9 changes: 7 additions & 2 deletions resources/prosody-plugins/mod_muc_rate_limit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end
-- process join_rate_presence_queue in the room and pops element passing them to handle_normal_presence
-- returns 1 if we want to reschedule it after 1 second
local function timer_process_queue_elements (rate, queue, process, queue_empty_cb)
if not queue or queue:count() == 0 then
if not queue or queue:count() == 0 or queue.empty then
return;
end

Expand Down Expand Up @@ -152,7 +152,12 @@ end, 9); -- as we will rate limit joins we need to be the first to execute

-- clear queue on room destroy so timer will skip next run if any
module:hook('muc-room-destroyed',function(event)
event.room.join_rate_presence_queue = nil;
if event.room.join_rate_presence_queue then
event.room.join_rate_presence_queue.empty = true;
end
if event.room.leave_rate_presence_queue then
event.room.leave_rate_presence_queue.empty = true;
end
end);

module:hook('muc-occupant-pre-leave', function (event)
Expand Down
4 changes: 2 additions & 2 deletions resources/prosody-plugins/mod_visitors_component.lua
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ local function stanza_handler(event)
end

local force_promote = request_promotion.attr.forcePromote;
if force_promote == 'true' and not is_vpaas(room.jid) then
module:log('warn', 'Received promotion request for non vpass room (%s) with forced promotion: ',
if force_promote == 'true' and not is_vpaas(room) then
module:log('warn', 'Received promotion request for non vpaas room (%s) with forced promotion: ',
room.jid, stanza);
return true; -- stop processing
end
Expand Down
32 changes: 21 additions & 11 deletions resources/prosody-plugins/util.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -416,25 +416,35 @@ function is_moderated(room_jid)
return false;
end

-- check if the room tenant starts with
-- vpaas-magic-cookie-
function is_vpaas(room_jid)
local node, host = jid.split(room_jid);
-- check if the room tenant starts with vpaas-magic-cookie-
-- @param room the room to check
function is_vpaas(room)
if not room then
return false;
end

-- stored check in room object if it exist
if room.is_vpaas ~= nil then
return room.is_vpaas;
end

room.is_vpaas = false;

local node, host = jid.split(room.jid);
if host ~= muc_domain or not node then
module:log('debug', 'Not the same host');
return false;
end
local tenant, conference_name = node:match('^%[([^%]]+)%](.+)$');
if not (tenant and conference_name) then
module:log('debug', 'Not a vpaas room %s', room_jid);
return false;
end
local vpaas_prefix, _ = tenant:match('^(vpaas%-magic%-cookie%-)(.*)$')
if vpaas_prefix ~= 'vpaas-magic-cookie-' then
module:log('debug', 'Not a vpaas room %s', room_jid);
return false

if not starts_with(tenant, 'vpaas-magic-cookie-') then
return false;
end
return true

room.is_vpaas = true;
return true;
end

return {
Expand Down

0 comments on commit 5871e50

Please sign in to comment.