forked from superfeedr/xmpp-server
/
s2s.js
29 lines (22 loc) · 801 Bytes
/
s2s.js
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
var xmpp = require('node-xmpp');
// XEP-0030: Service Discovery
// http://xmpp.org/extensions/xep-0030.html
function S2S() {
}
exports.configure = function(server, config) {
if(config) {
var s2s = new xmpp.Router(config.s2sPort, server.options.bindAddress); // We only use 5269 has the default S2S port.
// Load TLS key material
if (config.tls) {
s2s.loadCredentials(config.domain, config.tls.keyPath, config.tls.certPath);
}
// S2S plugged to C2S.
s2s.register(server.options.domain, function(stanza) {
server.router.route(stanza);
});
server.s2s = s2s;
server.router.on("externalUser", function(stanza) {
s2s.send(stanza); // this is for S2S.
});
}
}