Software /
code /
prosody
Changeset
6633:832987170da8
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 26 Apr 2015 00:07:36 +0200 |
parents | 6626:071611bc4f1d (current diff) 6632:855085439f7f (diff) |
children | 6636:441f8cb0deec |
files | plugins/mod_s2s/mod_s2s.lua |
diffstat | 7 files changed, 27 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/core/usermanager.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/core/usermanager.lua Sun Apr 26 00:07:36 2015 +0200 @@ -50,7 +50,7 @@ host_session.users = setmetatable(provider, provider_mt); end if host_session.users ~= nil and host_session.users.name ~= nil then - log("debug", "host '%s' now set to use user provider '%s'", host, host_session.users.name); + log("debug", "Host '%s' now set to use user provider '%s'", host, host_session.users.name); end end); host_session.events.add_handler("item-removed/auth-provider", function (event)
--- a/net/dns.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/net/dns.lua Sun Apr 26 00:07:36 2015 +0200 @@ -701,15 +701,20 @@ end -function resolver:peek (qname, qtype, qclass) -- - - - - - - - - - - - peek +function resolver:peek (qname, qtype, qclass, n) -- - - - - - - - - - - - peek qname, qtype, qclass = standardize(qname, qtype, qclass); local rrs = get(self.cache, qclass, qtype, qname); - if not rrs then return nil; end + if not rrs then + if n then if n <= 0 then return end else n = 3 end + rrs = get(self.cache, qclass, "CNAME", qname); + if not (rrs and rrs[1]) then return end + return self:peek(rrs[1].cname, qtype, qclass, n - 1); + end if prune(rrs, socket.gettime()) and qtype == '*' or not next(rrs) then set(self.cache, qclass, qtype, qname, nil); return nil; end - if self.unsorted[rrs] then table.sort (rrs, comp_mx); end + if self.unsorted[rrs] then table.sort (rrs, comp_mx); self.unsorted[rrs] = nil; end return rrs; end
--- a/plugins/mod_admin_adhoc.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/plugins/mod_admin_adhoc.lua Sun Apr 26 00:07:36 2015 +0200 @@ -246,7 +246,7 @@ local query = st.stanza("query", { xmlns = "jabber:iq:roster" }); for jid in pairs(roster) do - if jid ~= "pending" and jid then + if jid then query:tag("item", { jid = jid, subscription = roster[jid].subscription, @@ -299,7 +299,7 @@ local IPs = ""; local resources = ""; for jid in pairs(roster) do - if jid ~= "pending" and jid then + if jid then rostersize = rostersize + 1; end end
--- a/plugins/mod_blocklist.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/plugins/mod_blocklist.lua Sun Apr 26 00:07:36 2015 +0200 @@ -13,11 +13,11 @@ local is_contact_subscribed = require"core.rostermanager".is_contact_subscribed; local st = require"util.stanza"; local st_error_reply = st.error_reply; -local jid_prep, jid_split = import("util.jid", "prep", "split"); +local jid_prep = require"util.jid".prep; +local jid_split = require"util.jid".split; -local host = module.host; local storage = module:open_store(); -local sessions = prosody.hosts[host].sessions; +local sessions = prosody.hosts[module.host].sessions; -- Cache of blocklists used since module was loaded local cache = {}; @@ -72,7 +72,7 @@ local function get_blocklist(username) local blocklist = cache[username]; if not blocklist then - if not user_exists(username, host) then + if not user_exists(username, module.host) then return null_blocklist; end blocklist = storage:get(username); @@ -106,14 +106,13 @@ local action = stanza.tags[1]; local new = {}; - local jid; for item in action:childtags("item") do - jid = jid_prep(item.attr.jid); + local jid = jid_prep(item.attr.jid); if not jid then return origin.send(st_error_reply(stanza, "modify", "jid-malformed")); end item.attr.jid = jid; -- echo back prepped - new[jid] = is_contact_subscribed(username, host, jid) or false; + new[jid] = is_contact_subscribed(username, module.host, jid) or false; end local mode = action.name == "block" or nil; @@ -176,14 +175,14 @@ -- Cache invalidation, solved! module:hook_global("user-deleted", function (event) - if event.host == host then + if event.host == module.host then cache[event.username] = nil; end end); -- Buggy clients module:hook("iq-error/self/blocklist-push", function (event) - local type, condition, text = event.stanza:get_error(); + local _, condition, text = event.stanza:get_error(); (event.origin.log or module._log)("warn", "Client returned an error in response to notification from mod_%s: %s%s%s", module.name, condition, text and ": " or "", text or ""); return true; end);
--- a/plugins/mod_c2s.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/plugins/mod_c2s.lua Sun Apr 26 00:07:36 2015 +0200 @@ -28,6 +28,8 @@ local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); local opt_keepalives = module:get_option_boolean("c2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); +local measure_connections = module:measure("connections", "counter"); + local sessions = module:shared("sessions"); local core_process_stanza = prosody.core_process_stanza; local hosts = prosody.hosts; @@ -198,6 +200,7 @@ --- Port listener function listener.onconnect(conn) + measure_connections(1); local session = sm_new_session(conn); sessions[conn] = session; @@ -270,6 +273,7 @@ end function listener.ondisconnect(conn, err) + measure_connections(-1); local session = sessions[conn]; if session then (session.log or log)("info", "Client disconnected: %s", err or "connection closed");
--- a/plugins/mod_s2s/mod_s2s.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/plugins/mod_s2s/mod_s2s.lua Sun Apr 26 00:07:36 2015 +0200 @@ -37,6 +37,8 @@ module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; local require_encryption = module:get_option_boolean("s2s_require_encryption", false); +local measure_connections = module:measure("connections", "counter"); + local sessions = module:shared("sessions"); local log = module._log; @@ -577,6 +579,7 @@ end function listener.onconnect(conn) + measure_connections(1); conn:setoption("keepalive", opt_keepalives); local session = sessions[conn]; if not session then -- New incoming connection @@ -608,6 +611,7 @@ end function listener.ondisconnect(conn, err) + measure_connections(-1); local session = sessions[conn]; if session then sessions[conn] = nil;
--- a/plugins/mod_s2s/s2sout.lib.lua Sun Apr 05 16:47:49 2015 +0200 +++ b/plugins/mod_s2s/s2sout.lib.lua Sun Apr 26 00:07:36 2015 +0200 @@ -169,18 +169,6 @@ handle4 = adns.lookup(function (reply, err) handle4 = nil; - -- COMPAT: This is a compromise for all you CNAME-(ab)users :) - if not (reply and reply[#reply] and reply[#reply].a) then - local count = max_dns_depth; - reply = dns.peek(connect_host, "CNAME", "IN"); - while count > 0 and reply and reply[#reply] and not reply[#reply].a and reply[#reply].cname do - log("debug", "Looking up %s (DNS depth is %d)", tostring(reply[#reply].cname), count); - reply = dns.peek(reply[#reply].cname, "A", "IN") or dns.peek(reply[#reply].cname, "CNAME", "IN"); - count = count - 1; - end - end - -- end of CNAME resolving - if reply and reply[#reply] and reply[#reply].a then for _, ip in ipairs(reply) do log("debug", "DNS reply for %s gives us %s", connect_host, ip.a);