Skip to content

Commit

Permalink
Fix for issue MagicMirrorOrg#950
Browse files Browse the repository at this point in the history
Changed 'server.js' to allow an empty ipwhitelist to allow any and all hosts instead of none as mentioned in the documentation
  • Loading branch information
QNimbus committed Jul 18, 2017
1 parent 86ae704 commit a7297d2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 18 additions & 18 deletions js/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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; }
2 changes: 1 addition & 1 deletion js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

var port = 8080;
var address = "localhost";
var address = ""; // Default to listening on all interfaces
if (typeof(mmPort) !== "undefined") {
port = mmPort;
}
Expand Down
5 changes: 3 additions & 2 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
2 changes: 1 addition & 1 deletion js/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
12 changes: 6 additions & 6 deletions modules/default/updatenotification/updatenotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
},

Expand All @@ -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 });
}
},

Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/configs/check_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a7297d2

Please sign in to comment.