# HG changeset patch # User Kim Alvefur # Date 1447106192 -3600 # Node ID 7596c37e0a63c0387b6bedb46a92b922d7782179 # Parent 494938dec5d803c22d286db3ed84b7ef9e05a341# Parent ab6c57633ce520907fe1dfb40cc02cf43b99cac8 Merge 0.10->trunk diff -r 494938dec5d8 -r 7596c37e0a63 core/sessionmanager.lua --- a/core/sessionmanager.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/core/sessionmanager.lua Mon Nov 09 22:56:32 2015 +0100 @@ -39,10 +39,9 @@ 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("debug", "Error writing to connection: %s", tostring(err)); + return false, err; end - return true; end end return true; diff -r 494938dec5d8 -r 7596c37e0a63 core/statsmanager.lua --- a/core/statsmanager.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/core/statsmanager.lua Mon Nov 09 22:56:32 2015 +0100 @@ -66,4 +66,7 @@ get_stats = function () return latest_stats, changed_stats, stats_extra; end; + get = function (name) + return latest_stats[name], stats_extra[name]; + end; }; diff -r 494938dec5d8 -r 7596c37e0a63 plugins/mod_component.lua --- a/plugins/mod_component.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/plugins/mod_component.lua Mon Nov 09 22:56:32 2015 +0100 @@ -36,11 +36,13 @@ 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 @@ 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); diff -r 494938dec5d8 -r 7596c37e0a63 plugins/mod_s2s/s2sout.lib.lua --- a/plugins/mod_s2s/s2sout.lib.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/plugins/mod_s2s/s2sout.lib.lua Mon Nov 09 22:56:32 2015 +0100 @@ -103,11 +103,12 @@ 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 diff -r 494938dec5d8 -r 7596c37e0a63 plugins/mod_tls.lua --- a/plugins/mod_tls.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/plugins/mod_tls.lua Mon Nov 09 22:56:32 2015 +0100 @@ -40,17 +40,16 @@ 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; 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 diff -r 494938dec5d8 -r 7596c37e0a63 prosodyctl --- a/prosodyctl Sun Oct 18 14:00:15 2015 +0200 +++ b/prosodyctl Mon Nov 09 22:56:32 2015 +0100 @@ -890,7 +890,7 @@ 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 diff -r 494938dec5d8 -r 7596c37e0a63 util/queue.lua --- a/util/queue.lua Sun Oct 18 14:00:15 2015 +0200 +++ b/util/queue.lua Mon Nov 09 22:56:32 2015 +0100 @@ -16,8 +16,9 @@ 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; count = function (self) return items; end; push = function (self, item) @@ -50,6 +51,19 @@ end return t[tail]; end; + items = function (self) + --luacheck: ignore 431/t + 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