aboutsummaryrefslogtreecommitdiffstats
path: root/core/sessionmanager.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-06-02 17:51:14 +0100
committerMatthew Wild <mwild1@gmail.com>2010-06-02 17:51:14 +0100
commit828f40f911a2f14ed4a83ce8c70e203887af3361 (patch)
tree067011a90e96d07c6bee1bdf849a680d684fd128 /core/sessionmanager.lua
parent881dc8a1052b66d189426b0323005ad8aca2b38c (diff)
downloadprosody-828f40f911a2f14ed4a83ce8c70e203887af3361.tar.gz
prosody-828f40f911a2f14ed4a83ce8c70e203887af3361.zip
sessionmanager: Initialize new sessions for filtering, and add filters for outgoing bytes and stanzas
Diffstat (limited to 'core/sessionmanager.lua')
-rw-r--r--core/sessionmanager.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua
index fd6ed96e..a3c4c5ad 100644
--- a/core/sessionmanager.lua
+++ b/core/sessionmanager.lua
@@ -26,6 +26,7 @@ local config_get = require "core.configmanager".get;
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 @@ function new_session(conn)
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);