# HG changeset patch # User Kim Alvefur # Date 1439234011 -7200 # Node ID c353acd1d366b67f036390965cb42ab1bf350f96 # Parent fb2b9a2e2316e59d844507f3c7e8230382ff9fd7# Parent e7b5ab44339c8d6fa58373b5d9eb65f5006841ae Merge with Goffi diff -r e7b5ab44339c -r c353acd1d366 mod_adhoc_blacklist/mod_adhoc_blacklist.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_adhoc_blacklist/mod_adhoc_blacklist.lua Mon Aug 10 21:13:31 2015 +0200 @@ -0,0 +1,90 @@ +-- mod_adhoc_blacklist +-- +-- http://xmpp.org/extensions/xep-0133.html#edit-blacklist +-- +-- Copyright (C) 2015 Kim Alvefur +-- +-- This file is MIT/X11 licensed. +-- + +module:depends("adhoc"); +local adhoc = module:require "adhoc"; +local st = require"util.stanza"; +local set = require"util.set"; +local dataform = require"util.dataforms"; +local adhoc_inital_data = require "util.adhoc".new_initial_data_form; + +local blocklist_form = dataform.new { + title = "Editing the Blacklist"; + instructions = "Fill out this form to edit the list of entities with whom communications are disallowed."; + { + type = "hidden"; + name = "FORM_TYPE"; + value = "http://jabber.org/protocol/admin"; + }; + { + type = "jid-multi"; + name = "blacklistjids"; + label = "The blacklist"; + }; +} + +local blocklists = module:open_store("blocklist"); + +local blocklist_handler = adhoc_inital_data(blocklist_form, function () + local blacklistjids = {}; + local blacklist = blocklists:get(); + if blacklist then + for jid in pairs(blacklist) do + table.insert(blacklistjids, jid); + end + end + return { blacklistjids = blacklistjids }; +end, function(fields, form_err) + if form_err then + return { status = "completed", error = { message = "Problem in submitted form" } }; + end + local blacklistjids = set.new(fields.blacklistjids); + local ok, err = blocklists:set(nil, blacklistjids._items); + if ok then + return { status = "completed", info = "Blacklist updated" }; + else + return { status = "completed", error = { message = "Error saving blacklist: "..err } }; + end +end); + +module:add_item("adhoc", adhoc.new("Edit Blacklist", "http://jabber.org/protocol/admin#edit-blacklist", blocklist_handler, "admin")); + +local function is_blocked(host) + local blacklistjids = blocklists:get(); + return blacklistjids and blacklistjids[host]; +end + +module:hook("route/remote", function (event) + local origin, stanza = event.origin, event.stanza; + if is_blocked(event.to_host) then + if origin and stanza then + origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Communication with this domain is not allowed")); + return true; + end + return false; + end +end, 1000); + + +module:hook("s2s-stream-features", function (event) + local session = event.origin; + if is_blocked(session.from_host) then + session:close("policy-violation"); + return false; + end +end, 1000); + +module:hook("stanza/http://etherx.jabber.org/streams:features", function (event) + local session = event.origin; + if is_blocked(session.to_host) then + session:close("policy-violation"); + return true; + end +end, 1000); + diff -r e7b5ab44339c -r c353acd1d366 mod_admin_blocklist/mod_admin_blocklist.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_admin_blocklist/mod_admin_blocklist.lua Mon Aug 10 21:13:31 2015 +0200 @@ -0,0 +1,59 @@ +-- mod_admin_blocklist +-- +-- If a local admin has blocked a domain, don't allow s2s to that domain +-- +-- Copyright (C) 2015 Kim Alvefur +-- +-- This file is MIT/X11 licensed. +-- + +module:depends("blocklist"); + +local st = require"util.stanza"; +local jid_split = require"util.jid".split; + +local admins = module:get_option_inherited_set("admins", {}) / + function (admin) -- Filter out non-local admins + local user, host = jid_split(admin); + if host == module.host then return user; end + end + +local blocklists = module:open_store("blocklist"); + +local function is_blocked(host) + for admin in admins do + local blocklist = blocklists:get(admin); + if blocklist and blocklist[host] then + return true; + end + end +end + +module:hook("route/remote", function (event) + local origin, stanza = event.origin, event.stanza; + if is_blocked(event.to_host) then + if origin and stanza then + origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Communication with this domain is not allowed")); + return true; + end + return false; + end +end, 1000); + + +module:hook("s2s-stream-features", function (event) + local session = event.origin; + if is_blocked(session.from_host) then + session:close("policy-violation"); + return false; + end +end, 1000); + +module:hook("stanza/http://etherx.jabber.org/streams:features", function (event) + local session = event.origin; + if is_blocked(session.to_host) then + session:close("policy-violation"); + return true; + end +end, 1000); + diff -r e7b5ab44339c -r c353acd1d366 mod_auth_http_async/mod_auth_http_async.lua --- a/mod_auth_http_async/mod_auth_http_async.lua Fri Jul 31 18:46:27 2015 +0200 +++ b/mod_auth_http_async/mod_auth_http_async.lua Mon Aug 10 21:13:31 2015 +0200 @@ -7,7 +7,6 @@ -- COPYING file in the source package for more information. -- -local usermanager = require "core.usermanager"; local new_sasl = require "util.sasl".new; local base64 = require "util.encodings".base64.encode; local waiter =require "util.async".waiter; @@ -66,7 +65,7 @@ function provider.get_sasl_handler() return new_sasl(host, { plain_test = function(sasl, username, password, realm) - return usermanager.test_password(username, realm, password), true; + return provider.test_password(username, realm, password), true; end }); end diff -r e7b5ab44339c -r c353acd1d366 mod_benchmark_storage/mod_benchmark_storage.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_benchmark_storage/mod_benchmark_storage.lua Mon Aug 10 21:13:31 2015 +0200 @@ -0,0 +1,119 @@ +-- mod_benchmark_storage +-- Copyright (C) 2015 Kim Alvefur +-- +-- Prime numbers are pretty cool + +local gettime = require"socket".gettime; + +local sm = require"core.storagemanager"; +local um = require"core.usermanager"; +local mm = require"core.modulemanager"; + +local test_data, test_users; + +function module.command(arg) + local test_driver = arg[1]; + if not test_driver then + return print("Usage: prosodyctl mod_"..module.name.." "); + end + + sm.initialize_host("localhost"); + um.initialize_host("localhost"); + + local start_time = gettime(); + local storage = assert(sm.load_driver("localhost", test_driver)); + storage = assert(storage:open("benchmark")); + -- for i = 1, 23 do + -- storage:set(test_users[i], test_data); + -- end + local floor, sin, random, pi = math.floor, math.sin, math.random, math.pi; + for i = 1, 10079 do + if i % 11 == 1 then + storage:set(test_users[i%23+1], test_data[3-floor(sin(random()*pi)*3)]); + else + storage:get(test_users[i%23+1]); + end + if i % 151 == 0 then + -- Give indication of progress + io.write("*"); + io.flush(); + end + end + -- Cleanup + for i = 1, 23 do + storage:set(test_users[i], nil); + end + mm.unload("localhost", "storage_"..test_driver); + local time_taken = gettime() - start_time; + io.write("\27[0G\27[K"); -- Clear current line + io.flush(); + print(("Took %fs with mod_storage_%s"):format(time_taken, test_driver)); +end + +-- 23 usernames +test_users = { + "tritonymph"; "ankylotomy"; "tron"; "barbaric"; "twiddler"; + "spiritful"; "unmollifiably"; "suggestion"; "presubsistence"; + "unneeded"; "taxemic"; "teloteropathic"; "nonbending"; "mev"; + "septifragally"; "clame"; "obsolescent"; "unconceivable"; + "foolishly"; "conjunctur"; "precirculation"; "bethump"; "vermivorous"; +}; + +test_data = { + { some_data = "tiny data" }; + -- + { [false] = { version = 1; pending = {}; }; -- Medium data + ["user@example.com"] = { subscription = "both"; groups = {}; + name = "My Best Friend"; }; }; + -- + { attr = { xmlns = "vcard-temp"; }; name = "vCard"; -- The largest data + { attr = { xmlns = "vcard-temp"; }; name = "NICKNAME"; "Buster"; }; + { attr = { xmlns = "vcard-temp"; }; name = "PHOTO"; + { attr = { xmlns = "vcard-temp"; }; name = "TYPE"; "image/jpeg"; }; + { attr = { xmlns = "vcard-temp"; }; name = "BINVAL"; [[ + /9j/4AAQSkZJRgABAgAAZABkAAD/2wBDAAgFBQUGBQgGBggLBwYHCw0JCAgJDQ8MDA0MDA8RDAwM + DAwMEQ4RERIREQ4XFxgYFxcgICAgICQkJCQkJCQkJCT/2wBDAQgICA8ODxwTExwfGRQZHyQkJCQk + JCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCT/wAARCAA8ADwDAREA + AhEBAxEB/8QAGwAAAgMBAQEAAAAAAAAAAAAABgcDBAUCCAH/xAA9EAACAQIEAgcECAMJAAAAAAAB + AgMEEQAFEhMGIQcUFSIxQWEWQlFSIyQyM2JxgZElcqEXJjSCksHR8PH/xAAbAQACAwEBAQAAAAAA + AAAAAAAEBQECAwYAB//EADcRAAEDAwIDBAcGBwAAAAAAAAEAAgMEESESMQUTQSJRYYEUIzJCcaGx + BhUWkdHhQ1JyguLw8f/aAAwDAQACEQMRAD8ASI+7+N8WVuiNuiPgaHinPXkr115TloWWpjv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069txpbkLchywXC + Xg4shJtJGboPXMUrqzQokmpaaJ2LSNbmsZRZG8Od8MaKHt3KAqpbtsLrKy/UpdlJ740HSbGwZSPH + 8QGGDWAtv3lBA2KKOq5R7H9V00/a3aHZe7Ybu1q67v6v5vor/LimnOi3vfJX1Y1eF1qcTcMVWdTu + Mqp5KqS4cGEalWS3NWfkouPXGr5GgZKzDCThQ5J0KcYVFZEayNKLLzpMs+oO4QgkiKLlqceHPlgR + 9cGG7QSUTHSFxuSAEzJOG5svyJMiyWjqI48vjaahqHkR92WRvpon1FbO9tXwGFj5ZnG56ppHHC0W + wh7hzgfj6nk6zWwxrK8gLJJUoymJjeUMoDd/4G/jiksOqw2XoZw0G+Vu1XAtZNUsyU1DHSSRhZIp + JJJZNY99e6EA/DjI0thg5WjasXyMIO4n6MeJp2bs9KRouYKrJtWJFvAp/vguik5TruyhascwdnGU + LwcB8Y5ejCoyiWUchqj0TAWcNrXaZz5fDDZtVGWAXF/1S407wdlW9m8+7T6x1Gv1bm7t9Xkte9/l + +OCdcHN16wsOXLy9NvBOCo9tesL2L1Ps+30PVvufDuatvnb+mF8mr3UXHy/e+eyYUduqQ733mga/ + 5rDVb9cCZstha+FC+1c2v62xGFJXA2vO/pbFQpXMmzbz8fPwxBspCoVWzq5f0xkVqFnyaNR29Wr8 + FsQtGrr65p97R/X/ANxCn6r/2Q==]]; }; }; }; +}; diff -r e7b5ab44339c -r c353acd1d366 mod_compact_resource/mod_compact_resource.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_compact_resource/mod_compact_resource.lua Mon Aug 10 21:13:31 2015 +0200 @@ -0,0 +1,12 @@ + +local base64_encode = require"util.encodings".base64.encode; +local random_bytes = require"util.random".bytes; + +local b64url = { ["+"] = "-", ["/"] = "_", ["="] = "" }; +local function random_resource() + return base64_encode(random_bytes(8)):gsub("[+/=]", b64url); +end + +module:hook("pre-resource-bind", function (event) + event.resource = random_resource(); +end); diff -r e7b5ab44339c -r c353acd1d366 mod_filter_chatstates/mod_filter_chatstates.lua --- a/mod_filter_chatstates/mod_filter_chatstates.lua Fri Jul 31 18:46:27 2015 +0200 +++ b/mod_filter_chatstates/mod_filter_chatstates.lua Mon Aug 10 21:13:31 2015 +0200 @@ -1,9 +1,6 @@ local filters = require "util.filters"; local st = require "util.stanza"; -local dummy_stanza_mt = setmetatable({ __tostring = function () return ""; end }, { __index = st.stanza_mt }); -local dummy_stanza = setmetatable(st.stanza(), dummy_stanza_mt); - module:depends("csi"); local function filter_chatstates(stanza) @@ -11,11 +8,11 @@ stanza = st.clone(stanza); stanza:maptags(function (tag) if tag.attr.xmlns ~= "http://jabber.org/protocol/chatstates" then - return tag; + return tag end end); if #stanza.tags == 0 then - return dummy_stanza; + return nil; end end return stanza; diff -r e7b5ab44339c -r c353acd1d366 mod_http_muc_log/http_muc_log.html --- a/mod_http_muc_log/http_muc_log.html Fri Jul 31 18:46:27 2015 +0200 +++ b/mod_http_muc_log/http_muc_log.html Mon Aug 10 21:13:31 2015 +0200 @@ -44,7 +44,7 @@

{title}


@@ -52,33 +52,33 @@
    {lines# -
  1. - -{nick} -{verb?} -{body?} +
  2. + +{item.nick} +{item.verb?} +{item.body?}
  3. }