~samwhited/xmpp

ref: d3ceddb51fa198df1449016fda7923afe83bb0f3 xmpp/starttls.go -rw-r--r-- 604 bytes
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
// 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"
)

// StartTLS returns a new stream feature that can be used for negotiating TLS.
func StartTLS(required bool) StreamFeature {
	return StreamFeature{
		Handler: func(ctx context.Context, conn *Conn) (state SessionState, err error) {
			state = Secure | StreamRestartRequired
			return
		},
		Name:     xml.Name{Local: "starttls", Space: "urn:ietf:params:xml:ns:xmpp-tls"},
		Required: true,
	}
}