Software /
code /
prosody
Comparison
plugins/mod_admin_shell.lua @ 12281:9016071867d7
mod_admin_shell: Track connected events instead of created
The connection events are more appropriate here, where the s2s-created
events happens a bit later or earlier in a sessions lifetime depending
on its direction and for outgoing connections isn't actually the
creation time (which happens immediately after pressing enter, so not
very interesting), but rather closer to the connection time.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 06 Feb 2022 14:34:02 +0100 |
parent | 12258:99560987ea19 |
child | 12291:ec16fb706247 |
comparison
equal
deleted
inserted
replaced
12280:74f8739b967a | 12281:9016071867d7 |
---|---|
1480 elseif s2s_session.type == "s2sin_unauthed" and s2s_session.to_host == nil and s2s_session.from_host == nil then | 1480 elseif s2s_session.type == "s2sin_unauthed" and s2s_session.to_host == nil and s2s_session.from_host == nil then |
1481 print(("Session %s %s (%gs)"):format(s2s_session.id, what, time.now() - time_start)); | 1481 print(("Session %s %s (%gs)"):format(s2s_session.id, what, time.now() - time_start)); |
1482 end | 1482 end |
1483 end | 1483 end |
1484 end | 1484 end |
1485 local oncreated = onchange("created"); | 1485 local onconnected = onchange("connected"); |
1486 local onauthenticated = onchange("authenticated"); | 1486 local onauthenticated = onchange("authenticated"); |
1487 local onestablished = onchange("established"); | 1487 local onestablished = onchange("established"); |
1488 local ondestroyed = onchange("destroyed"); | 1488 local ondestroyed = onchange("destroyed"); |
1489 module:hook("s2s-created", oncreated, 1); | 1489 module:hook("s2s-connected", onconnected, 1); |
1490 module:context(localhost):hook("s2s-authenticated", onauthenticated, 1); | 1490 module:context(localhost):hook("s2s-authenticated", onauthenticated, 1); |
1491 module:hook("s2sout-established", onestablished, 1); | 1491 module:hook("s2sout-established", onestablished, 1); |
1492 module:hook("s2sin-established", onestablished, 1); | 1492 module:hook("s2sin-established", onestablished, 1); |
1493 module:hook("s2s-destroyed", ondestroyed, 1); | 1493 module:hook("s2s-destroyed", ondestroyed, 1); |
1494 return module:context(localhost):send_iq(iq, nil, timeout):finally(function() | 1494 return module:context(localhost):send_iq(iq, nil, timeout):finally(function() |
1495 module:unhook("s2s-created", oncreated); | 1495 module:unhook("s2s-connected", onconnected, 1); |
1496 module:context(localhost):unhook("s2s-authenticated", onauthenticated); | 1496 module:context(localhost):unhook("s2s-authenticated", onauthenticated); |
1497 module:unhook("s2sout-established", onestablished); | 1497 module:unhook("s2sout-established", onestablished); |
1498 module:unhook("s2sin-established", onestablished); | 1498 module:unhook("s2sin-established", onestablished); |
1499 module:unhook("s2s-destroyed", ondestroyed); | 1499 module:unhook("s2s-destroyed", ondestroyed); |
1500 end):next(function(pong) | 1500 end):next(function(pong) |