Software /
code /
prosody
Comparison
plugins/mod_component.lua @ 10061:5c71693c8345
Merge 0.11->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 08 Jul 2019 02:44:32 +0200 |
parent | 9870:8f4880576835 |
child | 10111:0f335815244f |
comparison
equal
deleted
inserted
replaced
10060:7a36b7ac309b | 10061:5c71693c8345 |
---|---|
47 env.session = false; | 47 env.session = false; |
48 | 48 |
49 local send; | 49 local send; |
50 | 50 |
51 local function on_destroy(session, err) --luacheck: ignore 212/err | 51 local function on_destroy(session, err) --luacheck: ignore 212/err |
52 module:set_status("warn", err and ("Disconnected: "..err) or "Disconnected"); | |
52 env.connected = false; | 53 env.connected = false; |
53 env.session = false; | 54 env.session = false; |
54 send = nil; | 55 send = nil; |
55 session.on_destroy = nil; | 56 session.on_destroy = nil; |
56 end | 57 end |
100 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); | 101 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); |
101 session.type = "component"; | 102 session.type = "component"; |
102 module:log("info", "External component successfully authenticated"); | 103 module:log("info", "External component successfully authenticated"); |
103 session.send(st.stanza("handshake")); | 104 session.send(st.stanza("handshake")); |
104 module:fire_event("component-authenticated", { session = session }); | 105 module:fire_event("component-authenticated", { session = session }); |
106 module:set_status("info", "Connected"); | |
105 | 107 |
106 return true; | 108 return true; |
107 end | 109 end |
108 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1); | 110 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1); |
109 | 111 |
308 end | 310 end |
309 | 311 |
310 function session.data(_, data) | 312 function session.data(_, data) |
311 local ok, err = stream:feed(data); | 313 local ok, err = stream:feed(data); |
312 if ok then return; end | 314 if ok then return; end |
313 module:log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_")); | 315 log("debug", "Received invalid XML (%s) %d bytes: %q", tostring(err), #data, data:sub(1, 300)); |
314 session:close("not-well-formed"); | 316 session:close("not-well-formed"); |
315 end | 317 end |
316 | 318 |
317 session.dispatch_stanza = stream_callbacks.handlestanza; | 319 session.dispatch_stanza = stream_callbacks.handlestanza; |
318 | 320 |