Skip to content

Commit

Permalink
Add the insecure launching option to homebridge cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaosT committed Feb 17, 2016
1 parent aea485c commit 1da98bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ var log = require("./logger")._system;

module.exports = function() {

var insecureAccess = false;

program
.version(version)
.option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as the default locations ([path] can also point to a single plugin)', function(p) { Plugin.addPluginPath(p); })
.option('-U, --user-storage-path [path]', 'look for homebridge user files at [path] instead of the default location (~/.homebridge)', function(p) { User.setStoragePath(p); })
.option('-D, --debug', 'turn on debug level logging', function() { require('./logger').setDebugEnabled(true) })
.option('-I, --insecure', 'allow insecure access to homebridge', function() { insecureAccess = true; })
.parse(process.argv);

// Initialize HAP-NodeJS with a custom persist directory
hap.init(User.persistPath());

new Server().run();
new Server(insecureAccess).run();
}
6 changes: 4 additions & 2 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ module.exports = {
Server: Server
}

function Server() {
function Server(insecureAccess) {
this._api = new API(); // object we feed to Plugins
this._plugins = this._loadPlugins(); // plugins[name] = Plugin instance
this._config = this._loadConfig();
this._bridge = this._createBridge();

this._allowInsecureAccess = insecureAccess || false;
}

Server.prototype.run = function() {
Expand Down Expand Up @@ -52,7 +54,7 @@ Server.prototype._publish = function() {
port: bridgeConfig.port || 51826,
pincode: bridgeConfig.pin || "031-45-154",
category: Accessory.Categories.BRIDGE
});
}, this._allowInsecureAccess);

log.info("Homebridge is running on port %s.", bridgeConfig.port || 51826);
}
Expand Down

0 comments on commit 1da98bb

Please sign in to comment.