Skip to content

Commit

Permalink
All JavaScript code is now 'strict'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylianst committed Aug 27, 2018
1 parent f6b6fe9 commit 312b937
Show file tree
Hide file tree
Showing 29 changed files with 129 additions and 78 deletions.
2 changes: 2 additions & 0 deletions amtevents.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a MeshAgent object, called upon connection
module.exports.CreateAmtEventsHandler = function (parent) {
var obj = {};
Expand Down
5 changes: 3 additions & 2 deletions amtscanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a Intel AMT Scanner object
module.exports.CreateAmtScanner = function (parent) {
var obj = {};
Expand Down Expand Up @@ -68,11 +70,10 @@ module.exports.CreateAmtScanner = function (parent) {
rangeinfo.server.on('listening', () => {
for (var i = rangeinfo.min; i <= rangeinfo.max; i++) { rangeinfo.server.send(obj.rpacket, 623, obj.IPv4NumToStr(i)); }
});
rangeinfo.timer = setTimeout(function () {
rangeinfo.timer = setTimeout(function () { // ************************* USER OF OUTER VARS!!!!!!!!!!!!!!!
obj.parent.DispatchEvent(['*', userid], obj, { action: 'scanamtdevice', range: rangeinfo.range, results: rangeinfo.results, nolog: 1 });
rangeinfo.server.close();
delete rangeinfo.server;
delete rangeinfo;
}, 3000);
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions amtscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.1.0e
*/

'use strict';

module.exports.CreateAmtScriptEngine = function () {
var o = {};

Expand Down
2 changes: 2 additions & 0 deletions certoperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

module.exports.CertificateOperations = function () {
var obj = {};

Expand Down
2 changes: 2 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

const crypto = require('crypto');

// Binary encoding and decoding functions
Expand Down
2 changes: 2 additions & 0 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.2
*/

'use strict';

//
// Construct Meshcentral database object
//
Expand Down
2 changes: 2 additions & 0 deletions exeHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

'use strict';

const exeJavaScriptGuid = 'B996015880544A19B7F7E9BE44914C18';
const exeMeshPolicyGuid = 'B996015880544A19B7F7E9BE44914C19';

Expand Down
2 changes: 2 additions & 0 deletions interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.3
*/

'use strict';

const crypto = require('crypto');
const common = require('./common.js');

Expand Down
2 changes: 2 additions & 0 deletions letsEncrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.2
*/

'use strict';

module.exports.CreateLetsEncrypt = function (parent) {
try {
const greenlock = require('greenlock');;
Expand Down
2 changes: 2 additions & 0 deletions meshaccelerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

const crypto = require('crypto');
var certStore = null;

Expand Down
7 changes: 5 additions & 2 deletions meshagent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

var AgentConnectCount = 0;

// Construct a MeshAgent object, called upon connection
Expand Down Expand Up @@ -423,9 +425,10 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {

// Process incoming agent JSON data
function processAgentData(msg) {
var str = msg.toString('utf8');
var str = msg.toString('utf8'), command = null;
if (str[0] == '{') {
try { command = JSON.parse(str) } catch (e) { console.log('Unable to parse agent JSON (' + obj.remoteaddr + '): ' + str); return; } // If the command can't be parsed, ignore it.
try { command = JSON.parse(str) } catch (ex) { console.log('Unable to parse agent JSON (' + obj.remoteaddr + '): ' + str, ex); return; } // If the command can't be parsed, ignore it.
if (typeof command != 'object') { return; }
switch (command.action) {
case 'msg':
{
Expand Down
9 changes: 5 additions & 4 deletions meshcentral.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// If app metrics is available
if (process.argv[2] == '--launch') { try { require('appmetrics-dash').monitor({ url: '/', title: 'MeshCentral', port: 88, host: '127.0.0.1' }); } catch (e) { } }

Expand Down Expand Up @@ -420,7 +422,7 @@ function CreateMeshCentralServer(config, args) {
if ((obj.args.nousers == true) && (obj.args.userallowedip == null)) { obj.args.userallowedip = "::1,127.0.0.1"; }

// Set the session length to 60 minutes if not set and set a random key if needed
if ((obj.args.sessiontime == null) || (typeof obj.args.sessiontime != 'number') || (obj.args.sessiontime < 1)) { obj.args.sessiontime = 60; }
if ((obj.args.sessiontime != null) && ((typeof obj.args.sessiontime != 'number') || (obj.args.sessiontime < 1))) { delete obj.args.sessiontime; }
if (!obj.args.sessionkey) { obj.args.sessionkey = buf.toString('hex').toUpperCase(); }

// Start eh web server and if needed, the redirection web server.
Expand Down Expand Up @@ -594,7 +596,6 @@ function CreateMeshCentralServer(config, args) {
}
}
if ((fromPeerServer == null) && (obj.multiServer != null) && ((typeof event != 'object') || (event.nopeers != 1))) { obj.multiServer.DispatchEvent(ids, source, event); }
delete targets;
}

// Get the connection state of a node
Expand Down Expand Up @@ -742,6 +743,7 @@ function CreateMeshCentralServer(config, args) {

if (obj.multiServer == null) {
// Single server mode
var eventConnectChange = 0;

// Remove the agent connection from the nodes connection list
var state = obj.connectivityByNode[nodeid];
Expand Down Expand Up @@ -1082,7 +1084,7 @@ function CreateMeshCentralServer(config, args) {
if ((name != null) && (meshServerState[name] != val)) { if ((val == null) && (meshServerState[name] != null)) { delete meshServerState[name]; changed = true; } else { if (meshServerState[name] != val) { meshServerState[name] = val; changed = true; } } }
if (changed == false) return;
}
r = 'time=' + Date.now() + '\r\n';
var r = 'time=' + Date.now() + '\r\n';
for (var i in meshServerState) { r += (i + '=' + meshServerState[i] + '\r\n'); }
obj.fs.writeFileSync(obj.getConfigFilePath('serverstate.txt'), r);
}
Expand Down Expand Up @@ -1173,7 +1175,6 @@ function InstallModules(modules, func) {
function InstallModule(modulename, func, tag1, tag2) {
try {
var module = require(modulename);
delete module;
} catch (e) {
console.log('Installing ' + modulename + '...');
var child_process = require('child_process');
Expand Down
2 changes: 2 additions & 0 deletions meshmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a MeshAgent object, called upon connection
module.exports.CreateMeshMain = function (parent) {
var obj = {};
Expand Down
2 changes: 2 additions & 0 deletions meshrelay.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

module.exports.CreateMeshRelay = function (parent, ws, req, domain) {
var obj = {};
obj.ws = ws;
Expand Down
8 changes: 5 additions & 3 deletions meshscanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a Mesh Scanner object
// TODO: We need once "server4" and "server6" per interface, or change the default multicast interface as we send.
module.exports.CreateMeshScanner = function (parent) {
Expand All @@ -27,9 +29,9 @@ module.exports.CreateMeshScanner = function (parent) {
var ipv4 = ['*'], ipv6 = ['*']; // Bind to IN_ADDR_ANY always
var interfaces = require('os').networkInterfaces();
for (var i in interfaces) {
var interface = interfaces[i];
for (var j in interface) {
var interface2 = interface[j];
var xinterface = interfaces[i];
for (var j in xinterface) {
var interface2 = xinterface[j];
if ((interface2.mac != '00:00:00:00:00:00') && (interface2.internal == false)) {
if (interface2.family == 'IPv4') { ipv4.push(interface2.address); }
if (interface2.family == 'IPv6') { ipv6.push(interface2.address + '%' + i); }
Expand Down
2 changes: 2 additions & 0 deletions meshuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a MeshAgent object, called upon connection
module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain) {
var obj = {};
Expand Down
2 changes: 2 additions & 0 deletions mpsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a Intel AMT MPS server object
module.exports.CreateMpsServer = function (parent, db, args, certificates) {
var obj = {};
Expand Down
2 changes: 2 additions & 0 deletions multiserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @version v0.0.1
*/

'use strict';

// Construct a Mesh Multi-Server object. This is used for MeshCentral-to-MeshCentral communication.
module.exports.CreateMultiServer = function (parent, args) {
var obj = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.1.9-q",
"version": "0.1.9-r",
"keywords": [
"Remote Management",
"Intel AMT",
Expand Down
2 changes: 2 additions & 0 deletions pass.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// check out https://github.com/tj/node-pwd

'use strict';

// Module dependencies.
const crypto = require('crypto');

Expand Down
Loading

0 comments on commit 312b937

Please sign in to comment.