Software /
code /
prosody
Changeset
968:13e3bdfb02f9
Automated merge with http://waqas.ath.cx:8000/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 08 Apr 2009 20:19:55 +0100 |
parents | 967:b021403c5d80 (current diff) 965:8bc06338aac3 (diff) |
children | 969:9ab6934fb1ff |
files | |
diffstat | 5 files changed, 39 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/core/componentmanager.lua Tue Apr 07 02:32:49 2009 +0500 +++ b/core/componentmanager.lua Wed Apr 08 20:19:55 2009 +0100 @@ -34,12 +34,18 @@ 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 @@ 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 @@ end end +function set_component_handler(host, handler) + components[host] = handler; +end + return _M;
--- a/core/s2smanager.lua Tue Apr 07 02:32:49 2009 +0500 +++ b/core/s2smanager.lua Wed Apr 08 20:19:55 2009 +0100 @@ -177,6 +177,11 @@ 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 @@ end function streamclosed(session) - session.send("</stream:stream>"); + session.sends2s("</stream:stream>"); session.notopen = true; end
--- a/net/server.lua Tue Apr 07 02:32:49 2009 +0500 +++ b/net/server.lua Wed Apr 08 20:19:55 2009 +0100 @@ -244,10 +244,10 @@ 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 @@ --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 @@ _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 @@ -- 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 @@ 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 @@ 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
--- a/plugins/mod_muc.lua Tue Apr 07 02:32:49 2009 +0500 +++ b/plugins/mod_muc.lua Wed Apr 08 20:19:55 2009 +0100 @@ -259,7 +259,7 @@ 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
--- a/util/stanza.lua Tue Apr 07 02:32:49 2009 +0500 +++ b/util/stanza.lua Wed Apr 08 20:19:55 2009 +0100 @@ -65,6 +65,14 @@ 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);