From 3dc21c4fc7da90b0ef739a85351c91ab87a38148 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 1 Jul 2009 17:53:18 +0100 Subject: Send xml:lang in stream headers, fixes #78 --- core/s2smanager.lua | 2 +- core/sessionmanager.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 879084d8..63605d5e 100644 --- a/core/s2smanager.lua +++ b/core/s2smanager.lua @@ -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([[]], from_host, to_host)); + conn.write(format([[]], 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..24da7c83 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -165,7 +165,7 @@ function streamopened(session, attr) (session.log or session)("debug", "Client sent opening to %s", session.host); send(""); - send(format("", session.streamid, session.host)); + send(format("", session.streamid, session.host)); if not hosts[session.host] then -- We don't serve this host... -- cgit v1.2.3 From a61b473078bbaa025855b0fdc8bd2046f9bcd481 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 3 Jul 2009 04:04:27 +0100 Subject: stanza_router: Check host.disallow_s2s before routing over s2sout. you can haz no s2s. --- core/stanza_router.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'core') 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); -- cgit v1.2.3 From 43b36591419d29e9fc21a461346c665aec3846b5 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 3 Jul 2009 04:24:30 +0100 Subject: hostmanager: Add disallow_s2s to config, defaults to false unless anonymous_login is enabled, then defaults to true --- core/hostmanager.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core') 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 -- cgit v1.2.3 From 0bee1c3195055afb101b3a7da843bd71f7ef7132 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 3 Jul 2009 14:58:11 +0100 Subject: s2smanager: Log the hostname and address when s2s connection fails instantly --- core/s2smanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/s2smanager.lua b/core/s2smanager.lua index 63605d5e..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 -- cgit v1.2.3 From 63d405dc25e6667dc983c6fe9635ca8e8fbc2768 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 3 Jul 2009 21:37:09 +0100 Subject: sessionmanager: Newly created sessions shouldn't have a priority. Fixes one of the stanza-gobbling bugs \o/ --- core/sessionmanager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 24da7c83..8083ce8a 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; -- cgit v1.2.3 From 18ab4901ef98fcb320ee62b150d4ec51460fe63d Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 3 Jul 2009 21:47:26 +0100 Subject: sessionmanager: Reset bare_sessions[user] after resource conflict resolution. Fixes the other stanza gobbling bug \o/ --- core/sessionmanager.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 8083ce8a..1b6aee17 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -132,6 +132,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 -- cgit v1.2.3 From 0d65c3fef770ea2491514c981b73d1743ddf7b68 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 5 Jul 2009 16:21:58 +0500 Subject: sessionmanager: Replace raw session by an event data table for resource bind/unbind events, allowing extra data --- core/sessionmanager.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 1b6aee17..91a8a22f 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -66,7 +66,7 @@ function destroy_session(session, err) -- 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; @@ -152,7 +152,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 -- cgit v1.2.3 From 44ba02eef0075861e2398dfb5959288c9330f781 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 5 Jul 2009 17:45:44 +0500 Subject: Moved automatic unavailable presence generation on disconnect from sessionmanager to mod_presence --- core/sessionmanager.lua | 8 -------- 1 file changed, 8 deletions(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 91a8a22f..5d7c1c39 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -56,14 +56,6 @@ 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=session, error=err}); -- cgit v1.2.3