~samwhited/xmpp

ibb: add new package

This patch adds an implementation of XEP-0047: In-Band Bytestreams which
can be used to create reliable, bidirectional, data streams over
existing XMPP networks.

Fixes #19

Signed-off-by: Sam Whited <sam@samwhited.com>
jid: add fuzz testing

No issues found, but commit the fuzz testing tool anyways in case we
want to run it again later.

Signed-off-by: Sam Whited <sam@samwhited.com>
styling: minor typo fix in fuzz tests

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add Error method on IQ

This provides an easy way to reply to IQs with an error, similar to
Result.

Signed-off-by: Sam Whited <sam@samwhited.com>
component: use a net.Pipe in tests

This simplifies the code over using two io.Pipe's as we were doing
before.

Signed-off-by: Sam Whited <sam@samwhited.com>
roster: cleanup old tests to use ClientServer

Signed-off-by: Sam Whited <sam@samwhited.com>
all: change stream feature Parse signature

This is a breaking change that makes the function signature of the Parse
function on StreamFeatures actually do what everyone is going to
immediately do with it anyways.

It also fixes the API to make it clear that we're passing a Decoder
which we had to do anyways because if we passed a wrapped TokenReader
and the user created a new decoder from that it wouldn't have had the
start element that we pass in popped from it and would error on reachign
its end element. This wasn't happening only because we were passing the
Decoder anyways and the NewTokenDecoder function would return the
original if the TokenReader was already a Decoder.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: limit feature parse to feature element

Previously a buggy feature parse function could cause us to skip other
features or put the stream in a bad state.

Fixes #86

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/xmpptest: simplify pipe in ClientServer

Previously we used two io.Pipe's to connect the client and server
goroutines. However, net.Pipe can provide a single bidirectional pipe
which does the same thing and reduces boilerplate.

This commit also fixes some minor documentation issues.

Signed-off-by: Sam Whited <sam@samwhited.com>
xmpp: return stream errors during negotiation

Previously arbitrary and confusing errors about unexpected XML would be
returned if a stream error was encountered during stream negotiation.
This unmarshals stream errors properly and returns errors from the
stream package.

Fixes #77

Signed-off-by: Sam Whited <sam@samwhited.com>
Revert "stream: add ErrorReader"

This reverts commit aad439bd828115698d881c67f6b54f01f4bf837e.

Signed-off-by: Sam Whited <sam@samwhited.com>
stream: add ErrorReader

Added a new xmlstream.Transformer that automatically unmarshals and
returns stream errors (but does not handle other stream namespaced
elements). This will be useful in places where we hand off stream
handling to the user (eg. calling a stream features Negotiate function)
and we want to handle any errors that arise during negotiation.

Signed-off-by: Sam Whited <sam@samwhited.com>
internal/stream: typo fix in docs

Signed-off-by: Sam Whited <sam@samwhited.com>
examples: go mod tidy

Oops.

Signed-off-by: Sam Whited <sam@samwhited.com>
receipts: add struct and stream APIs

Previously we had to block waiting on response if we wanted to request
read receipts. However, this is more likely to be used asynchronously
where we associate the receipt with the original message using the ID.
To faciliate this, one type and one function was added: one for the
struct based API and one for the stream based API.

Fixes #89

Signed-off-by: Sam Whited <sam@samwhited.com>
xtime: add integration test

Adds a quick integration test against Prosody. The test couldn't be run
against Ejabberd due to a bug. See
https://github.com/processone/ejabberd/issues/3454 for more info.

Signed-off-by: Sam Whited <sam@samwhited.com>
xtime: fix unmarshaling by changing the Time type

Previously unmarshaling was broken because of some pointer/copying
issues. This changes the type to always unmarshal from the correct
element and fixes the round trip test to detect this sort of issue in
the future.

The refactor for this test also fixes the other place where we wanted to
refactor the roundtrip test to use ClientServer.

Fixes #84

Signed-off-by: Sam Whited <sam@samwhited.com>
ping: improve round trip test using ClientServer

Previously the test directly ran the get function and the handler
against a buffer. For a simple ping this is fine, but even for this it
requires a lot of boilerplate.  Using the new(ish) xmpptest.ClientServer
lets us excersize the code in a way that's closer to using an actual
server.

Updates #84

Signed-off-by: Sam Whited <sam@samwhited.com>
styling: use new xmlstream.Insert for Disable

This functionality will be generally useful throughout this library as
well as for others so I've split it out into the xmlstream module in a
generalized way. This patch uses the new xmlstream version for its
original use in the styling package.

Signed-off-by: Sam Whited <sam@samwhited.com>
styling: add ability to disable styling

Fixes #90

Signed-off-by: Sam Whited <sam@samwhited.com>
examples/msgrepl: don't use %w in logging

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