aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-04-08 20:19:55 +0100
committerMatthew Wild <mwild1@gmail.com>2009-04-08 20:19:55 +0100
commitf6a5da2375a21b7cd2429b7ba82d819683af5109 (patch)
tree7148b7e142e79cfc47dcec5f7e22f47a219946b3
parent9982558804de3976a3d5d9e12ab5215503420e0f (diff)
parentedd59b5d381bd8b0daee063a99f8678f86f6b9bb (diff)
downloadprosody-f6a5da2375a21b7cd2429b7ba82d819683af5109.tar.gz
prosody-f6a5da2375a21b7cd2429b7ba82d819683af5109.zip
Automated merge with http://waqas.ath.cx:8000/
-rw-r--r--core/componentmanager.lua18
-rw-r--r--core/s2smanager.lua7
-rw-r--r--net/server.lua14
-rw-r--r--plugins/mod_muc.lua2
-rw-r--r--util/stanza.lua8
5 files changed, 39 insertions, 10 deletions
diff --git a/core/componentmanager.lua b/core/componentmanager.lua
index 0b13c5c5..5efb1f51 100644
--- a/core/componentmanager.lua
+++ b/core/componentmanager.lua
@@ -34,12 +34,18 @@ end);
module "componentmanager"
+local function default_component_handler(origin, stanza)
+ origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable"));
+end
+
+
function load_enabled_components(config)
local defined_hosts = config or configmanager.getconfig();
for host, host_config in pairs(defined_hosts) do
if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
hosts[host] = { type = "component", host = host, connected = false, s2sout = {} };
+ components[host] = default_component_handler;
local ok, err = modulemanager.load(host, host_config.core.component_module);
if not ok then
log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err));
@@ -93,7 +99,13 @@ function deregister_component(host)
if components[host] then
modulemanager.unload(host, "dialback");
components[host] = nil;
- hosts[host] = nil;
+ local host_config = defined_hosts[host];
+ if ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then
+ -- Set default handler
+ else
+ -- Component not in config, or disabled, remove
+ hosts[host] = nil;
+ end
-- remove from disco_items
if not(host:find("@", 1, true) or host:find("/", 1, true)) and host:find(".", 1, true) then
disco_items:remove(host:sub(host:find(".", 1, true)+1), host);
@@ -105,4 +117,8 @@ function deregister_component(host)
end
end
+function set_component_handler(host, handler)
+ components[host] = handler;
+end
+
return _M;
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 4c758159..0ef8e241 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -177,6 +177,11 @@ function attempt_connection(host_session, err)
return false;
end
+ if not (connect_host and connect_port) then
+ -- Likely we couldn't resolve DNS
+ return false;
+ end
+
-- Ok, we're going to try to connect
conn:settimeout(0);
local success, err = conn:connect(connect_host, connect_port);
@@ -245,7 +250,7 @@ function streamopened(session, attr)
end
function streamclosed(session)
- session.send("</stream:stream>");
+ session.sends2s("</stream:stream>");
session.notopen = true;
end
diff --git a/net/server.lua b/net/server.lua
index 891d32db..755b369e 100644
--- a/net/server.lua
+++ b/net/server.lua
@@ -244,10 +244,10 @@ wrapserver = function( listeners, socket, ip, serverport, pattern, sslctx, maxco
return false
end
connections = connections + 1
- out_put( "server.lua: accepted new client connection from ", ip, ":", clientport, " to ", serverport)
+ out_put( "server.lua: accepted new client connection from ", tostring(ip), ":", tostring(clientport), " to ", tostring(serverport))
return dispatch( handler )
elseif err then -- maybe timeout or something else
- out_put( "server.lua: error with new client connection: ", err )
+ out_put( "server.lua: error with new client connection: ", tostring(err) )
return false
end
end
@@ -443,7 +443,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
--out_put( "server.lua: read data '", buffer, "', error: ", err )
return dispatch( handler, buffer, err )
else -- connections was closed or fatal error
- out_put( "server.lua: client ", ip, ":", tostring(clientport), " error: ", tostring(err) )
+ out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " error: ", tostring(err) )
fatalerror = true
disconnect( handler, err )
_ = handler and handler.close( )
@@ -474,7 +474,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
_writetimes[ handler ] = _currenttime
return true
else -- connection was closed during sending or fatal error
- out_put( "server.lua: client ", ip, ":", clientport, " error: ", err )
+ out_put( "server.lua: client ", tostring(ip), ":", tostring(clientport), " error: ", tostring(err) )
fatalerror = true
disconnect( handler, err )
_ = handler and handler.close( )
@@ -500,7 +500,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
-- return dispatch( handler )
return true
else
- out_put( "server.lua: error during ssl handshake: ", err )
+ out_put( "server.lua: error during ssl handshake: ", tostring(err) )
if err == "wantwrite" and not wrote then
_sendlistlen = _sendlistlen + 1
_sendlist[ _sendlistlen ] = client
@@ -526,7 +526,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
local err
socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
if err then
- out_put( "server.lua: ssl error: ", err )
+ out_put( "server.lua: ssl error: ", tostring(err) )
mem_free( )
return nil, nil, err -- fatal error
end
@@ -546,7 +546,7 @@ wrapconnection = function( server, listeners, socket, ip, serverport, clientport
socket, err = ssl_wrap( socket, sslctx ) -- wrap socket
--out_put( "server.lua: sslwrapped socket is " .. tostring( socket ) )
if err then
- out_put( "server.lua: error while starting tls on client: ", err )
+ out_put( "server.lua: error while starting tls on client: ", tostring(err) )
return nil, err -- fatal error
end
diff --git a/plugins/mod_muc.lua b/plugins/mod_muc.lua
index 117a044b..8fbe1e91 100644
--- a/plugins/mod_muc.lua
+++ b/plugins/mod_muc.lua
@@ -259,7 +259,7 @@ function handle_to_occupant(origin, stanza) -- PM, vCards, etc
end
else -- possible rejoin
log("debug", "%s had connection replaced", current_nick);
- handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('Replaced by new connection')); -- send unavailable
+ handle_to_occupant(origin, st.presence({type='unavailable', from=from, to=to}):tag('status'):text('Replaced by new connection'):up()); -- send unavailable
handle_to_occupant(origin, stanza); -- resend available
end
else -- enter room
diff --git a/util/stanza.lua b/util/stanza.lua
index 1ad3679b..7e40dfa4 100644
--- a/util/stanza.lua
+++ b/util/stanza.lua
@@ -65,6 +65,14 @@ function stanza_mt:up()
return self;
end
+function stanza_mt:reset()
+ local last_add = self.last_add;
+ for i = 1,#last_add do
+ last_add[i] = nil;
+ end
+ return self;
+end
+
function stanza_mt:add_direct_child(child)
if type(child) == "table" then
t_insert(self.tags, child);