From da17a46e6f97ebe301584b0b0898ea3ac956bb27 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Thu, 28 Mar 2024 15:57:56 +0100 Subject: [PATCH] Also read stream limits after authentication The [business rules](https://xmpp.org/extensions/xep-0478.html#rules) mention the following: > It is acceptable for the limits on a stream to change whenever new stream features are announced - such as before and after authentication of the connecting entity. The first detection of the stream limits is not deleted as there is also ANONYMOUS authentication. --- xmpp.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xmpp.go b/xmpp.go index a01d2ac..72a49b0 100644 --- a/xmpp.go +++ b/xmpp.go @@ -765,6 +765,20 @@ func (c *Client) init(o *Options) error { if f, err = c.startStream(o, domain); err != nil { return err } + // Make the max. stanza size limit available. + if f.Limits.MaxBytes != "" { + c.LimitMaxBytes, err = strconv.Atoi(f.Limits.MaxBytes) + if err != nil { + c.LimitMaxBytes = 0 + } + } + // Make the servers time limit after which it might consider the stream idle available. + if f.Limits.IdleSeconds != "" { + c.LimitIdleSeconds, err = strconv.Atoi(f.Limits.IdleSeconds) + if err != nil { + c.LimitIdleSeconds = 0 + } + } // Generate a unique cookie cookie := getCookie()