aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_component.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-11-09 22:56:32 +0100
committerKim Alvefur <zash@zash.se>2015-11-09 22:56:32 +0100
commit094164e5f0bf835e4fd1dcefa57f3bb4add8325d (patch)
tree3e6fc617741dec52b661ba121b7949d6b284399d /plugins/mod_component.lua
parent1173ee03d3daede409447b6eb049c1ca06145f50 (diff)
parent57fe905a8c3eeffb507a0967512a4caccb0e882b (diff)
downloadprosody-094164e5f0bf835e4fd1dcefa57f3bb4add8325d.tar.gz
prosody-094164e5f0bf835e4fd1dcefa57f3bb4add8325d.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins/mod_component.lua')
-rw-r--r--plugins/mod_component.lua14
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);