~samwhited/xmpp

.builds: split testing and validation builds

The validation steps don't depend on the testing steps and I sometimes
don't want to wait for the long setup installing static analysis tools
before getting test results or wait for tests to run to get validation
results so run these in parallel.

Signed-off-by: Sam Whited <sam@samwhited.com>
.builds: validate license headers

Validate that all files have the correct license header so that it
doesn't accidentally get left off of new files or get broken by a stray
Vim shortcut and then not noticed until after it has been merged.

Fixes #40

Signed-off-by: Sam Whited <sam@samwhited.com>
.builds: validate URLs in docs

Ensures that all links in the documentation point to valid full URLs
because relative links may break depending on whether we're viewing the
docs on Sourcehut or GitHub.

Fixes #41

Signed-off-by: Sam Whited <sam@samwhited.com>
all: remove relative links from docs

Signed-off-by: Sam Whited <sam@samwhited.com>
docs: mention autosigning commits in CONTRIBUTING

This explains how to autosign commits in the CONTRIBUTING doc because I
found a lot of conflicting information about this when searching online.
It also moves the signing section up to just below the commit message
section since it's part of the commit message and it makes sense that
even if it's not part of that section, it is related and should be
grouped near it.

Signed-off-by: Sam Whited <sam@samwhited.com>
docs: update CONTRIBUTING commit message rules

Update the commit message paragraphs to mention the line length limits
that are required and explain more about what should go into the body.

Signed-off-by: Sam Whited <sam@samwhited.com>
docs: remove dangling words from CONTRIBUTING

There was a sentence fragment in the middle of the documentation on a
line by its own with no context. Remove it since it's an obvious mistake
that should not have been committed.

Signed-off-by: Sam Whited <sam@samwhited.com>
sasl2: remove experimental package

The sasl2 package was experimental and generally unused. Major changes
to the spec are likely coming down the pipeline and the final feature
will likely live alongside the legacy SASL feature.

Signed-off-by: Sam Whited <sam@samwhited.com>
.builds: validate example go.mod files

For each example ensure that go mod tidy has been run like we do for the
main go.mod file.

Fixes #39

Signed-off-by: Sam Whited <sam@samwhited.com>
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>
xmpp, sasl2: use Session ConnectionState for SASL

Previously we attempted to pull the tls.ConnectionState out of the
Session's underlying net.Conn, however, even if the underlying
connection is a *tls.Conn if it is wrapped at all the connection state
would become unavailable. Instead, use the new ConnectionState method on
Session which will always proxy down into the top most *tls.Conn.

Fixes #45

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: provide access to tls.ConnectionState

When a session's underlying net.Conn gets wrapped, the underlying
tls.ConnectionState becomes inaccessible. Saving the connState and
adding a method on Session to access it will let us proxy it forward to
things that need it (eg. SASL) so that they don't break if we negotiate
stream features that wrap the conn.

See #45

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: proxy ConnectionState through teeConn

When we use the TeeIn/TeeOut functionality our connections get wrapped
in a teeConn which would hide the connection state if the underlying
connection is a *tls.Conn (or anything else that exposes TLS connection
state). Proxying it through lets us access the connection state from all
the way up at the Session level (which means that SASL mechanisms can
get access to it).

See #45

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: proxy ConnectionState through wrapped conns

When we wrap a connection during stream negotiation (eg. to add
compression, or some other transformation), proxy through the
ConnectionState method. This way the TLS connection state isn't hidden
from the session which will need it to pass to SASL mechanisms that use
it.

See #45

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: check every feature in the list for required

Previously if a required feature in a list of stream features could not
be negotiated (eg. because one of its necessary state bits wasn't set)
it would be skipped over and the stream features list would not be
marked as containing required features. This means that if no feature in
the list was marked as required, we would assume that was the end of
stream negotiation and bail out early. Instead, make sure to always
parse every feature and check if it's required, even if it can't be
negotiated. This way we know that we need to try again and negotiate one
of the required features after negotiating the optional features.

Fixes #47

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: remove duplicate stream feature data cache

Data returned for caching from stream feature negotiation is always
stored on the session so that it can be accessed later.
Previously it was also being stored on the current stream features list
cache, but this is redundant since we always have access to the session.

Signed-off-by: Sam Whited <sam@samwhited.com>
docs: update contributing doc for SourceHut

Signed-off-by: Sam Whited <sam@samwhited.com>
.builds: sync to GitHub on push

Signed-off-by: Sam Whited <sam@samwhited.com>
.builds: default to SourceHut repo for CI

See #51

Signed-off-by: Sam Whited <sam@samwhited.com>
design: remove status from design docs

We don't want to have to create a new commit when the status changes.
It's much easier to track this on the issue with a label or tag.
Since the issue is linked in the design doc anyways it's still pretty
easy to find out the status.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: move SASL tests to xmpp_test package

I prefer to keep tests in a separate package from the main code where
possible to ensure that the public API is what ends up being tested.
This makes it less likely that tests only test small internal pieces and
not the behavior of the package as a whole.

Signed-off-by: Sam Whited <sam@samwhited.com>
Next