Software /
code /
prosody
Comparison
plugins/mod_component.lua @ 4805:1aeece2cc814
mod_component: Components start out as component_unauthed until successful authentication (thanks xnyhps)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 30 Apr 2012 01:02:39 +0100 |
parent | 4803:39ba097ec641 |
child | 4806:27a99c289b90 |
comparison
equal
deleted
inserted
replaced
4804:607414b26c8c | 4805:1aeece2cc814 |
---|---|
74 | 74 |
75 env.connected = true; | 75 env.connected = true; |
76 send = session.send; | 76 send = session.send; |
77 session.on_destroy = on_destroy; | 77 session.on_destroy = on_destroy; |
78 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); | 78 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); |
79 session.type = "component"; | |
79 module:log("info", "External component successfully authenticated"); | 80 module:log("info", "External component successfully authenticated"); |
80 session.send(st.stanza("handshake")); | 81 session.send(st.stanza("handshake")); |
81 | 82 |
82 return true; | 83 return true; |
83 end | 84 end |
242 | 243 |
243 --- Component connlistener | 244 --- Component connlistener |
244 | 245 |
245 function listener.onconnect(conn) | 246 function listener.onconnect(conn) |
246 local _send = conn.write; | 247 local _send = conn.write; |
247 local session = { type = "component", conn = conn, send = function (data) return _send(conn, tostring(data)); end }; | 248 local session = { type = "component_unauthed", conn = conn, send = function (data) return _send(conn, tostring(data)); end }; |
248 | 249 |
249 -- Logging functions -- | 250 -- Logging functions -- |
250 local conn_name = "jcp"..tostring(conn):match("[a-f0-9]+$"); | 251 local conn_name = "jcp"..tostring(conn):match("[a-f0-9]+$"); |
251 session.log = logger.init(conn_name); | 252 session.log = logger.init(conn_name); |
252 session.close = session_close; | 253 session.close = session_close; |