mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
authorMatthew Wild <mwild1@gmail.com>
Fri, 04 May 2012 02:28:10 +0100
changeset 4821 deec69fc33e5
parent 4820 c65edd3bb334
child 4822 5ef05f32bc42
child 4823 a61e78b4a2b3
child 4835 751510cd558d
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
plugins/mod_auth_anonymous.lua
--- a/plugins/mod_auth_anonymous.lua	Fri May 04 02:27:26 2012 +0100
+++ b/plugins/mod_auth_anonymous.lua	Fri May 04 02:28:10 2012 +0100
@@ -50,15 +50,17 @@
 	end
 	return username, host, datastore, data;
 end
-local host = hosts[module.host];
-local _saved_disallow_s2s = host.disallow_s2s;
+
+if module:get_option_boolean("disallow_s2s", true) then
+	module:hook("route/remote", function (event)
+		return false; -- Block outgoing s2s from anonymous users
+	end, 300);
+end
+
 function module.load()
-	_saved_disallow_s2s = host.disallow_s2s;
-	host.disallow_s2s = module:get_option("disallow_s2s") ~= false;
 	datamanager.add_callback(dm_callback);
 end
 function module.unload()
-	host.disallow_s2s = _saved_disallow_s2s;
 	datamanager.remove_callback(dm_callback);
 end