aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
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 /plugins
parent1be7952fe226feefa784e1975d23e950323877e3 (diff)
parent3e6b35b5d49b5f6ec06cb301ba7b4cbce0a75000 (diff)
downloadprosody-43702241ec9a8bf74a23c63b5ee2fd6edd49cbe3.tar.gz
prosody-43702241ec9a8bf74a23c63b5ee2fd6edd49cbe3.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins')
-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
5 files changed, 18 insertions, 23 deletions
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);