Software / code / prosody
Comparison
plugins/mod_component.lua @ 5954:6dc73be95213
Merge 0.9->0.10
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 18 Dec 2013 18:36:54 +0100 |
| parent | 5776:bd0ff8ae98a8 |
| parent | 5953:1c08d6cca552 |
| child | 6063:e626ee2fe106 |
comparison
equal
deleted
inserted
replaced
| 5950:bd1d1c29a7e7 | 5954:6dc73be95213 |
|---|---|
| 23 local core_process_stanza = prosody.core_process_stanza; | 23 local core_process_stanza = prosody.core_process_stanza; |
| 24 local hosts = prosody.hosts; | 24 local hosts = prosody.hosts; |
| 25 | 25 |
| 26 local log = module._log; | 26 local log = module._log; |
| 27 | 27 |
| 28 local opt_keepalives = module:get_option_boolean("component_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); | |
| 29 | |
| 28 local sessions = module:shared("sessions"); | 30 local sessions = module:shared("sessions"); |
| 29 | 31 |
| 30 function module.add_host(module) | 32 function module.add_host(module) |
| 31 if module:get_host_type() ~= "component" then | 33 if module:get_host_type() ~= "component" then |
| 32 error("Don't load mod_component manually, it should be for a component, please see http://prosody.im/doc/components", 0); | 34 error("Don't load mod_component manually, it should be for a component, please see http://prosody.im/doc/components", 0); |
| 84 module:log("info", "External component successfully authenticated"); | 86 module:log("info", "External component successfully authenticated"); |
| 85 session.send(st.stanza("handshake")); | 87 session.send(st.stanza("handshake")); |
| 86 | 88 |
| 87 return true; | 89 return true; |
| 88 end | 90 end |
| 89 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth); | 91 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1); |
| 90 | 92 |
| 91 -- Handle stanzas addressed to this component | 93 -- Handle stanzas addressed to this component |
| 92 local function handle_stanza(event) | 94 local function handle_stanza(event) |
| 93 local stanza = event.stanza; | 95 local stanza = event.stanza; |
| 94 if send then | 96 if send then |
| 268 -- Logging functions -- | 270 -- Logging functions -- |
| 269 local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$"); | 271 local conn_name = "jcp"..tostring(session):match("[a-f0-9]+$"); |
| 270 session.log = logger.init(conn_name); | 272 session.log = logger.init(conn_name); |
| 271 session.close = session_close; | 273 session.close = session_close; |
| 272 | 274 |
| 275 if opt_keepalives then | |
| 276 conn:setoption("keepalive", opt_keepalives); | |
| 277 end | |
| 278 | |
| 273 session.log("info", "Incoming Jabber component connection"); | 279 session.log("info", "Incoming Jabber component connection"); |
| 274 | 280 |
| 275 local stream = new_xmpp_stream(session, stream_callbacks); | 281 local stream = new_xmpp_stream(session, stream_callbacks); |
| 276 session.stream = stream; | 282 session.stream = stream; |
| 277 | 283 |