ref: 8a516e9e064619dcb3d84499b66e1562546be918 xmpp/session_test.go -rw-r--r-- 10.1 KiB
xmpp: make STARTTLS always required

TLS (or at the time, SSL) may have been an optional feature in the past,
but it's not anymore. These days it's far more likely that a server will
always want to require TLS in some form, so giving the user the ability
to turn it off just means we're giving users who won't understand the
consequences of their actions a knob to twiddle. In the very rare case
that a user actually *does* need STARTTLS to be an optional stream
feature, I don't think it's something we should support. For this rare
use case, they'll have to take the maintenance burden on themselves by
copy/pasting the StartTLS feature code and tweaking it for their needs.

Fixes #50

Signed-off-by: Sam Whited <sam@samwhited.com>
all: include close element in handler stream

Previously the close element was not included in the limited XML stream
passed to handlers. This made it possible to enter an infinite loop or
deadlock when trying to use the DecodeElement method of xml.Decoder's.
A regression test has also been added to make sure that we can't read
beyond the end of the element (which was previously the case but there
was no test for this, which was dangerous) and to make sure that the new
behavior (with the end element) is enforced.

Signed-off-by: Sam Whited <sam@samwhited.com>
all: move stanza wrapping to methods

Previously to wrap a payload in a stanza you would use the functions
WrapIQ, WrapMessage, and WrapPresence. Each of these took their
respective stanza types and a payload.
These have been moved to Wrap methods on the various stanza types that
take a payload to make them easier to use in handlers where you already
have the stanza.
The down side is that these methods now exist on types that embed a
stanza, which may be confusing since the payload will be ignored and
only the stanza will be used.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: factor out stream token handling
xmpp: minor copy/paste fix in session tests
xmpp: allow whitespace keepalives
all: allow encoding structs from within handlers
xmpp: fix serve tests
Revert "all: pass Session directly to handler"

This reverts commit 7e76defde884af7cd63b3d6bb7065694db076b8f.
all: move session Flush into TokenWriter
all: add new API to make reading tokens safer
all: pass Session directly to handler
all: add new API to make writing tokens safe
all: remove unnecessary pointer in WrapIQ
all: allow negotiating received sessions
xmpp: normalize "from" attr on stanzas
xmpp: add default IQ response handling

Also remove incorrect statement from Serve docs
xmpp: add simple tests for session.Serve
Revert "all: new session XML read/write API"

This reverts commit 5265955b9c79963ea0c1b9f392db0e56b6a242a8.
xmpp: only error on flush to closed stream

I'm not entirely sure if this behavior is correct, but it "feels right"
and it lets us pass the decoder (with its existing state) directly to
the features (so that trying to wrap it with xml.NewDecoder in parse
will return the original decoder). We should probably just change the
API to accept one to prevent anything else from being passed and
breaking the state on parse.
all: new session XML read/write API