mod_s2s_never_encrypt_blacklist: cleanup code, also hooks were mixed up.

Thu, 07 Mar 2013 16:55:28 +0100

author
Marco Cirillo <maranda@lightwitch.org>
date
Thu, 07 Mar 2013 16:55:28 +0100
changeset 922
661e2322b4df
parent 921
ef859c9d42c4
child 923
5f38d762d071

mod_s2s_never_encrypt_blacklist: cleanup code, also hooks were mixed up.

mod_s2s_never_encrypt_blacklist/mod_s2s_never_encrypt_blacklist.lua file | annotate | diff | comparison | revisions
--- a/mod_s2s_never_encrypt_blacklist/mod_s2s_never_encrypt_blacklist.lua	Thu Mar 07 14:16:55 2013 +0100
+++ b/mod_s2s_never_encrypt_blacklist/mod_s2s_never_encrypt_blacklist.lua	Thu Mar 07 16:55:28 2013 +0100
@@ -4,15 +4,20 @@
 local bad_servers_ip = module:get_option_set("tls_s2s_blacklist_ip", {})
 
 local function disable_tls_for_baddies_in(event)
-	if bad_servers:contains(event.origin.to_host) or bad_servers_ip:contains(event.origin.conn:ip())
-		then event.origin.conn.starttls = nil end
+	local session = event.origin
+	if bad_servers:contains(session.from_host) or bad_servers_ip:contains(session.conn:ip()) then 
+		module:log("debug", "disabling tls on incoming stream from %s...", tostring(session.from_host));
+		session.conn.starttls = nil
+	end
 end
 
 local function disable_tls_for_baddies_out(event)
-	if bad_servers:contains(event.origin.from_host) or bad_servers_ip:contains(event.origin.conn:ip())
-		then event.origin.conn.starttls = nil end
+	local session = event.origin
+	if bad_servers:contains(session.to_host) then
+		module:log("debug", "disabling tls on outgoing stream from %s...", tostring(session.to_host));
+		session.conn.starttls = nil
+	end
 end
 
-module:hook("s2s-stream-features", disable_tls_for_baddies_out, 10)
-module:hook("stanza/http://etherx.jabber.org/streams:features", disable_tls_for_baddies_in, 510)
-
+module:hook("s2s-stream-features", disable_tls_for_baddies_in, 600)
+module:hook("stanza/http://etherx.jabber.org/streams:features", disable_tls_for_baddies_out, 600)

mercurial