aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-04-26 00:07:36 +0200
committerKim Alvefur <zash@zash.se>2015-04-26 00:07:36 +0200
commit43702241ec9a8bf74a23c63b5ee2fd6edd49cbe3 (patch)
treeb003c23950a3bb53f56cc0eedaca77b2aaf4bbe0
parent1be7952fe226feefa784e1975d23e950323877e3 (diff)
parent3e6b35b5d49b5f6ec06cb301ba7b4cbce0a75000 (diff)
downloadprosody-43702241ec9a8bf74a23c63b5ee2fd6edd49cbe3.tar.gz
prosody-43702241ec9a8bf74a23c63b5ee2fd6edd49cbe3.zip
Merge 0.10->trunk
-rw-r--r--core/usermanager.lua2
-rw-r--r--net/dns.lua11
-rw-r--r--plugins/mod_admin_adhoc.lua4
-rw-r--r--plugins/mod_blocklist.lua17
-rw-r--r--plugins/mod_c2s.lua4
-rw-r--r--plugins/mod_s2s/mod_s2s.lua4
-rw-r--r--plugins/mod_s2s/s2sout.lib.lua12
7 files changed, 27 insertions, 27 deletions
diff --git a/core/usermanager.lua b/core/usermanager.lua
index 4ac288a4..900531ca 100644
--- a/core/usermanager.lua
+++ b/core/usermanager.lua
@@ -50,7 +50,7 @@ function initialize_host(host)
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)
diff --git a/net/dns.lua b/net/dns.lua
index 2cb677f6..2128fb1a 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -701,15 +701,20 @@ local function comp_mx(a, b) -- - - - - - - - - - - - - - - - - - - comp_mx
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
diff --git a/plugins/mod_admin_adhoc.lua b/plugins/mod_admin_adhoc.lua
index 405980c2..4fab84bc 100644
--- a/plugins/mod_admin_adhoc.lua
+++ b/plugins/mod_admin_adhoc.lua
@@ -246,7 +246,7 @@ local get_user_roster_handler = adhoc_simple(get_user_roster_layout, function(fi
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 get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fiel
local IPs = "";
local resources = "";
for jid in pairs(roster) do
- if jid ~= "pending" and jid then
+ if jid then
rostersize = rostersize + 1;
end
end
diff --git a/plugins/mod_blocklist.lua b/plugins/mod_blocklist.lua
index 81bdd2c6..baed6709 100644
--- a/plugins/mod_blocklist.lua
+++ b/plugins/mod_blocklist.lua
@@ -13,11 +13,11 @@ local user_exists = require"core.usermanager".user_exists;
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 @@ end
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 function edit_blocklist(event)
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 @@ module:hook("iq-set/self/urn:xmpp:blocking:unblock", edit_blocklist);
-- 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);
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua
index 4238b2e7..1423eaa3 100644
--- a/plugins/mod_c2s.lua
+++ b/plugins/mod_c2s.lua
@@ -28,6 +28,8 @@ local c2s_timeout = module:get_option_number("c2s_timeout");
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 @@ end
--- Port listener
function listener.onconnect(conn)
+ measure_connections(1);
local session = sm_new_session(conn);
sessions[conn] = session;
@@ -270,6 +273,7 @@ function listener.onincoming(conn, data)
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");
diff --git a/plugins/mod_s2s/mod_s2s.lua b/plugins/mod_s2s/mod_s2s.lua
index e7c10e7e..5a47559e 100644
--- a/plugins/mod_s2s/mod_s2s.lua
+++ b/plugins/mod_s2s/mod_s2s.lua
@@ -37,6 +37,8 @@ local secure_domains, insecure_domains =
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 @@ local function initialize_session(session)
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 @@ function listener.onstatus(conn, status)
end
function listener.ondisconnect(conn, err)
+ measure_connections(-1);
local session = sessions[conn];
if session then
sessions[conn] = nil;
diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua
index 942a618d..5214f4cf 100644
--- a/plugins/mod_s2s/s2sout.lib.lua
+++ b/plugins/mod_s2s/s2sout.lib.lua
@@ -169,18 +169,6 @@ function s2sout.try_connect(host_session, connect_host, connect_port, err)
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);