~samwhited/xmpp

bd3ef5df30762aa8afba1e9621bc92d171d5111d — Sam Whited 3 years ago 2e34e0e
all: rewrap copyright comments/use xml.TokenReader
M bind.go => bind.go +3 -3
@@ 50,7 50,7 @@ type bindIQ struct {
	Err  *stanza.Error `xml:"error,ommitempty"`
}

func (biq *bindIQ) TokenReader() xmlstream.TokenReader {
func (biq *bindIQ) TokenReader() xml.TokenReader {
	if biq.Err != nil {
		return stanza.WrapIQ(biq.IQ.To, biq.IQ.Type, biq.Err.TokenReader())
	}


@@ 67,7 67,7 @@ type bindPayload struct {
	JID      *jid.JID `xml:"jid,omitempty"`
}

func (bp bindPayload) TokenReader() xmlstream.TokenReader {
func (bp bindPayload) TokenReader() xml.TokenReader {
	if bp.JID != nil {
		return xmlstream.Wrap(
			xmlstream.ReaderFunc(func() (xml.Token, error) {


@@ 101,7 101,7 @@ func bind(server func(*jid.JID, string) (*jid.JID, error)) StreamFeature {

			return req, e.Flush()
		},
		Parse: func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		Parse: func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
			parsed := struct {
				XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
			}{}

M bind_test.go => bind_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package xmpp


M compress/compression.go => compress/compression.go +1 -1
@@ 68,7 68,7 @@ func New(methods ...Method) xmpp.StreamFeature {
			}
			return false, e.Flush()
		},
		Parse: func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		Parse: func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
			listed := struct {
				XMLName xml.Name `xml:"http://jabber.org/features/compress compression"`
				Methods []string `xml:"http://jabber.org/features/compress method"`

M compress/methods.go => compress/methods.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package compress


M dial.go => dial.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package xmpp


M dial_test.go => dial_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package xmpp


M features.go => features.go +1 -1
@@ 49,7 49,7 @@ type StreamFeature struct {
	// Returns whether or not the feature is required, and any data that will be
	// needed if the feature is selected for negotiation (eg. the list of
	// mechanisms if the feature was SASL).
	Parse func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (req bool, data interface{}, err error)
	Parse func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (req bool, data interface{}, err error)

	// A function that will take over the session temporarily while negotiating
	// the feature. The "mask" SessionState represents the state bits that should

M form/doc.go => form/doc.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package form is an implementation of XEP-0004: Data Forms.
//

M form/fields.go => form/fields.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package form


M form/form.go => form/form.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package form


M form/options.go => form/options.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package form


M ibr2/challenge.go => ibr2/challenge.go +1 -1
@@ 25,5 25,5 @@ type Challenge struct {

	// Receive is used by the client to receive and decode the server's challenge
	// and by the server to receive and decode the clients response.
	Receive func(ctx context.Context, server bool, r xmlstream.TokenReader, start *xml.StartElement) error
	Receive func(ctx context.Context, server bool, r xml.TokenReader, start *xml.StartElement) error
}

M ibr2/form.go => ibr2/form.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package ibr2


M ibr2/ibr2.go => ibr2/ibr2.go +3 -3
@@ 78,8 78,8 @@ func listFunc(challenges ...Challenge) func(context.Context, xmlstream.TokenWrit
	}
}

func parseFunc(challenges ...Challenge) func(context.Context, xmlstream.TokenReader, *xml.StartElement) (req bool, supported interface{}, err error) {
	return func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
func parseFunc(challenges ...Challenge) func(context.Context, xml.TokenReader, *xml.StartElement) (req bool, supported interface{}, err error) {
	return func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		// Parse the list of challenge types sent down by the server.
		parsed := struct {
			Challenges []string `xml:"urn:xmpp:register:0 challenge"`


@@ 107,7 107,7 @@ func parseFunc(challenges ...Challenge) func(context.Context, xmlstream.TokenRea
	}
}

func decodeClientResp(ctx context.Context, r xmlstream.TokenReader, decode func(ctx context.Context, server bool, r xmlstream.TokenReader, start *xml.StartElement) error) (cancel bool, err error) {
func decodeClientResp(ctx context.Context, r xml.TokenReader, decode func(ctx context.Context, server bool, r xml.TokenReader, start *xml.StartElement) error) (cancel bool, err error) {
	var tok xml.Token
	tok, err = r.Token()
	if err != nil {

M ibr2/ibr2_test.go => ibr2/ibr2_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package ibr2


M ibr2/oob.go => ibr2/oob.go +1 -1
@@ 26,7 26,7 @@ func OOB(data *oob.Data, f func(*oob.Data) error) Challenge {
			}
			return w.Flush()
		},
		Receive: func(ctx context.Context, server bool, r xmlstream.TokenReader, start *xml.StartElement) error {
		Receive: func(ctx context.Context, server bool, r xml.TokenReader, start *xml.StartElement) error {
			// The server does not receive a reply for this mechanism.
			if server {
				return nil

M internal/doc.go => internal/doc.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package internal provides non-exported functionality used by xmpp and its
// child packages.

M internal/idgen.go => internal/idgen.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/idgen_test.go => internal/idgen_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/lookup.go => internal/lookup.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/lookup_test.go => internal/lookup_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/ns/ns.go => internal/ns/ns.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package ns provides namespace constants that are used by the xmpp package and
// other internal packages.

M internal/saslerr/errors.go => internal/saslerr/errors.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package saslerr provides error conditions for the XMPP profile of SASL as
// defined by RFC 6120 §6.5.

M internal/saslerr/errors_test.go => internal/saslerr/errors_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package saslerr


M internal/version.go => internal/version.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/version_test.go => internal/version_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M internal/xmlutil.go => internal/xmlutil.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package internal


M ping/ping.go => ping/ping.go +2 -2
@@ 16,9 16,9 @@ import (
// NS is the XML namespace used by XMPP pings. It is provided as a convenience.
const NS = `urn:xmpp:ping`

// IQ returns an xmlstream.TokenReader that outputs a new IQ stanza with a ping
// IQ returns an xml.TokenReader that outputs a new IQ stanza with a ping
// payload.
func IQ(to *jid.JID) xmlstream.TokenReader {
func IQ(to *jid.JID) xml.TokenReader {
	start := xml.StartElement{Name: xml.Name{Local: "ping", Space: NS}}
	return stanza.WrapIQ(to, stanza.GetIQ, xmlstream.Wrap(nil, start))
}

M sasl.go => sasl.go +1 -1
@@ 64,7 64,7 @@ func SASL(identity, password string, mechanisms ...sasl.Mechanism) StreamFeature
			}
			return req, e.EncodeToken(start.End())
		},
		Parse: func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		Parse: func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
			parsed := struct {
				XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
				List    []string `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanism"`

M sasl2/sasl.go => sasl2/sasl.go +2 -2
@@ 79,7 79,7 @@ func SASL(identity, password string, mechanisms ...sasl.Mechanism) xmpp.StreamFe
			}
			return req, e.EncodeToken(start.End())
		},
		Parse: func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		Parse: func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
			parsed := struct {
				XMLName xml.Name `xml:"urn:xmpp:sasl:0 mechanisms"`
				List    []string `xml:"urn:xmpp:sasl:0 mechanism"`


@@ 203,7 203,7 @@ func SASL(identity, password string, mechanisms ...sasl.Mechanism) xmpp.StreamFe
	}
}

func decodeSASLChallenge(r xmlstream.TokenReader, start xml.StartElement, allowChallenge bool) (challenge []byte, success bool, err error) {
func decodeSASLChallenge(r xml.TokenReader, start xml.StartElement, allowChallenge bool) (challenge []byte, success bool, err error) {
	d := xml.NewTokenDecoder(r)
	switch start.Name {
	case xml.Name{Space: NS, Local: "challenge"}:

M sasl2/sasl_test.go => sasl2/sasl_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package sasl2


M sasl_test.go => sasl_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package xmpp


M session.go => session.go +1 -1
@@ 249,7 249,7 @@ func (s *Session) handleInputStream(handler Handler) (err error) {
		}

		rw := struct {
			xmlstream.TokenReader
			xml.TokenReader
			xmlstream.TokenWriter
		}{
			TokenReader: xmlstream.Inner(s),

M stanza/doc.go => stanza/doc.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2017 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package stanza contains functionality for dealing with XMPP stanzas and
// stanza level errors.

M stanza/error.go => stanza/error.go +2 -2
@@ 267,7 267,7 @@ func (se Error) Error() string {
}

// TokenReader satisfies the xmlstream.Marshaler interface for Error.
func (se Error) TokenReader() xmlstream.TokenReader {
func (se Error) TokenReader() xml.TokenReader {
	start := xml.StartElement{
		Name: xml.Name{Space: ``, Local: "error"},
		Attr: []xml.Attr{},


@@ 280,7 280,7 @@ func (se Error) TokenReader() xmlstream.TokenReader {
		start.Attr = append(start.Attr, a)
	}

	var text xmlstream.TokenReader = xmlstream.ReaderFunc(func() (xml.Token, error) {
	var text xml.TokenReader = xmlstream.ReaderFunc(func() (xml.Token, error) {
		return nil, io.EOF
	})
	if se.Text != "" {

M stanza/example_pingstream_test.go => stanza/example_pingstream_test.go +2 -2
@@ 14,9 14,9 @@ import (
	"mellium.im/xmpp/stanza"
)

// WrapPingIQ returns an xmlstream.TokenReader that outputs a new IQ stanza with
// WrapPingIQ returns an xml.TokenReader that outputs a new IQ stanza with
// a ping payload.
func WrapPingIQ(to *jid.JID) xmlstream.TokenReader {
func WrapPingIQ(to *jid.JID) xml.TokenReader {
	start := xml.StartElement{Name: xml.Name{Local: "ping", Space: "urn:xmpp:ping"}}
	return stanza.WrapIQ(to, stanza.GetIQ, xmlstream.Wrap(nil, start))
}

M stanza/stanza.go => stanza/stanza.go +3 -3
@@ 14,7 14,7 @@ import (
// WrapIQ wraps a payload in an IQ stanza.
// The resulting IQ does not contain an id or from attribute and is thus not
// valid without further processing.
func WrapIQ(to *jid.JID, typ IQType, payload xmlstream.TokenReader) xmlstream.TokenReader {
func WrapIQ(to *jid.JID, typ IQType, payload xml.TokenReader) xml.TokenReader {
	return xmlstream.Wrap(payload, xml.StartElement{
		Name: xml.Name{Local: "iq"},
		Attr: []xml.Attr{


@@ 25,7 25,7 @@ func WrapIQ(to *jid.JID, typ IQType, payload xmlstream.TokenReader) xmlstream.To
}

// WrapMessage wraps a payload in a message stanza.
func WrapMessage(to *jid.JID, typ MessageType, payload xmlstream.TokenReader) xmlstream.TokenReader {
func WrapMessage(to *jid.JID, typ MessageType, payload xml.TokenReader) xml.TokenReader {
	return xmlstream.Wrap(payload, xml.StartElement{
		Name: xml.Name{Local: "message"},
		Attr: []xml.Attr{


@@ 36,7 36,7 @@ func WrapMessage(to *jid.JID, typ MessageType, payload xmlstream.TokenReader) xm
}

// WrapPresence wraps a payload in a presence stanza.
func WrapPresence(to *jid.JID, typ PresenceType, payload xmlstream.TokenReader) xmlstream.TokenReader {
func WrapPresence(to *jid.JID, typ PresenceType, payload xml.TokenReader) xml.TokenReader {
	return xmlstream.Wrap(payload, xml.StartElement{
		Name: xml.Name{Local: "presence"},
		Attr: []xml.Attr{

M stanza/stanza_test.go => stanza/stanza_test.go +3 -3
@@ 35,7 35,7 @@ var start = xml.StartElement{
type iqTest struct {
	to      string
	typ     stanza.IQType
	payload xmlstream.TokenReader
	payload xml.TokenReader
	out     string
	err     error
}


@@ 82,7 82,7 @@ func TestIQ(t *testing.T) {
type messageTest struct {
	to      string
	typ     stanza.MessageType
	payload xmlstream.TokenReader
	payload xml.TokenReader
	out     string
	err     error
}


@@ 129,7 129,7 @@ func TestMessage(t *testing.T) {
type presenceTest struct {
	to      string
	typ     stanza.PresenceType
	payload xmlstream.TokenReader
	payload xml.TokenReader
	out     string
	err     error
}

M starttls.go => starttls.go +1 -1
@@ 40,7 40,7 @@ func StartTLS(required bool, cfg *tls.Config) StreamFeature {
			}
			return required, e.EncodeToken(start.End())
		},
		Parse: func(ctx context.Context, r xmlstream.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
		Parse: func(ctx context.Context, r xml.TokenReader, start *xml.StartElement) (bool, interface{}, error) {
			parsed := struct {
				XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
				Required struct {

M stream/error.go => stream/error.go +6 -6
@@ 1,6 1,6 @@
// Copyright 2015 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

// Package stream contains XMPP stream errors as defined by RFC 6120 §4.9.
//


@@ 153,7 153,7 @@ var (
// SeeOtherHostError returns a new see-other-host error with the given network
// address as the host. If the address appears to be a raw IPv6 address (eg.
// "::1"), the error wraps it in brackets ("[::1]").
func SeeOtherHostError(addr net.Addr, payload xmlstream.TokenReader) Error {
func SeeOtherHostError(addr net.Addr, payload xml.TokenReader) Error {
	var cdata string

	// If the address looks like an IPv6 literal, wrap it in []


@@ 184,7 184,7 @@ func SeeOtherHostError(addr net.Addr, payload xmlstream.TokenReader) Error {
type Error struct {
	Err string

	innerXML xmlstream.TokenReader
	innerXML xml.TokenReader
}

// Error satisfies the builtin error interface and returns the name of the


@@ 235,9 235,9 @@ func (s Error) WriteXML(w xmlstream.TokenWriter) (n int, err error) {
	return n, w.Flush()
}

// TokenReader returns a new xmlstream.TokenReader that returns an encoding of
// TokenReader returns a new xml.TokenReader that returns an encoding of
// the error.
func (s Error) TokenReader(payload xmlstream.TokenReader) xmlstream.TokenReader {
func (s Error) TokenReader(payload xml.TokenReader) xml.TokenReader {
	inner := xmlstream.Wrap(s.innerXML, xml.StartElement{Name: xml.Name{Local: s.Err, Space: ns.XMPPStream}})
	if payload != nil {
		inner = xmlstream.MultiReader(

M stream/error_test.go => stream/error_test.go +2 -2
@@ 1,6 1,6 @@
// Copyright 2015 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.
// Use of this source code is governed by the BSD 2-clause
// license that can be found in the LICENSE file.

package stream_test