Diff

core/sessionmanager.lua @ 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
parent 3091:d6a059af2077
child 3145:675241be2935
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);