~samwhited/xmpp

ref: d3ceddb51fa198df1449016fda7923afe83bb0f3 xmpp/features.go -rw-r--r-- 1.1 KiB
d3ceddb5Sam Whited Add some new options to Config 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// 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.

package xmpp

import (
	"encoding/xml"

	"golang.org/x/net/context"
)

// A StreamFeature represents a feature that may be selected during stream
// negotiation.
type StreamFeature struct {
	// A function that will take over the session temporarily while negotiating
	// the feature. If StreamRestart is true, the stream will be restarted
	// automatically if Handler does not return an error. SessionState represents
	// the state bits that should be flipped on successful negotiation of the
	// feature. For instance, if this feature upgrades the connection to a
	// TLS connection and performs mutual TLS authentication to log in the user
	// this would be set to Authn|Secure|StreamRestartRequired, but if it does not
	// authenticate the connection it would return Secure|StreamRestartRequired.
	Handler func(ctx context.Context, conn *Conn) (SessionState, error)

	// The XML name of the feature in the <stream:feature/> list.
	Name xml.Name

	// True if negotiating the feature is required.
	Required bool
}