Mercurial > prosody-modules
comparison mod_smacks/mod_smacks.lua @ 3218:67f1d1f22625
mod_smacks: Improve logging on resume so session changes are more easily tracked
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 08 Aug 2018 12:49:02 +0100 |
| parents | 14b6ad2b773f |
| children | 9b6206f23151 |
comparison
equal
deleted
inserted
replaced
| 3217:063abaab666f | 3218:67f1d1f22625 |
|---|---|
| 465 end | 465 end |
| 466 | 466 |
| 467 module:hook("s2sout-destroyed", handle_s2s_destroyed); | 467 module:hook("s2sout-destroyed", handle_s2s_destroyed); |
| 468 module:hook("s2sin-destroyed", handle_s2s_destroyed); | 468 module:hook("s2sin-destroyed", handle_s2s_destroyed); |
| 469 | 469 |
| 470 local function get_session_id(session) | |
| 471 return session.id or (tostring(session):match("[a-f0-9]+$")); | |
| 472 end | |
| 473 | |
| 470 function handle_resume(session, stanza, xmlns_sm) | 474 function handle_resume(session, stanza, xmlns_sm) |
| 471 if session.full_jid then | 475 if session.full_jid then |
| 472 session.log("warn", "Tried to resume after resource binding"); | 476 session.log("warn", "Tried to resume after resource binding"); |
| 473 session.send(st.stanza("failed", { xmlns = xmlns_sm }) | 477 session.send(st.stanza("failed", { xmlns = xmlns_sm }) |
| 474 :tag("unexpected-request", { xmlns = xmlns_errors }) | 478 :tag("unexpected-request", { xmlns = xmlns_errors }) |
| 492 :tag("item-not-found", { xmlns = xmlns_errors }) | 496 :tag("item-not-found", { xmlns = xmlns_errors }) |
| 493 ); | 497 ); |
| 494 end; | 498 end; |
| 495 elseif session.username == original_session.username | 499 elseif session.username == original_session.username |
| 496 and session.host == original_session.host then | 500 and session.host == original_session.host then |
| 497 session.log("debug", "mod_smacks resuming existing session..."); | 501 session.log("debug", "mod_smacks resuming existing session %s...", get_session_id(original_session)); |
| 498 -- TODO: All this should move to sessionmanager (e.g. session:replace(new_session)) | 502 -- TODO: All this should move to sessionmanager (e.g. session:replace(new_session)) |
| 499 if original_session.conn then | 503 if original_session.conn then |
| 500 session.log("debug", "mod_smacks closing an old connection for this session"); | 504 original_session.log("debug", "mod_smacks closing an old connection for this session"); |
| 501 local conn = original_session.conn; | 505 local conn = original_session.conn; |
| 502 c2s_sessions[conn] = nil; | 506 c2s_sessions[conn] = nil; |
| 503 conn:close(); | 507 conn:close(); |
| 504 end | 508 end |
| 505 original_session.ip = session.ip; | 509 original_session.ip = session.ip; |
