aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/hostmanager.lua7
-rw-r--r--core/s2smanager.lua4
-rw-r--r--core/sessionmanager.lua17
-rw-r--r--core/stanza_router.lua16
4 files changed, 23 insertions, 21 deletions
diff --git a/core/hostmanager.lua b/core/hostmanager.lua
index a72e5f61..0dd2c9d8 100644
--- a/core/hostmanager.lua
+++ b/core/hostmanager.lua
@@ -27,7 +27,12 @@ end
eventmanager.add_event_hook("server-starting", load_enabled_hosts);
function activate(host, host_config)
- hosts[host] = {type = "local", connected = true, sessions = {}, host = host, s2sout = {}, events = events_new() };
+ hosts[host] = {type = "local", connected = true, sessions = {},
+ host = host, s2sout = {}, events = events_new(),
+ disallow_s2s = configmanager.get(host, "core", "disallow_s2s")
+ or (configmanager.get(host, "core", "anonymous_login")
+ and (configmanager.get(host, "core", "disallow_s2s") ~= false))
+ };
log((hosts_loaded_once and "info") or "debug", "Activated host: %s", host);
eventmanager.fire_event("host-activated", host, host_config);
end
diff --git a/core/s2smanager.lua b/core/s2smanager.lua
index 879084d8..75bb5d36 100644
--- a/core/s2smanager.lua
+++ b/core/s2smanager.lua
@@ -238,7 +238,7 @@ function try_connect(host_session, connect_host, connect_port)
conn:settimeout(0);
local success, err = conn:connect(connect_host, connect_port);
if not success and err ~= "timeout" then
- log("warn", "s2s connect() failed: %s", err);
+ log("warn", "s2s connect() to %s (%s:%d) failed: %s", host_session.to_host, connect_host, connect_port, err);
return false;
end
@@ -253,7 +253,7 @@ function try_connect(host_session, connect_host, connect_port)
local w = conn.write;
host_session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end
- conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host));
+ conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0' xml:lang='en'>]], from_host, to_host));
log("debug", "Connection attempt in progress...");
return true;
end
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index 2862cd52..5d7c1c39 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -40,7 +40,7 @@ module "sessionmanager"
local open_sessions = 0;
function new_session(conn)
- local session = { conn = conn, priority = 0, type = "c2s_unauthed", conntime = gettime() };
+ local session = { conn = conn, type = "c2s_unauthed", conntime = gettime() };
if true then
session.trace = newproxy(true);
getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end;
@@ -56,17 +56,9 @@ end
function destroy_session(session, err)
(session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)");
- -- Send unavailable presence
- if session.presence then
- local pres = st.presence{ type = "unavailable" };
- if (not err) or err == "closed" then err = "connection closed"; end
- pres:tag("status"):text("Disconnected: "..err):up();
- session:dispatch_stanza(pres);
- end
-
-- Remove session/resource from user's session list
if session.full_jid then
- hosts[session.host].events.fire_event("resource-unbind", session);
+ hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err});
hosts[session.host].sessions[session.username].sessions[session.resource] = nil;
full_sessions[session.full_jid] = nil;
@@ -132,6 +124,7 @@ function bind_resource(session, resource)
};
if not next(sessions) then
hosts[session.host].sessions[session.username] = { sessions = sessions };
+ bare_sessions[session.username.."@"..session.host] = hosts[session.host].sessions[session.username];
end
end
if increment and sessions[resource] then
@@ -151,7 +144,7 @@ function bind_resource(session, resource)
session.roster = rm_load_roster(session.username, session.host);
- hosts[session.host].events.fire_event("resource-bind", session);
+ hosts[session.host].events.fire_event("resource-bind", {session=session});
return true;
end
@@ -165,7 +158,7 @@ function streamopened(session, attr)
(session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host);
send("<?xml version='1.0'?>");
- send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0'>", session.streamid, session.host));
+ send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0' xml:lang='en'>", session.streamid, session.host));
if not hosts[session.host] then
-- We don't serve this host...
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index d3bd2445..5bf437f9 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -173,12 +173,16 @@ function core_route_stanza(origin, stanza)
core_post_stanza(origin, stanza);
elseif origin.type == "c2s" then
-- Remote host
- local xmlns = stanza.attr.xmlns;
- --stanza.attr.xmlns = "jabber:server";
- stanza.attr.xmlns = nil;
- log("debug", "sending s2s stanza: %s", tostring(stanza));
- send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors
- stanza.attr.xmlns = xmlns; -- reset
+ if not hosts[from_host].disallow_s2s then
+ local xmlns = stanza.attr.xmlns;
+ --stanza.attr.xmlns = "jabber:server";
+ stanza.attr.xmlns = nil;
+ log("debug", "sending s2s stanza: %s", tostring(stanza));
+ send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors
+ stanza.attr.xmlns = xmlns; -- reset
+ else
+ core_route_stanza(hosts[from_host], st.error_reply(stanza, "cancel", "not-allowed", "Communication with remote servers is not allowed"));
+ end
elseif origin.type == "component" or origin.type == "local" then
-- Route via s2s for components and modules
log("debug", "Routing outgoing stanza for %s to %s", from_host, host);