~samwhited/xmpp

2e34e0e1e7aaa7fbb99cb64c18cd1c7965d018d7 — Sam Whited 3 years ago 8f35f66
all: use xmlstream.TokenWriter in features

Fixes #39
8 files changed, 9 insertions(+), 9 deletions(-)

M bind.go
M compress/compression.go
M features.go
M ibr2/ibr2.go
M sasl.go
M sasl2/sasl.go
M session.go
M starttls.go
M bind.go => bind.go +1 -1
@@ 90,7 90,7 @@ func bind(server func(*jid.JID, string) (*jid.JID, error)) StreamFeature {
		Name:       xml.Name{Space: ns.Bind, Local: "bind"},
		Necessary:  Authn,
		Prohibited: Ready,
		List: func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
		List: func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
			req = true
			if err = e.EncodeToken(start); err != nil {
				return req, err

M compress/compression.go => compress/compression.go +1 -1
@@ 38,7 38,7 @@ func New(methods ...Method) xmpp.StreamFeature {
	return xmpp.StreamFeature{
		Name:      xml.Name{Local: "compression", Space: NSFeatures},
		Necessary: xmpp.Secure | xmpp.Authn,
		List: func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
		List: func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
			if err = e.EncodeToken(start); err != nil {
				return
			}

M features.go => features.go +1 -1
@@ 42,7 42,7 @@ type StreamFeature struct {
	// used as the outermost tag in the stream (but also may be ignored). List
	// implementations that call e.EncodeToken directly need to call e.Flush when
	// finished to ensure that the XML is written to the underlying writer.
	List func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error)
	List func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error)

	// Used to parse the feature that begins with the given xml start element
	// (which should have a Name that matches this stream feature's Name).

M ibr2/ibr2.go => ibr2/ibr2.go +2 -2
@@ 44,8 44,8 @@ func challengeStart(typ string) xml.StartElement {
	}
}

func listFunc(challenges ...Challenge) func(context.Context, *xml.Encoder, xml.StartElement) (bool, error) {
	return func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
func listFunc(challenges ...Challenge) func(context.Context, xmlstream.TokenWriter, xml.StartElement) (bool, error) {
	return func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
		if err = e.EncodeToken(start); err != nil {
			return
		}

M sasl.go => sasl.go +1 -1
@@ 38,7 38,7 @@ func SASL(identity, password string, mechanisms ...sasl.Mechanism) StreamFeature
		Name:       xml.Name{Space: ns.SASL, Local: "mechanisms"},
		Necessary:  Secure,
		Prohibited: Authn,
		List: func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
		List: func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
			req = true
			if err = e.EncodeToken(start); err != nil {
				return

M sasl2/sasl.go => sasl2/sasl.go +1 -1
@@ 53,7 53,7 @@ func SASL(identity, password string, mechanisms ...sasl.Mechanism) xmpp.StreamFe
		Name:       xml.Name{Space: NS, Local: "mechanisms"},
		Necessary:  xmpp.Secure,
		Prohibited: xmpp.Authn,
		List: func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
		List: func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
			req = true
			if err = e.EncodeToken(start); err != nil {
				return

M session.go => session.go +1 -1
@@ 82,7 82,7 @@ type Session struct {
	}
	out struct {
		internal.StreamInfo
		e *xml.Encoder
		e xmlstream.TokenWriter
	}
}


M starttls.go => starttls.go +1 -1
@@ 25,7 25,7 @@ func StartTLS(required bool, cfg *tls.Config) StreamFeature {
	return StreamFeature{
		Name:       xml.Name{Local: "starttls", Space: ns.StartTLS},
		Prohibited: Secure,
		List: func(ctx context.Context, e *xml.Encoder, start xml.StartElement) (req bool, err error) {
		List: func(ctx context.Context, e xmlstream.TokenWriter, start xml.StartElement) (req bool, err error) {
			if err = e.EncodeToken(start); err != nil {
				return required, err
			}