diff options
author | Kim Alvefur <zash@zash.se> | 2015-10-21 01:56:07 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2015-10-21 01:56:07 +0200 |
commit | a05e313bb259ace44bd79bfce243741b1ae2f772 (patch) | |
tree | dd2c794ec9fa8ecd5b1f90b3223a5080dba05718 /plugins/mod_component.lua | |
parent | ec598648859d8b66213772ebe1d04c70794aa7cd (diff) | |
download | prosody-a05e313bb259ace44bd79bfce243741b1ae2f772.tar.gz prosody-a05e313bb259ace44bd79bfce243741b1ae2f772.zip |
mod_component: Add config option for deciding what happens if a component connects while already connected (fixes #525)
Diffstat (limited to 'plugins/mod_component.lua')
-rw-r--r-- | plugins/mod_component.lua | 14 |
1 files 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); |