Changeset

3383:c7acddf80583

s2smanager: Handle disallow_s2s for incoming streams as well as outgoing
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Jul 2010 22:47:26 +0100
parents 3382:fea0f8e19e4c
children 3384:b7600dd7cd42
files core/s2smanager.lua
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/core/s2smanager.lua	Fri Jul 16 22:28:50 2010 +0100
+++ b/core/s2smanager.lua	Fri Jul 16 22:47:26 2010 +0100
@@ -390,10 +390,22 @@
 	
 		session.streamid = uuid_gen();
 		(session.log or log)("debug", "incoming s2s received <stream:stream>");
-		if session.to_host and not hosts[session.to_host] then
-			-- Attempting to connect to a host we don't serve
-			session:close({ condition = "host-unknown"; text = "This host does not serve "..session.to_host });
-			return;
+		if session.to_host then
+			if not hosts[session.to_host] then
+				-- Attempting to connect to a host we don't serve
+				session:close({
+					condition = "host-unknown";
+					text = "This host does not serve "..session.to_host
+				});
+				return;
+			elseif hosts[session.to_host].disallow_s2s then
+				-- Attempting to connect to a host that disallows s2s
+				session:close({
+					condition = "policy-violation";
+					text = "Server-to-server communication is not allowed to this host";
+				});
+				return;
+			end
 		end
 		send("<?xml version='1.0'?>");
 		send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback',