diff mod_throttle_unsolicited/mod_throttle_unsolicited.lua @ 2120:f6dcfe263b85

mod_throttle_unsolicited: Mark sessions so they can be matched with 'ORIGIN_MARKED: throttle_unsolicited' by mod_firewall
author Kim Alvefur <zash@zash.se>
date Thu, 17 Mar 2016 16:45:27 +0100
parents 163d55777ad5
children d6fbb57a216c
line wrap: on
line diff
--- a/mod_throttle_unsolicited/mod_throttle_unsolicited.lua	Thu Mar 17 14:45:08 2016 +0100
+++ b/mod_throttle_unsolicited/mod_throttle_unsolicited.lua	Thu Mar 17 16:45:27 2016 +0100
@@ -3,6 +3,7 @@
 local jid_bare = require "util.jid".bare;
 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
 local throttle = require "util.throttle";
+local gettime = require "socket".gettime;
 
 local sessions = prosody.full_sessions;
 
@@ -37,6 +38,7 @@
 		log("debug", "%s is not subscribed to %s@%s", from_jid, to_user, to_host);
 		if not lim:poll(1) then
 			log("warn", "Sent too many messages to non-contacts, bouncing message");
+			event.origin.firewall_mark_throttle_unsolicited = gettime();
 			event.origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
 			return true;
 		end