~samwhited/xmpp

xmpp/internal d---------
internal/stream: remove s2s bool from stream send

Previously we set the namespace depending on whether a server-to-server
value was set. However, the namespace is set in the stream and may be
other values (such as the Jabber Component namespace) as well, so just
leave this alone and let the negotiator handle it.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: make stream config more flexible

Previously the stream config was a struct and the only thing that could
be changed between stream restarts was the features we advertised.
However, we may want to change other parts of the stream config between
restarts. For example, if we figure out the users JID after the first
step we may want to look them up in the database and set the default
stream language based on their preferences.

To accomplish this we now take a stream config function instead of
taking the struct directly (and the Features field has gone back to
being a slice and is no longer a function itself).
Each time we iterate we update the config by calling the function, which
can look up properties of the session before deciding what config needs
to change.

Fixes #106

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/discover: remove extra fallback addresses

Fallback currently breaks if, eg. port 80 has HTTP on it and we connect
because we're just testing whether we can establish TLS, not whether we
can actually get a response that looks like XMPP.

Until we can figure out a better way to probe ports that doesn't involve
violating the separation we keep between layers in the stack, just
remove the fallbacks.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/genfeature: new tool for disco features

This tool allows us to generate disco features for the many packages
that need them. While this is likely a one time change and a tool
doesn't reduce the workload much, there is a chance I'll want to change
what these types look like later so having a tool generate them makes it
easy to update the tool and then not have to redo all the work in each
individual package.

Signed-off-by: Sam Whited <sam@samwhited.com>
all: remove use of deprecated ioutil

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp, websocket: move websocket negotiator config

Previously we configured whether to use websockets in the stream config.
This meant that in a future version of this library where the stream
config can be changed on each feature negotiation step (eg. to set the
language once we know the JID we're trying to auth as) we could swap
back and forth between websockets and the normal way, which is not
ideal. It also just felt wrong there: the websocket negotiator should
obviously be in the websocket package.
However, splitting it out was difficult because unless we copy/paste the
entire implementation (a maintainability nightmare) we end up with
import loops.
To fix this a somewhat jank internal API was added so that we can use
the same implementation but copy/pate a single string key instead of the
whole thing. For now this works and is hidden from the user.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: write docs

Fixes #146

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: add muc room config

Allowing us to pre-configure MUC rooms will reduce boilerplate (and
round trips) for integration tests in the muc package.

Also ship the license file like we do for Go to make sure we're properly
attributing the authors and following the license to the best of our
ability.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/xmpptest: make output easier to compare

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: support MUC

Signed-off-by: Sam Whited <sam@samwhited.com>
all: update build tags for Go 1.17

See: https://golang.org/issues/41184

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration: remove some gosec warnings

Newer versions of gosec warn about file inclsion from a variable, but
this is in integration tests in a safe manner so disable these warnings.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/xmpptest: add encoding test helper

Fixes #84

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/saslerr: remove unnecessary underscore

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/integration/prosody: fix unnecessary loop

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/discover: fix ineffectual break

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/discover: fix unused error

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/attr: export RandomLen

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: clarify argument name on Send

These are not actually the origin/location JIDs, they are the "to" and
"from" attributes (which may be the origin or the location depending on
whether we are receiving end or the sending end).

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: fix missing ID error

Previously the ID said that the initiating entity must set the stream
ID, but the error occured when the receiving entity did not set a stream
ID (which is what is required by RFC 6120 § 4.7.3).

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