1 local initialize_filters
= require
"util.filters".initialize
;
2 local logger
= require
"util.logger";
4 local function new_session(typ
)
6 type = typ
.. "_unauthed";
11 local function set_id(session
)
12 local id
= session
.type .. tostring(session
):match("%x+$"):lower();
17 local function set_logger(session
)
18 local log = logger
.init(session
.id
);
23 local function set_conn(session
, conn
)
25 session
.ip
= conn
:ip();
29 local function set_send(session
)
30 local conn
= session
.conn
;
32 function session
.send(data
)
33 session
.log("debug", "Discarding data sent to unconnected session: %s", tostring(data
));
38 local filter
= initialize_filters(session
);
40 session
.send
= function (t
)
42 t
= filter("stanzas/out", t
);
45 t
= filter("bytes/out", tostring(t
));
47 local ret
, err
= w(conn
, t
);
49 session
.log("debug", "Error writing to connection: %s", tostring(err
));
62 set_logger
= set_logger
;