1 local initialize_filters
= require
"util.filters".initialize
;
2 local logger
= require
"util.logger";
4 local function new_session(typ
)
6 type = typ
.. "_unauthed";
12 local function set_id(session
)
13 local id
= session
.base_type
.. tostring(session
):match("%x+$"):lower();
18 local function set_logger(session
)
19 local log = logger
.init(session
.id
);
24 local function set_conn(session
, conn
)
26 session
.ip
= conn
:ip();
30 local function set_send(session
)
31 local conn
= session
.conn
;
33 function session
.send(data
)
34 session
.log("debug", "Discarding data sent to unconnected session: %s", data
);
39 local filter
= initialize_filters(session
);
41 session
.send
= function (t
)
43 t
= filter("stanzas/out", t
);
46 t
= filter("bytes/out", tostring(t
));
48 local ret
, err
= w(conn
, t
);
50 session
.log("debug", "Error writing to connection: %s", err
);
63 set_logger
= set_logger
;