This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
/
modules.go
129 lines (125 loc) 路 4.7 KB
/
modules.go
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright 2020 The jackal Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"github.com/ortuman/jackal/pkg/module"
"github.com/ortuman/jackal/pkg/module/offline"
"github.com/ortuman/jackal/pkg/module/roster"
"github.com/ortuman/jackal/pkg/module/xep0012"
"github.com/ortuman/jackal/pkg/module/xep0030"
"github.com/ortuman/jackal/pkg/module/xep0049"
"github.com/ortuman/jackal/pkg/module/xep0054"
"github.com/ortuman/jackal/pkg/module/xep0092"
"github.com/ortuman/jackal/pkg/module/xep0115"
"github.com/ortuman/jackal/pkg/module/xep0191"
"github.com/ortuman/jackal/pkg/module/xep0198"
"github.com/ortuman/jackal/pkg/module/xep0199"
"github.com/ortuman/jackal/pkg/module/xep0202"
"github.com/ortuman/jackal/pkg/module/xep0280"
)
var defaultModules = []string{
roster.ModuleName,
offline.ModuleName,
xep0012.ModuleName,
xep0030.ModuleName,
xep0049.ModuleName,
xep0054.ModuleName,
xep0092.ModuleName,
xep0115.ModuleName,
xep0191.ModuleName,
xep0198.ModuleName,
xep0199.ModuleName,
xep0280.ModuleName,
}
var modFns = map[string]func(a *serverApp, cfg modulesConfig) module.Module{
// Roster
// (https://xmpp.org/rfcs/rfc6121.html#roster)
roster.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return roster.New(a.router, a.hosts, a.resMng, a.rep, a.hk)
},
// Offline
// (https://xmpp.org/extensions/xep-0160.html)
offline.ModuleName: func(a *serverApp, cfg modulesConfig) module.Module {
return offline.New(a.router, a.hosts, a.resMng, a.rep, a.locker, a.hk, offline.Config{
QueueSize: cfg.Offline.QueueSize,
})
},
// XEP-0012: Last Activity
// (https://xmpp.org/extensions/xep-0012.html)
xep0012.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0012.New(a.router, a.hosts, a.resMng, a.rep, a.hk)
},
// XEP-0030: Service Discovery
// (https://xmpp.org/extensions/xep-0030.html)
xep0030.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0030.New(a.router, a.comps, a.rep, a.resMng, a.hk)
},
// XEP-0049: Private XML Storage
// (https://xmpp.org/extensions/xep-0049.html)
xep0049.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0049.New(a.router, a.rep, a.hk)
},
// XEP-0054: vcard-temp
// (https://xmpp.org/extensions/xep-0054.html)
xep0054.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0054.New(a.router, a.rep, a.hk)
},
// XEP-0092: Software Version
// (https://xmpp.org/extensions/xep-0092.html)
xep0092.ModuleName: func(a *serverApp, cfg modulesConfig) module.Module {
return xep0092.New(a.router, xep0092.Config{
ShowOS: cfg.Version.ShowOS,
})
},
// XEP-0115: Entity Capabilities
// (https://xmpp.org/extensions/xep-0115.html)
xep0115.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0115.New(a.router, a.rep, a.hk)
},
// XEP-0191: Blocking Command
// (https://xmpp.org/extensions/xep-0191.html)
xep0191.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0191.New(a.router, a.hosts, a.resMng, a.rep, a.hk)
},
// XEP-0198: Stream Management
// (https://xmpp.org/extensions/xep-0198.html)
xep0198.ModuleName: func(a *serverApp, cfg modulesConfig) module.Module {
return xep0198.New(a.router, a.hosts, a.resMng, a.hk, xep0198.Config{
HibernateTime: cfg.Stream.HibernateTime,
RequestAckInterval: cfg.Stream.RequestAckInterval,
WaitForAckTimeout: cfg.Stream.WaitForAckTimeout,
MaxQueueSize: cfg.Stream.MaxQueueSize,
})
},
// XEP-0199: XMPP Ping
// (https://xmpp.org/extensions/xep-0199.html)
xep0199.ModuleName: func(a *serverApp, cfg modulesConfig) module.Module {
return xep0199.New(a.router, a.hk, xep0199.Config{
AckTimeout: cfg.Ping.AckTimeout,
Interval: cfg.Ping.Interval,
SendPings: cfg.Ping.SendPings,
TimeoutAction: cfg.Ping.TimeoutAction,
})
},
// XEP-0202: Entity Time
// (https://xmpp.org/extensions/xep-0202.html)
xep0202.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0202.New(a.router)
},
// XEP-0280: Message Carbons
// (https://xmpp.org/extensions/xep-0280.html)
xep0280.ModuleName: func(a *serverApp, _ modulesConfig) module.Module {
return xep0280.New(a.router, a.hosts, a.resMng, a.hk)
},
}