Mercurial > prosody-hg
comparison plugins/mod_c2s.lua @ 7957:083c062c2fb7
Merge 0.10->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 06 Mar 2017 15:31:21 +0100 |
| parents | 11fcdef5022f bba71bfe2154 |
| children | e38e3300b955 |
comparison
equal
deleted
inserted
replaced
| 7950:f91e7ec9654e | 7957:083c062c2fb7 |
|---|---|
| 166 end | 166 end |
| 167 | 167 |
| 168 session.send("</stream:stream>"); | 168 session.send("</stream:stream>"); |
| 169 function session.send() return false; end | 169 function session.send() return false; end |
| 170 | 170 |
| 171 local reason = (reason and (reason.name or reason.text or reason.condition)) or reason; | 171 local reason_text = (reason and (reason.name or reason.text or reason.condition)) or reason; |
| 172 session.log("debug", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason or "session closed"); | 172 session.log("debug", "c2s stream for %s closed: %s", session.full_jid or ("<"..session.ip..">"), reason_text or "session closed"); |
| 173 | 173 |
| 174 -- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote | 174 -- Authenticated incoming stream may still be sending us stanzas, so wait for </stream:stream> from remote |
| 175 local conn = session.conn; | 175 local conn = session.conn; |
| 176 if reason == nil and not session.notopen and session.type == "c2s" then | 176 if reason_text == nil and not session.notopen and session.type == "c2s" then |
| 177 -- Grace time to process data from authenticated cleanly-closed stream | 177 -- Grace time to process data from authenticated cleanly-closed stream |
| 178 add_task(stream_close_timeout, function () | 178 add_task(stream_close_timeout, function () |
| 179 if not session.destroyed then | 179 if not session.destroyed then |
| 180 session.log("warn", "Failed to receive a stream close response, closing connection anyway..."); | 180 session.log("warn", "Failed to receive a stream close response, closing connection anyway..."); |
| 181 sm_destroy_session(session, reason); | 181 sm_destroy_session(session, reason_text); |
| 182 conn:close(); | 182 conn:close(); |
| 183 end | 183 end |
| 184 end); | 184 end); |
| 185 else | 185 else |
| 186 sm_destroy_session(session, reason); | 186 sm_destroy_session(session, reason_text); |
| 187 conn:close(); | 187 conn:close(); |
| 188 end | 188 end |
| 189 else | 189 else |
| 190 local reason = (reason and (reason.name or reason.text or reason.condition)) or reason; | 190 local reason_text = (reason and (reason.name or reason.text or reason.condition)) or reason; |
| 191 sm_destroy_session(session, reason); | 191 sm_destroy_session(session, reason_text); |
| 192 end | 192 end |
| 193 end | 193 end |
| 194 | 194 |
| 195 module:hook_global("user-deleted", function(event) | 195 module:hook_global("user-deleted", function(event) |
| 196 local username, host = event.username, event.host; | 196 local username, host = event.username, event.host; |
| 197 local user = hosts[host].sessions[username]; | 197 local user = hosts[host].sessions[username]; |
| 198 if user and user.sessions then | 198 if user and user.sessions then |
| 199 for jid, session in pairs(user.sessions) do | 199 for _, session in pairs(user.sessions) do |
| 200 session:close{ condition = "not-authorized", text = "Account deleted" }; | 200 session:close{ condition = "not-authorized", text = "Account deleted" }; |
| 201 end | 201 end |
| 202 end | 202 end |
| 203 end, 200); | 203 end, 200); |
| 204 | 204 |
