diff --git a/CHANGELOG.md b/CHANGELOG.md index 45528ab2..592a521f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Add symbol and color properties of event when `CALENDAR_EVENTS` notification is broadcasted from `default/calendar` module. ### Updated +- Changed 'default.js' - listen on all attached interfaces by default ### Fixed - Fixed issue with incorrect allignment of analog clock when displayed in the center column of the MM +- Fixed ipWhitelist behaviour to make empty whitelist ([]) allow any and all hosts access to the MM ## [2.1.2] - 2017-07-01 diff --git a/js/class.js b/js/class.js index 3c44250e..f2fa5159 100644 --- a/js/class.js +++ b/js/class.js @@ -4,15 +4,15 @@ */ // Inspired by base2 and Prototype -(function() { +(function () { var initializing = false; - var fnTest = /xyz/.test(function() {xyz;}) ? /\b_super\b/ : /.*/; + var fnTest = /xyz/.test(function () { xyz; }) ? /\b_super\b/ : /.*/; // The base Class implementation (does nothing) - this.Class = function() {}; + this.Class = function () { }; // Create a new Class that inherits from this class - Class.extend = function(prop) { + Class.extend = function (prop) { var _super = this.prototype; // Instantiate a base class (but only create the instance, @@ -30,23 +30,23 @@ for (var name in prop) { // Check if we're overwriting an existing function prototype[name] = typeof prop[name] == "function" && - typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function(name, fn) { - return function() { - var tmp = this._super; + typeof _super[name] == "function" && fnTest.test(prop[name]) ? (function (name, fn) { + return function () { + var tmp = this._super; - // Add a new ._super() method that is the same method - // but on the super-class - this._super = _super[name]; + // Add a new ._super() method that is the same method + // but on the super-class + this._super = _super[name]; - // The method only need to be bound temporarily, so we - // remove it when we're done executing - var ret = fn.apply(this, arguments); - this._super = tmp; + // The method only need to be bound temporarily, so we + // remove it when we're done executing + var ret = fn.apply(this, arguments); + this._super = tmp; - return ret; - }; - })(name, prop[name]) : prop[name]; + return ret; + }; + })(name, prop[name]) : prop[name]; } // The dummy class constructor @@ -90,4 +90,4 @@ function cloneObject(obj) { } /*************** DO NOT EDIT THE LINE BELOW ***************/ -if (typeof module !== "undefined") {module.exports = Class;} +if (typeof module !== "undefined") { module.exports = Class; } diff --git a/js/defaults.js b/js/defaults.js index 08c4d945..06ff7b62 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -8,7 +8,7 @@ */ var port = 8080; -var address = "localhost"; +var address = ""; // Default to listening on all interfaces if (typeof(mmPort) !== "undefined") { port = mmPort; } diff --git a/js/electron.js b/js/electron.js index d55f17a0..7003218a 100644 --- a/js/electron.js +++ b/js/electron.js @@ -46,8 +46,9 @@ function createWindow() { mainWindow = new BrowserWindow(electronOptions); // and load the index.html of the app. - //mainWindow.loadURL('file://' + __dirname + '../../index.html'); - mainWindow.loadURL(`http://${config.address}:${config.port}`); + // If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost + var address = config.address === void 0 | config.address === "" ? config.address = "localhost" : config.address; + mainWindow.loadURL(`http://${address}:${config.port}`); // Open the DevTools if run with "npm start dev" if (process.argv.includes("dev")) { diff --git a/js/server.js b/js/server.js index 8520e392..78aac2fe 100644 --- a/js/server.js +++ b/js/server.js @@ -30,7 +30,7 @@ var Server = function(config, callback) { } app.use(function(req, res, next) { - var result = ipfilter(config.ipWhitelist, {mode: "allow", log: false})(req, res, function(err) { + var result = ipfilter(config.ipWhitelist, {mode: config.ipWhitelist.length === 0 ? "deny" : "allow", log: false})(req, res, function(err) { if (err === undefined) { return next(); } diff --git a/modules/default/updatenotification/updatenotification.js b/modules/default/updatenotification/updatenotification.js index f663f593..bf7ec2c1 100644 --- a/modules/default/updatenotification/updatenotification.js +++ b/modules/default/updatenotification/updatenotification.js @@ -11,11 +11,11 @@ Module.register("updatenotification", { }, - notificationReceived: function(notification, payload, sender) { + notificationReceived: function (notification, payload, sender) { if (notification === "DOM_OBJECTS_CREATED") { this.sendSocketNotification("CONFIG", this.config); this.sendSocketNotification("MODULES", Module.definitions); - this.hide(0,{lockString: self.identifier}); + this.hide(0, { lockString: self.identifier }); } }, @@ -26,11 +26,11 @@ Module.register("updatenotification", { } }, - updateUI: function() { + updateUI: function () { var self = this; if (this.status && this.status.behind > 0) { self.updateDom(0); - self.show(1000, {lockString: self.identifier}); + self.show(1000, { lockString: self.identifier }); } }, @@ -59,8 +59,8 @@ Module.register("updatenotification", { var subtext = document.createElement("div"); subtext.innerHTML = this.translate("UPDATE_INFO") - .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1)? "commit" : "commits")) - .replace("BRANCH_NAME", this.status.current); + .replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits")) + .replace("BRANCH_NAME", this.status.current); subtext.className = "xsmall dimmed"; wrapper.appendChild(subtext); } diff --git a/tests/configs/check_config.js b/tests/configs/check_config.js index fa294761..f5ad61c1 100644 --- a/tests/configs/check_config.js +++ b/tests/configs/check_config.js @@ -14,7 +14,7 @@ var path = require("path"); var fs = require("fs"); var Utils = require(__dirname + "/../../js/utils.js"); -if (process.env.NODE_ENV == "test") {return 0}; +if (process.env.NODE_ENV == "test") { return 0 }; /* getConfigFile() * Return string with path of configuration file @@ -48,9 +48,9 @@ try { // In case the there errors show messages and // return console.info(Utils.colors.info("Checking file... ", configFileName)); - // I'm not sure if all ever is utf-8 -fs.readFile(configFileName, "utf-8", function(err, data) { - if (err) {throw err;} +// I'm not sure if all ever is utf-8 +fs.readFile(configFileName, "utf-8", function (err, data) { + if (err) { throw err; } v.JSHINT(data); // Parser by jshint if (v.JSHINT.errors.length == 0) {