~samwhited/xmpp

ref: 1ae4e93cf98dad5040582648a66e8d26f8652374 xmpp/config.go -rw-r--r-- 1.3 KiB
1ae4e93cSam Whited Use Conn as the session and remove Session 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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 (
	"crypto/tls"
	"encoding/xml"

	"mellium.im/xmpp/internal"
	"mellium.im/xmpp/jid"
)

// Config represents the configuration of an XMPP session.
type Config struct {
	// An XMPP server address.
	Location *jid.JID

	// An XMPP connection origin (local address).
	Origin *jid.JID

	// XMPP protocol version
	Version internal.Version

	// TLS config for STARTTLS.
	TLSConfig *tls.Config

	// True if this is a server-to-server session.
	S2S bool

	// The supported stream features.
	Features map[xml.Name]StreamFeature
}

// NewClientConfig constructs a new client-to-server session configuration with
// sane defaults.
func NewClientConfig(origin *jid.JID) *Config {
	return &Config{
		Location: origin.Domain(),
		Origin:   origin,
		Version:  internal.DefaultVersion,

		Features: map[xml.Name]StreamFeature{
		// TODO
		},
	}
}

// NewServerConfig constructs a new server-to-server session configuration with
// sane defaults.
func NewServerConfig(location, origin *jid.JID) *Config {
	return &Config{
		Location: location,
		Origin:   origin,
		S2S:      true,
		Version:  internal.DefaultVersion,

		Features: map[xml.Name]StreamFeature{
		// TODO
		},
	}
}