Changeset

3143:887a6374f51c

sessionmanager: Initialize new sessions for filtering, and add filters for outgoing bytes and stanzas
author Matthew Wild <mwild1@gmail.com>
date Wed, 02 Jun 2010 17:51:14 +0100
parents 3142:3cf02e5e632b
children 3144:9e16012c2155
files core/sessionmanager.lua
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/sessionmanager.lua	Wed Jun 02 17:23:57 2010 +0100
+++ b/core/sessionmanager.lua	Wed Jun 02 17:51:14 2010 +0100
@@ -26,6 +26,7 @@
 local nameprep = require "util.encodings".stringprep.nameprep;
 local resourceprep = require "util.encodings".stringprep.resourceprep;
 
+local filters_initialize = require "util.filters".initialize;
 local fire_event = require "core.eventmanager".fire_event;
 local add_task = require "util.timer".add_task;
 local gettime = require "socket".gettime;
@@ -49,8 +50,20 @@
 	end
 	open_sessions = open_sessions + 1;
 	log("debug", "open sessions now: ".. open_sessions);
+	
+	local filter = filters_initialize(session);
 	local w = conn.write;
-	session.send = function (t) w(conn, tostring(t)); end
+	session.send = function (t)
+		if t.name then
+			t = filter("stanzas/out", t);
+		end
+		if t then
+			t = filter("bytes/out", tostring(t));
+			if t then
+				return w(conn, t);
+			end
+		end
+	end
 	session.ip = conn:ip();
 	local conn_name = "c2s"..tostring(conn):match("[a-f0-9]+$");
 	session.log = logger.init(conn_name);