Software /
code /
prosody
Changeset
6913:c7a0d5299933
mod_component: Add config option for deciding what happens if a component connects while already connected (fixes #525)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 21 Oct 2015 01:56:07 +0200 (2015-10-20) |
parents | 6912:cb5b14c95b7b |
children | 6914:5df76208e050 |
files | plugins/mod_component.lua |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_component.lua Sun Oct 18 21:54:17 2015 +0100 +++ b/plugins/mod_component.lua Wed Oct 21 01:56:07 2015 +0200 @@ -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);