Comparison

plugins/mod_privacy.lua @ 2524:b427f5401ce7

mod_privacy: A handful of logging fixes
author Matthew Wild <mwild1@gmail.com>
date Fri, 29 Jan 2010 13:02:06 +0000
parent 2523:0c816b271208
child 2579:4e0caff152d6
comparison
equal deleted inserted replaced
2523:0c816b271208 2524:b427f5401ce7
84 sendNeededUnavailablePersences(origin, item); 84 sendNeededUnavailablePersences(origin, item);
85 end 85 end
86 end 86 end
87 end 87 end
88 elseif type(listnameOrItem) == "table" then 88 elseif type(listnameOrItem) == "table" then
89 module:log("debug", "got an item, check wether to send unavailable presence stanza or not"); 89 module:log("debug", "got an item, check whether to send unavailable presence stanza or not");
90 local item = listnameOrItem; 90 local item = listnameOrItem;
91 91
92 if item["presence-out"] == true then 92 if item["presence-out"] == true then
93 if item.type == "jid" then 93 if item.type == "jid" then
94 sendUnavailable(origin, item.value, origin.full_jid); 94 sendUnavailable(origin, item.value, origin.full_jid);
389 (privacy_lists.default == nil or privacy_lists.default == "") 389 (privacy_lists.default == nil or privacy_lists.default == "")
390 then 390 then
391 return; -- Nothing to block, default is Allow all 391 return; -- Nothing to block, default is Allow all
392 end 392 end
393 if from_user and to_user then 393 if from_user and to_user then
394 module:log("debug", "Never block communications from one of a user's resources to another."); 394 module:log("debug", "Not blocking communications between user's resources");
395 return; -- from one of a user's resource to another => HANDS OFF! 395 return; -- from one of a user's resource to another => HANDS OFF!
396 end 396 end
397 397
398 local idx; 398 local idx;
399 local list; 399 local list;
402 if listname == nil or listname == "" then 402 if listname == nil or listname == "" then
403 listname = privacy_lists.default; -- no active list selected, use default list 403 listname = privacy_lists.default; -- no active list selected, use default list
404 end 404 end
405 idx = findNamedList(privacy_lists, listname); 405 idx = findNamedList(privacy_lists, listname);
406 if idx == nil then 406 if idx == nil then
407 module:log("error", "given privacy listname not found. name: %s", listname); 407 module:log("debug", "given privacy listname not found. name: %s", listname);
408 return; 408 return;
409 end 409 end
410 list = privacy_lists.lists[idx]; 410 list = privacy_lists.lists[idx];
411 if list == nil then 411 if list == nil then
412 module:log("info", "privacy list index wrong. index: %d", idx); 412 module:log("debug", "privacy list index wrong. index: %d", idx);
413 return; 413 return;
414 end 414 end
415 for _,item in ipairs(list.items) do 415 for _,item in ipairs(list.items) do
416 local apply = false; 416 local apply = false;
417 local block = false; 417 local block = false;
462 block = (item.action == "deny"); 462 block = (item.action == "deny");
463 end 463 end
464 end 464 end
465 if apply then 465 if apply then
466 if block then 466 if block then
467 module:log("info", "stanza blocked: %s, to: %s, from: %s", tostring(stanza.name), tostring(to), tostring(from)); 467 module:log("debug", "stanza blocked: %s, to: %s, from: %s", tostring(stanza.name), tostring(to), tostring(from));
468 if stanza.name == "message" then 468 if stanza.name == "message" then
469 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 469 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
470 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then 470 elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then
471 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); 471 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
472 end 472 end
473 return true; -- stanza blocked ! 473 return true; -- stanza blocked !
474 else 474 else
475 module:log("info", "stanza explicit allowed!") 475 module:log("debug", "stanza explicitly allowed!")
476 return; 476 return;
477 end 477 end
478 end 478 end
479 end 479 end
480 end 480 end