[Pkg-javascript-commits] [ltx] 101/469: router: refuse to send to empty JID, clarify identifiers
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:01:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit 620ddb4805a0eee19089237de526e53efc0362e9
Author: Astro <astro at spaceboyz.net>
Date: Tue Sep 7 00:02:16 2010 +0200
router: refuse to send to empty JID, clarify identifiers
---
lib/xmpp/router.js | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/lib/xmpp/router.js b/lib/xmpp/router.js
index e6a33a3..4357625 100644
--- a/lib/xmpp/router.js
+++ b/lib/xmpp/router.js
@@ -75,23 +75,25 @@ DomainContext.prototype.sendRaw = function(stanza, destDomain) {
return outStream;
};
-DomainContext.prototype.getOutStream = function(domain) {
+DomainContext.prototype.getOutStream = function(destDomain) {
var self = this;
// unfortunately we cannot use the incoming streams
- if (this.s2sOut.hasOwnProperty(domain)) {
+ if (!destDomain) {
+ throw new Error('Trying to reach empty domain');
+ } else if (this.s2sOut.hasOwnProperty(destDomain)) {
// There's one already
- return this.s2sOut[domain];
+ return this.s2sOut[destDomain];
} else {
- console.log("OUTGOING to " + domain);
+ console.log("OUTGOING to " + destDomain);
// Setup a new outgoing connection
- var outStream = Server.makeOutgoingServer(domain);
- this.s2sOut[domain] = outStream;
+ var outStream = Server.makeOutgoingServer(destDomain);
+ this.s2sOut[destDomain] = outStream;
dbgStream('outgoing', outStream);
this.router.setupStream(outStream);
- this.setupStream(domain, outStream);
+ this.setupStream(destDomain, outStream);
outStream.addListener('close', function() {
// purge queue
@@ -112,14 +114,14 @@ DomainContext.prototype.getOutStream = function(domain) {
delete outStream.queue;
// remove from DomainContext
- delete self.s2sOut[domain];
+ delete self.s2sOut[destDomain];
});
// Prepare dialback
outStream.addListener('online', function() {
outStream.isOnline = true;
outStream.dbKey = generateKey();
- outStream.send(Server.dialbackKey(self.domain, domain, outStream.dbKey));
+ outStream.send(Server.dialbackKey(self.domain, destDomain, outStream.dbKey));
});
outStream.addListener('dialbackResult', function(from, to, isValid) {
if (isValid) {
@@ -144,23 +146,23 @@ DomainContext.prototype.getOutStream = function(domain) {
/**
* Called by router when verification is done
*/
-DomainContext.prototype.addInStream = function(domain, stream) {
+DomainContext.prototype.addInStream = function(srcDomain, stream) {
var self = this;
- if (this.s2sIn.hasOwnProperty(domain)) {
+ if (this.s2sIn.hasOwnProperty(srcDomain)) {
// Replace old
- var oldStream = this.s2sIn[domain];
+ var oldStream = this.s2sIn[srcDomain];
oldStream.error('conflict', 'Connection replaced');
}
- this.setupStream(domain, stream);
+ this.setupStream(srcDomain, stream);
stream.isOnline = true;
stream.isVerified = true;
stream.addListener('close', function() {
- if (self.s2sIn[domain] == stream)
- delete self.s2sIn[domain];
+ if (self.s2sIn[srcDomain] == stream)
+ delete self.s2sIn[srcDomain];
});
- this.s2sIn[domain] = stream;
+ this.s2sIn[srcDomain] = stream;
};
DomainContext.prototype.setupStream = function(domain, stream) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list