Fixed getDomain() when domain uses DNS.

Ylian Saint-Hilaire committed Feb 18, 2020 at 12:02 UTC 393ab66bf436cd020300a61d5d129857dba04982
3 files changed +8 -8
common.js
+4 -4
@@ -26,8 +26,8 @@ module.exports.ShortToStr = function (v) { return String.fromCharCode((v >> 8) &
26 module.exports.ShortToStrX = function (v) { return String.fromCharCode(v & 0xFF, (v >> 8) & 0xFF); };
27 module.exports.IntToStr = function (v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); };
28 module.exports.IntToStrX = function (v) { return String.fromCharCode(v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF); };
29 -module.exports.MakeToArray = function (v) { if (!v || v == null || typeof v == "object") return v; return [v]; };
30 -module.exports.SplitArray = function (v) { return v.split(","); };
29 +module.exports.MakeToArray = function (v) { if (!v || v == null || typeof v == 'object') return v; return [v]; };
30 +module.exports.SplitArray = function (v) { return v.split(','); };
31 module.exports.Clone = function (v) { return JSON.parse(JSON.stringify(v)); };
32 module.exports.IsFilenameValid = (function () { var x1 = /^[^\\/:\*\?"<>\|]+$/, x2 = /^\./, x3 = /^(nul|prn|con|lpt[0-9]|com[0-9])(\.|$)/i; return function isFilenameValid(fname) { return module.exports.validateString(fname, 1, 4096) && x1.test(fname) && !x2.test(fname) && !x3.test(fname) && (fname[0] != '.'); }; })();
33 module.exports.makeFilename = function (v) { return v.split('\\').join('').split('/').join('').split(':').join('').split('*').join('').split('?').join('').split('"').join('').split('<').join('').split('>').join('').split('|').join('').split(' ').join('').split('\'').join(''); }
@@ -122,8 +122,8 @@ module.exports.parseNameValueList = function (list) {
122
123 // Compute the MD5 digest hash for a set of values
124 module.exports.ComputeDigesthash = function (username, password, realm, method, path, qop, nonce, nc, cnonce) {
125 - var ha1 = crypto.createHash('md5').update(username + ":" + realm + ":" + password).digest("hex");
126 - var ha2 = crypto.createHash('md5').update(method + ":" + path).digest("hex");
125 + var ha1 = crypto.createHash('md5').update(username + ":" + realm + ":" + password).digest('hex');
126 + var ha2 = crypto.createHash('md5').update(method + ":" + path).digest('hex');
127 return crypto.createHash('md5').update(ha1 + ":" + nonce + ":" + nc + ":" + cnonce + ":" + qop + ":" + ha2).digest("hex");
128 };
129
meshrelay.js
+1 -1
@@ -337,7 +337,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
337 tag.ws.logfile = null;
338 tag.pws.logfile = null;
339 // Now that the recording file is closed, check if we need to index this file.
340 - if (domain.sessionrecording.index == true) { parent.parent.certificateOperations.acceleratorPerformOperation('indexMcRec', tag.logfile.filename); }
340 + if (domain.sessionrecording.index !== false) { parent.parent.certificateOperations.acceleratorPerformOperation('indexMcRec', tag.logfile.filename); }
341 }, { ws: ws, pws: peer.ws, logfile: ws.logfile });
342 }
343
webserver.js
+3 -3
@@ -498,7 +498,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
498 // Return the current domain of the request
499 function getDomain(req) {
500 if (req.xdomain != null) { return req.xdomain; } // Domain already set for this request, return it.
501 - if (req.headers.host != null) { var d = obj.dnsDomains[req.headers.host.toLowerCase()]; if (d != null) return d; } // If this is a DNS name domain, return it here.
501 + if (req.headers.host != null) { var d = obj.dnsDomains[req.headers.host.split(':')[0].toLowerCase()]; if (d != null) return d; } // If this is a DNS name domain, return it here.
502 var x = req.url.split('/');
503 if (x.length < 2) return parent.config.domains[''];
504 var y = parent.config.domains[x[1].toLowerCase()];
@@ -2676,8 +2676,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
2676 // Fetch the mesh object
2677 ws.meshid = 'mesh/' + domain.id + '/' + req.query.id;
2678 const mesh = obj.meshes[ws.meshid];
2679 - if (mesh == null) { delete ws.meshid; ws.send(JSON.stringify({ errorText: 'Invalid device group: ' + ws.meshid })); ws.close(); return; }
2680 - if (mesh.mtype != 1) { ws.send(JSON.stringify({ errorText: 'Invalid device group type:' + ws.meshid })); ws.close(); return; }
2679 + if (mesh == null) { ws.send(JSON.stringify({ errorText: 'Invalid device group: ' + ws.meshid })); delete ws.meshid; ws.close(); return; }
2680 + if (mesh.mtype != 1) { ws.send(JSON.stringify({ errorText: 'Invalid device group type:' + ws.meshid })); delete ws.meshid; ws.close(); return; }
2681
2682 // Fetch the remote IP:Port for logging
2683 ws.remoteaddr = cleanRemoteAddr(req.ip);