From 0b394fbeb9d90e72637a085e5bf02ecfa68f44e3 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 18 Oct 2015 21:35:21 +0100 Subject: statsmanager: Add get() method --- core/statsmanager.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/statsmanager.lua b/core/statsmanager.lua index d6cbd2bc..7771a2b3 100644 --- a/core/statsmanager.lua +++ b/core/statsmanager.lua @@ -66,4 +66,7 @@ return { get_stats = function () return latest_stats, changed_stats, stats_extra; end; + get = function (name) + return latest_stats[name], stats_extra[name]; + end; }; -- cgit v1.2.3 From cd8af079c3b729283f8dba28a17320c58fd15110 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 18 Oct 2015 21:42:33 +0100 Subject: util.queue: Add :items() iterator --- util/queue.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util/queue.lua b/util/queue.lua index 203da0e3..ac782e84 100644 --- a/util/queue.lua +++ b/util/queue.lua @@ -18,6 +18,7 @@ local function new(size, allow_wrapping) local t = have_utable and utable.create(size, 0) or {}; -- Table to hold items return { + _items = t; size = size; count = function (self) return items; end; push = function (self, item) @@ -50,6 +51,18 @@ local function new(size, allow_wrapping) end return t[tail]; end; + items = function (self) + return function (t, pos) + if pos >= t:count() then + return nil; + end + local read_pos = tail + pos; + if read_pos > t.size then + read_pos = (read_pos%size); + end + return pos+1, t._items[read_pos]; + end, self, 0; + end; }; end -- cgit v1.2.3 From 7592b57bc634f514570cb70e0b38347c13085ffe Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sun, 18 Oct 2015 21:54:17 +0100 Subject: util.queue: Add luacheck annotations --- util/queue.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/queue.lua b/util/queue.lua index ac782e84..728e905f 100644 --- a/util/queue.lua +++ b/util/queue.lua @@ -16,7 +16,7 @@ local function new(size, allow_wrapping) local head, tail = 1, 1; local items = 0; -- Number of stored items local t = have_utable and utable.create(size, 0) or {}; -- Table to hold items - + --luacheck: ignore 212/self return { _items = t; size = size; @@ -52,6 +52,7 @@ local function new(size, allow_wrapping) return t[tail]; end; items = function (self) + --luacheck: ignore 431/t return function (t, pos) if pos >= t:count() then return nil; -- cgit v1.2.3 From b7e3bf93eae9c6ae373d2f555b9d1fb0bbc2056d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 21 Oct 2015 01:56:07 +0200 Subject: mod_component: Add config option for deciding what happens if a component connects while already connected (fixes #525) --- plugins/mod_component.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/mod_component.lua b/plugins/mod_component.lua index f29245b2..a5136f6c 100644 --- a/plugins/mod_component.lua +++ b/plugins/mod_component.lua @@ -36,11 +36,13 @@ function module.add_host(module) local env = module.environment; env.connected = false; + env.session = false; local send; local function on_destroy(session, err) env.connected = false; + env.session = false; send = nil; session.on_destroy = nil; end @@ -73,12 +75,18 @@ function module.add_host(module) end if env.connected then - module:log("error", "Second component attempted to connect, denying connection"); - session:close{ condition = "conflict", text = "Component already connected" }; - return true; + local policy = module:get_option_string("component_conflict_resolve", "kick_new"); + if policy == "kick_old" then + env.session:close{ condition = "conflict", text = "Replaced by a new connection" }; + else -- kick_new + module:log("error", "Second component attempted to connect, denying connection"); + session:close{ condition = "conflict", text = "Component already connected" }; + return true; + end end env.connected = true; + env.session = session; send = session.send; session.on_destroy = on_destroy; session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); -- cgit v1.2.3 From 1a728fad755b3ba2b5383ac0ee6273d19e498e0f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 21 Oct 2015 13:37:26 +0200 Subject: prosodyctl: check: Don't complain about c2s_ssl or s2s_ssl being in VirtualHost sections, that's supported --- prosodyctl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prosodyctl b/prosodyctl index e4e22322..76c05fa6 100755 --- a/prosodyctl +++ b/prosodyctl @@ -890,7 +890,7 @@ function commands.check(arg) for name in pairs(options) do if name:match("^interfaces?") or name:match("_ports?$") or name:match("_interfaces?$") - or name:match("_ssl$") then + or (name:match("_ssl$") and not name:match("^[cs]2s_ssl$")) then misplaced_options:add(name); end end -- cgit v1.2.3 From 6c28def6cca6c511701c180976eb3c2d81610e64 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 4 Nov 2015 12:21:46 +0100 Subject: sessionmanager: Clarify log message when failing to write data to connection --- core/sessionmanager.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index bc4d7cef..f168c8e9 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -39,10 +39,9 @@ local function new_session(conn) if t then local ret, err = w(conn, t); if not ret then - session.log("error", "Write-error: %s", tostring(err)); - return false; + session.log("error", "Error writing to connection: %s", tostring(err)); + return false, err; end - return true; end end return true; -- cgit v1.2.3 From 146627211bb25845b41adef6ddc0534520873736 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 5 Nov 2015 13:35:16 +0100 Subject: sessionmanager: Demote write error to debug message --- core/sessionmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index f168c8e9..6aa0a4f0 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -39,7 +39,7 @@ local function new_session(conn) if t then local ret, err = w(conn, t); if not ret then - session.log("error", "Error writing to connection: %s", tostring(err)); + session.log("debug", "Error writing to connection: %s", tostring(err)); return false, err; end end -- cgit v1.2.3 From 3b6f62670dd866efb708c886feb7b6a974081596 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 5 Nov 2015 13:54:35 +0100 Subject: mod_s2s/s2sout: Keep SRV lookup response around even if it's empty --- plugins/mod_s2s/s2sout.lib.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/mod_s2s/s2sout.lib.lua b/plugins/mod_s2s/s2sout.lib.lua index 7c6033a3..395406cd 100644 --- a/plugins/mod_s2s/s2sout.lib.lua +++ b/plugins/mod_s2s/s2sout.lib.lua @@ -103,11 +103,12 @@ function s2sout.attempt_connection(host_session, err) local handle; handle = adns.lookup(function (answer) handle = nil; + local srv_hosts = { answer = answer }; + host_session.srv_hosts = srv_hosts; + host_session.srv_choice = 0; host_session.connecting = nil; if answer and #answer > 0 then log("debug", "%s has SRV records, handling...", to_host); - local srv_hosts = { answer = answer }; - host_session.srv_hosts = srv_hosts; for _, record in ipairs(answer) do t_insert(srv_hosts, record.srv); end -- cgit v1.2.3 From edc807903201f089ef85b107b4900375a82a26f1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 9 Nov 2015 13:39:23 +0100 Subject: mod_tls: Remove unused reference to global ssl config option (certmanager adds that to the context) --- plugins/mod_tls.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 39c4649e..365be69e 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -40,7 +40,6 @@ do local modhost = module.host; local parent = modhost:match("%.(.*)$"); - local global_ssl = rawgetopt("*", "ssl") or NULL; local parent_ssl = rawgetopt(parent, "ssl") or NULL; local host_ssl = rawgetopt(modhost, "ssl") or parent_ssl; -- cgit v1.2.3 From 57fe905a8c3eeffb507a0967512a4caccb0e882b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 9 Nov 2015 13:40:06 +0100 Subject: mod_tls: Fix ssl option fallback to a "parent" host if current host does not have ssl options set (thanks 70b1) --- plugins/mod_tls.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 365be69e..69aafe82 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -45,11 +45,11 @@ do local global_c2s = rawgetopt("*", "c2s_ssl") or NULL; local parent_c2s = rawgetopt(parent, "c2s_ssl") or NULL; - local host_c2s = rawgetopt(modhost, "c2s_ssl") or parent_ssl; + local host_c2s = rawgetopt(modhost, "c2s_ssl") or parent_c2s; local global_s2s = rawgetopt("*", "s2s_ssl") or NULL; local parent_s2s = rawgetopt(parent, "s2s_ssl") or NULL; - local host_s2s = rawgetopt(modhost, "s2s_ssl") or parent_ssl; + local host_s2s = rawgetopt(modhost, "s2s_ssl") or parent_s2s; ssl_ctx_c2s, err, ssl_cfg_c2s = create_context(host.host, "server", host_c2s, host_ssl, global_c2s); -- for incoming client connections if not ssl_ctx_c2s then module:log("error", "Error creating context for c2s: %s", err); end -- cgit v1.2.3