Skip to content

Commit

Permalink
feat: Drops some debug prints. (jitsi#14311)
Browse files Browse the repository at this point in the history
* feat: Drops some debug prints.

* squash: Fix linter errors.
  • Loading branch information
damencho authored Feb 2, 2024
1 parent b106c20 commit b6b77f5
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion resources/prosody-plugins/mod_filter_iq_rayo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module:hook("pre-iq/full", function(event)
-- now lets check any limits if configured
if limit_outgoing_calls > 0 then
if not session.dial_out_throttle then
module:log("debug", "Enabling dial-out throttle session=%s.", session);
-- module:log("debug", "Enabling dial-out throttle session=%s.", session);
session.dial_out_throttle = new_throttle(limit_outgoing_calls, OUTGOING_CALLS_THROTTLE_INTERVAL);
end

Expand Down
7 changes: 5 additions & 2 deletions resources/prosody-plugins/mod_muc_auth_ban.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ end

local json = require "cjson.safe";
local http = require "net.http";
local inspect = require 'inspect';

local ban_check_count = module:measure("muc_auth_ban_check", "rate")
local ban_check_users_banned_count = module:measure("muc_auth_ban_users_banned", "rate")
Expand Down Expand Up @@ -38,7 +39,7 @@ local function shouldAllow(session)
local token = session.auth_token;

if token ~= nil then
module:log("debug", "Checking whether user should be banned ")
-- module:log("debug", "Checking whether user should be banned ")

-- cached tokens are banned
if cache:get(token) then
Expand All @@ -52,7 +53,9 @@ local function shouldAllow(session)

local r = json.decode(content)
if r['access'] ~= nil and r['access'] == false then
module:log("debug", "user is banned")
module:log("info", "User is banned room:%s tenant:%s user_id:%s group:%s",
session.jitsi_meet_room, session.jitsi_web_query_prefix,
inspect(session.jitsi_meet_context_user), session.jitsi_meet_context_group);

ban_check_users_banned_count();

Expand Down
10 changes: 5 additions & 5 deletions resources/prosody-plugins/mod_muc_flip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
local function remove_flip_tag(stanza)
stanza:maptags(function(tag)
if tag and tag.name == "flip_device" then
module:log("debug", "Removing %s tag from presence stanza!", tag.name);
-- module:log("debug", "Removing %s tag from presence stanza!", tag.name);
return nil;
else
return tag;
Expand Down Expand Up @@ -59,7 +59,7 @@ module:hook("muc-occupant-pre-join", function(event)
local occupant_jid = stanza.attr.from;
local affiliation = room:get_affiliation(occupant_jid);
if not affiliation or affiliation == 'none' or affiliation == 'member' then
module:log("debug", "Bypass lobby invitee %s", occupant_jid)
-- module:log("debug", "Bypass lobby invitee %s", occupant_jid)
occupant.role = "participant";
room:set_affiliation(true, jid_bare(occupant_jid), "member")
room:save_occupant(occupant);
Expand Down Expand Up @@ -95,7 +95,7 @@ module:hook("muc-occupant-pre-join", function(event)
-- update authenticated participant list
participants[id] = occupant.nick;
room._data.participants_details = participants
module:log("debug", "current details list %s", inspect(participants))
-- module:log("debug", "current details list %s", inspect(participants))
else
if flip_device_tag then
module:log("warn", "Flip device tag present for a guest user")
Expand Down Expand Up @@ -125,7 +125,7 @@ module:hook("muc-occupant-joined", function(event)
end

local initial_affiliation = room:get_affiliation(kicked_occupant.jid) or "member";
module:log("debug", "Transfer affiliation %s to occupant jid %s", initial_affiliation, occupant.jid)
-- module:log("debug", "Transfer affiliation %s to occupant jid %s", initial_affiliation, occupant.jid)
room:set_affiliation(true, occupant.bare_jid, initial_affiliation)
if initial_affiliation == "owner" then
event.occupant.role = "moderator";
Expand Down Expand Up @@ -177,7 +177,7 @@ module:hook('muc-broadcast-presence', function(event)
local kicked_participant_nick = event.room._data.kicked_participant_nick
local stanza = event.stanza;
if kicked_participant_nick and stanza.attr.from == kicked_participant_nick and stanza.attr.type == 'unavailable' then
module:log("debug", "Add flip_device tag for presence unavailable from occupant nick %s", kicked_participant_nick)
-- module:log("debug", "Add flip_device tag for presence unavailable from occupant nick %s", kicked_participant_nick)
stanza:tag("flip_device"):up();
end
end)
Expand Down
4 changes: 2 additions & 2 deletions resources/prosody-plugins/mod_muc_password_check.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function handle_validate_room_password (event)
body = json.encode({ valid = (room:get_password() == passcode) })
};

module:log("debug","Sending response for room password validate: %s", inspect(PUT_response));
-- module:log("debug","Sending response for room password validate: %s", inspect(PUT_response));

return PUT_response;
end
Expand All @@ -155,7 +155,7 @@ function handle_get_room_password (event)
};
body = json.encode(room_details);
};
module:log("debug","Sending response for room password: %s", inspect(GET_response));
-- module:log("debug","Sending response for room password: %s", inspect(GET_response));

return GET_response;
end
Expand Down
2 changes: 1 addition & 1 deletion resources/prosody-plugins/mod_muc_password_whitelist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module:hook("muc-occupant-pre-join", function (event)

join:tag("password", { xmlns = MUC_NS }):text(room:get_password());

module:log("debug", "Applied password access whitelist for %s in room %s", event.stanza.attr.from, room.jid);
-- module:log("debug", "Applied password access whitelist for %s in room %s", event.stanza.attr.from, room.jid);
end, -7); --- Run before the password check (priority -20), runs after lobby(priority -4) and members-only (priority -5).


Expand Down
6 changes: 3 additions & 3 deletions resources/prosody-plugins/mod_s2soutinjection.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function proxy_listener.onconnect(conn)
session.version = 1;

session.sends2s = function (t)
log("debug", "sending (s2s over proxy): %s", (t.top_tag and t:top_tag()) or t:match("^[^>]*>?"));
-- log("debug", "sending (s2s over proxy): %s", (t.top_tag and t:top_tag()) or t:match("^[^>]*>?"));
if t.name then
t = filter("stanzas/out", t);
end
Expand Down Expand Up @@ -73,13 +73,13 @@ module:hook("route/remote", function(event)
local from_host, to_host, stanza = event.from_host, event.to_host, event.stanza;
local inject = injected and injected[to_host];
if not inject then return end
module:log("debug", "opening a new outgoing connection for this stanza");
-- module:log("debug", "opening a new outgoing connection for this stanza");
local host_session = new_outgoing(from_host, to_host);

-- Store in buffer
host_session.bounce_sendq = bounce_sendq;
host_session.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} };
host_session.log("debug", "stanza [%s] queued until connection complete", tostring(stanza.name));
-- host_session.log("debug", "stanza [%s] queued until connection complete", tostring(stanza.name));

local host, port = inject[1] or inject, tonumber(inject[2]) or 5269;

Expand Down
6 changes: 3 additions & 3 deletions resources/prosody-plugins/mod_secure_interfaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module:hook("stream-features", function (event)
end
local localip = socket:getsockname();
if secure_interfaces:contains(localip) then
module:log("debug", "Marking session from %s to %s as secure", session.ip or "[?]", localip);
-- module:log("debug", "Marking session from %s to %s as secure", session.ip or "[?]", localip);
session.secure = true;
session.conn.starttls = false;
else
module:log("debug", "Not marking session from %s to %s as secure", session.ip or "[?]", localip);
-- else
-- module:log("debug", "Not marking session from %s to %s as secure", session.ip or "[?]", localip);
end
end, 2500);
22 changes: 11 additions & 11 deletions resources/prosody-plugins/mod_token_verification.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local um_is_admin = require "core.usermanager".is_admin;
local jid_split = require 'util.jid'.split;
local jid_bare = require 'util.jid'.bare;

local DEBUG = false;

local function is_admin(jid)
return um_is_admin(jid, host);
Expand Down Expand Up @@ -51,14 +52,15 @@ load_config();

-- verify user and whether he is allowed to join a room based on the token information
local function verify_user(session, stanza)
module:log("debug", "Session token: %s, session room: %s",
tostring(session.auth_token),
tostring(session.jitsi_meet_room));
if DEBUG then
module:log("debug", "Session token: %s, session room: %s",
tostring(session.auth_token), tostring(session.jitsi_meet_room));
end

-- token not required for admin users
local user_jid = stanza.attr.from;
if is_admin(user_jid) then
module:log("debug", "Token not required from admin user: %s", user_jid);
if DEBUG then module:log("debug", "Token not required from admin user: %s", user_jid); end
return true;
end

Expand All @@ -68,13 +70,11 @@ local function verify_user(session, stanza)

-- allowlist for participants
if allowlist:contains(user_domain) or allowlist:contains(user_bare_jid) then
module:log("debug", "Token not required from user in allow list: %s", user_jid);
if DEBUG then module:log("debug", "Token not required from user in allow list: %s", user_jid); end
return true;
end


module:log("debug",
"Will verify token for user: %s, room: %s ", user_jid, stanza.attr.to);
if DEBUG then module:log("debug", "Will verify token for user: %s, room: %s ", user_jid, stanza.attr.to); end
if not token_util:verify_room(session, stanza.attr.to) then
module:log("error", "Token %s not allowed to join: %s",
tostring(session.auth_token), tostring(stanza.attr.to));
Expand All @@ -83,21 +83,21 @@ local function verify_user(session, stanza)
stanza, "cancel", "not-allowed", "Room and token mismatched"));
return false; -- we need to just return non nil
end
module:log("debug", "allowed: %s to enter/create room: %s", user_jid, stanza.attr.to);
if DEBUG then module:log("debug", "allowed: %s to enter/create room: %s", user_jid, stanza.attr.to); end
return true;
end

module:hook("muc-room-pre-create", function(event)
local origin, stanza = event.origin, event.stanza;
module:log("debug", "pre create: %s %s", tostring(origin), tostring(stanza));
if DEBUG then module:log("debug", "pre create: %s %s", tostring(origin), tostring(stanza)); end
if not verify_user(origin, stanza) then
return true; -- Returning any value other than nil will halt processing of the event
end
end, 99);

module:hook("muc-occupant-pre-join", function(event)
local origin, room, stanza = event.origin, event.room, event.stanza;
module:log("debug", "pre join: %s %s", tostring(room), tostring(stanza));
if DEBUG then module:log("debug", "pre join: %s %s", tostring(room), tostring(stanza)); end
if not verify_user(origin, stanza) then
return true; -- Returning any value other than nil will halt processing of the event
end
Expand Down
4 changes: 2 additions & 2 deletions resources/prosody-plugins/token/util.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function Util:process_and_verify_token(session, acceptedIssuers)
local key;
if session.public_key then
-- We're using an public key stored in the session
module:log("debug","Public key was found on the session");
-- module:log("debug","Public key was found on the session");
key = session.public_key;
elseif self.asapKeyServer and session.auth_token ~= nil then
-- We're fetching an public key from an ASAP server
Expand Down Expand Up @@ -398,7 +398,7 @@ function Util:verify_room(session, room_address)
-- not a regex
room_to_check = auth_room;
end
module:log("debug", "room to check: %s", room_to_check)
-- module:log("debug", "room to check: %s", room_to_check)
if not room_to_check then
if not self.requireRoomClaim then
-- if we do not require to have the room claim, and it is missing
Expand Down
2 changes: 1 addition & 1 deletion resources/prosody-plugins/util.lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function http_get_with_retry(url, retry, auth_token)
if timeout_occurred == nil then
code = code_;
if code == 200 or code == 204 then
module:log("debug", "External call was successful, content %s", content_);
-- module:log("debug", "External call was successful, content %s", content_);
content = content_;

-- if there is cache-control header, let's return the max-age value
Expand Down

0 comments on commit b6b77f5

Please sign in to comment.