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(-) (limited to 'plugins') 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 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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(-) (limited to 'plugins') 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