aboutsummaryrefslogtreecommitdiffstats
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
commitdd417c0f4a850be9280c2589f0a582aa0d7d566d (patch)
tree3e6fc617741dec52b661ba121b7949d6b284399d
parent1407c9f7a72c9e27efb9983554e7579d157aecc6 (diff)
parent5d077a0c17dbe89c2481cdebd18f4051dd2d10ae (diff)
downloadprosody-dd417c0f4a850be9280c2589f0a582aa0d7d566d.tar.gz
prosody-dd417c0f4a850be9280c2589f0a582aa0d7d566d.zip
Merge 0.10->trunk
-rw-r--r--core/sessionmanager.lua5
-rw-r--r--core/statsmanager.lua3
-rw-r--r--plugins/mod_component.lua14
-rw-r--r--plugins/mod_s2s/s2sout.lib.lua5
-rw-r--r--plugins/mod_tls.lua5
-rwxr-xr-xprosodyctl2
-rw-r--r--util/queue.lua16
7 files changed, 37 insertions, 13 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index bc4d7cef..6aa0a4f0 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -39,10 +39,9 @@ local function new_session(conn)
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 --git a/core/statsmanager.lua b/core/statsmanager.lua
index d6cbd2bc..7771a2b3 100644
--- a/core/statsmanager.lua
+++ b/core/statsmanager.lua
@@ -66,4 +66,7 @@ return {
get_stats = function ()
return latest_stats, changed_stats, stats_extra;
end;
+ get = function (name)
+ return latest_stats[name], stats_extra[name];
+ end;
};
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);
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
diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua
index 39c4649e..69aafe82 100644
--- a/plugins/mod_tls.lua
+++ b/plugins/mod_tls.lua
@@ -40,17 +40,16 @@ 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;
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 --git a/prosodyctl b/prosodyctl
index e4e22322..76c05fa6 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -890,7 +890,7 @@ function commands.check(arg)
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 --git a/util/queue.lua b/util/queue.lua
index 203da0e3..728e905f 100644
--- a/util/queue.lua
+++ b/util/queue.lua
@@ -16,8 +16,9 @@ local function new(size, allow_wrapping)
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 @@ local function new(size, allow_wrapping)
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