aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_smacks.lua
Commit message (Collapse)AuthorAgeFilesLines
* mod_smacks: Replace existing watchdog when starting hibernationKim Alvefur2023-04-021-0/+4
| | | | | | There shouldn't be one here but if there is, for some reason, it's better to close it than have it around to wake up and possibly try to destroy the session.
* mod_smacks: Fix stray watchdog closing sessionsKim Alvefur2023-04-021-1/+6
| | | | | | Unsure exactly how this happens, but sometimes a watchdog appears to close a session that isn't hibernating, or hasn't hibernating long enough.
* mod_smacks: Log something when hibernation startsKim Alvefur2023-01-191-0/+1
| | | | | Will hopefully save future confusion about sessions being destroyed when they are in fact not.
* mod_smacks: Disable resumption behavior on s2sKim Alvefur2022-11-131-1/+2
| | | | | | | Since resumption is not supported on s2s currently, there is no point in allocating resumption tokens. The code that removes entries from session_registry is only invoked for c2s sessions, thus enabling resumable smacks on s2s adds an entry that never goes away.
* mod_smacks: Fix #1761 by setting a flag earlierKim Alvefur2022-06-121-1/+1
| | | | | | This ensures that the flag is set even if the pre-drain callback is called from send(), as would be the case if opportunistic writes are enabled.
* mod_smacks: Bounce unhandled stanzas from local origin (fix #1759)0.12.1Kim Alvefur2022-05-271-2/+1
| | | | | | | | | Sending stanzas with a remote session as origin when the stanzas have a local JID in the from attribute trips validation in core.stanza_router, leading to warnings: > Received a stanza claiming to be from remote.example, over a stream authed for localhost.example Using module:send() uses the local host as origin, which is fine here.
* mod_smacks: Fix bounce of stanzas directed to full JID on unclean disconnectKim Alvefur2022-05-271-1/+1
| | | | | | | | | | | | | | | Fixes #1758 Introduced in 1ea01660c79a In e62025f949f9 to and from was inverted since it changed from acting on a reply to acting on the original stanza (or a clone thereof) Unsure of the purpose of this check, you don't usually send stanzas to your own full JID. Perhaps guarding against routing loops? The check was present in the original commit of mod_smacks, prosody-modules rev 9a7671720dec
* mod_smacks: Fix to use current method of counting acked stanzasKim Alvefur2022-05-261-3/+2
| | | | | | | | | Fixes #1757 These places seem to have been left since e62025f949f9 The logic around expected_h in should_ack() misbehaved, always comparing with 0 + unacked instead of acked + unacked.
* mod_smacks: Tweak resumption age buckets towards multiples of 60Kim Alvefur2022-02-041-1/+1
| | | | | This seems like the thing to do for time, which is usually divided into divisors divisible by 60, or multiplied by multiples of 60
* mod_smacks: Log error to silence luacheckKim Alvefur2021-12-311-0/+2
|
* mod_smacks: Limit "old" session resumption countersKim Alvefur2021-12-311-0/+19
| | | | | | Doing this when creating a whole new session seems reasonable because it is already expensive and this is when it may be adding to the old session store, while a successful resumption should be plus-minus zero.
* mod_smacks: Record timestamp with persisted countersKim Alvefur2021-12-311-2/+4
| | | | | For future cleanup routine when people inevitably complain about this data being stored there forever
* mod_smacks: sprinkle some metrics on itJonas Schäfer2021-12-271-2/+45
|
* mod_smacks: Compact code using new stanza APIKim Alvefur2021-12-221-9/+2
|
* mod_smacks: Use more compact resumption tokensKim Alvefur2021-12-221-2/+2
| | | | | | UUID seems like insane overkill for something user-scoped and not security-sensitive. All that is needed is to avoid conflicts among what should be relatively long-lived sessions.
* mod_smacks: Add future todoKim Alvefur2021-12-201-0/+1
| | | | | The vision: All the queueing and counting and session replacement logic in core, with mod_smacks only hooking this up to the XEP-0198 protocol.
* mod_smacks: Only include max resumption time when resumption is activatedKim Alvefur2021-12-201-1/+3
|
* mod_smacks: Fix typosKim Alvefur2021-12-201-2/+2
|
* mod_smacks: Fix error on shutdown if loaded on ComponentKim Alvefur2021-12-201-0/+4
|
* mod_smacks: Fix typo (thanks codespell)Kim Alvefur2021-12-191-1/+1
|
* mod_smacks: Avoid log noise when a non-smacks session is closedKim Alvefur2021-12-191-0/+1
|
* mod_smacks: Check if session was really sleeping before logging messageKim Alvefur2021-12-181-1/+1
| | | | | | It could have been resumed without going into hibernation first, i.e. when the client notices the disconnect before the server, or if it switches networks etc.
* mod_smacks: Fix traceback when bouncing unacked stanzasKim Alvefur2021-12-181-0/+1
| | | | | Errors sent from handle_unacked_stanzas() should usually not be sent to the session itself, but if one is, it should not be queued.
* mod_smacks: Fix duplicate sleep behavior when replacing a sessionKim Alvefur2021-12-181-0/+1
| | | | | Fixes that an extra watchdog was set, leaking the previous one, which went on to do behave as if the session times out.
* mod_smacks: Remove references to connection on hibernationKim Alvefur2021-12-181-1/+4
| | | | | | Still having the connection on the session may cause unintentional behavior, such as the session being treated as if connected, even tho the connection has been closed.
* mod_smacks: Add more loggingKim Alvefur2021-12-181-0/+9
|
* mod_smacks: Remove useless delay in requesting ack on resumptionKim Alvefur2021-12-171-23/+1
| | | | Was this the last place using the delay? Nice!
* mod_smacks: Fix to not wait for acks from before a resumptionKim Alvefur2021-12-171-0/+1
| | | | | Otherwise it can get stuck waiting indefinitely for an ack that made it notice the connection was stale.
* mod_smacks: Split log messages for when an old session exists in storageKim Alvefur2021-12-171-1/+2
| | | | Non-existent did not seem entirely accurate for this case
* mod_smacks: Bounce unacked stanzas on shutdownKim Alvefur2021-12-171-1/+11
|
* mod_smacks: Preserve counter values on shutdownKim Alvefur2021-12-171-0/+22
|
* mod_smacks: Simplify access to local user sessionsKim Alvefur2021-12-171-2/+2
| | | | | Less to type if per chance the next commit also wants to access sessions.
* mod_smacks: Cancel hibernation when session is closedKim Alvefur2021-12-161-0/+6
| | | | | | To ensure that if a session is replaced after it has gone into hibernation, it does not come back and cause trouble for the new session (see previous commit).
* mod_smacks: Skip hibernation logic if session was closed or replacedKim Alvefur2021-12-161-0/+4
| | | | | | | | | | | | The resumption_token is removed when the session is closed via the pre-session-close event, signaling that it cannot be resumed, and therefore no hibernation timeout logic should be invoked. Fixes that if a session somehow is replaced by a new one using the same resource (which is the common behavior), the old session would still be around until it times out at which point it sends `<presence type="unavailable"/>` which would look as if it came from the new session, ie appearing offline to everyone including MUCs.
* mod_smacks: Fix indentationKim Alvefur2021-12-161-4/+4
| | | | Meld keeps messing up indentation when I merge and rebase...
* mod_smacks: Stop stanzas from being queued on hibernation timeoutKim Alvefur2021-12-161-0/+1
| | | | | | | | | | This overloads that flag a bit, but it has the intended effect of stopping outgoing_stanza_filter() from queueing stanzas. Fixes a traceback because of the queue having been removed somewhere around here, since it is no longer needed. Thanks Martin for reporting
* mod_smacks: Limit queue memory consumption using new utilKim Alvefur2021-12-141-51/+72
| | | | | | | | | This brings back the queue size limit that was once added, then removed because destroying the session when reaching the limit was not great. Instead, the queue wraps and overwrites the oldest unacked stanza on the assumption that it will probably be acked anyway and thus does not need to be delivered. If those discarded stanzas turn out to be needed on resumption then the resumption fails.
* mod_smacks: Set a watchdog to watch sleeping sessionsKim Alvefur2021-12-021-59/+27
| | | | | Extending the timeout by poking the watchdog, and letting it go on resumption, should be much better than the previous method.
* mod_smacks: Switch storage for tracking resumption tokensKim Alvefur2021-12-021-40/+5
| | | | | | | | All that was a complicated way to limit the number of resumable sessions. Let's control resource usage some other way. This leaves the essence of mapping resumption tokens to live sessions. This keeps resumption state across reloads.
* mod_smacks: Clear resumption token from persistent storage on resumptionKim Alvefur2021-12-011-0/+1
|
* mod_smacks: Persist old counter values to storageKim Alvefur2021-12-011-7/+5
| | | | | | | | | This allows clients that try to resume a session after a server restart to at least know which of their pending outgoing stanzas were received and which need to be re-sent. This removes the limit on how many of those counters are kept, which should be fixed eventually.
* mod_smacks: Remove now unused variable [luacheck]Kim Alvefur2021-12-151-1/+1
|
* mod_smacks: Remove unused eventKim Alvefur2021-12-151-1/+0
| | | | | Since nothing uses it. Some equivalent functionality may return in the future.
* mod_smacks: Fix typoKim Alvefur2021-12-151-1/+1
|
* mod_smacks: Flag both sessions to prevent duplicating queue on resumptionKim Alvefur2021-12-141-0/+3
| | | | | | | I have no idea what is going on in this code, which session is which? Something has one of the sessions as an upvalue which is where the filter checks for it.
* mod_smacks: Increment a counter for each resumptionKim Alvefur2021-12-061-0/+1
| | | | | Encountered what looks like a bug where after *many* resumptions, part of the queue was not acked.
* mod_smacks: Back out 48f8fa6cea7b - back in a86ae74da96c againKim Alvefur2021-12-131-2/+4
| | | | Maybe it works now with the session patching in the previous commit
* mod_smacks: Patch various self-references on the resumed sessionKim Alvefur2021-12-131-0/+5
| | | | | The number of places where the session is an upvalue to its own methods is too high!
* mod_smacks: Back out a86ae74da96c: Fixed one problem, caused anotherKim Alvefur2021-12-131-4/+2
| | | | | | | | As per a86ae74da96c the 'session' object here is the wrong session, so the attempt to block stanzas from being added to the queue twice did not work causing something of a leak. Instead we have a leak of the previous session.
* mod_smacks: Back out def20683c161Kim Alvefur2021-12-131-1/+0
| | | | The attempted fix completely broke everything after resumption.