diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b7f5572..41a3557d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Run tests on long term support and latest stable version of nodejs - Added the ability to configure a list of modules that shouldn't be update checked. - Run linters on git commits +- Add HTTPS support for clientonly-mode. ### Fixed - Force declaration of public ip address in config file (ISSUE #1852) diff --git a/clientonly/index.js b/clientonly/index.js index 6430b270..1c772f5d 100644 --- a/clientonly/index.js +++ b/clientonly/index.js @@ -18,6 +18,9 @@ ["address", "port"].forEach((key) => { config[key] = getCommandLineParameter(key, process.env[key.toUpperCase()]); }); + + // determine if "--use-tls"-flag was provided + config["tls"] = process.argv.indexOf(`--use-tls`) > 0; } function getServerConfig(url) { @@ -48,7 +51,7 @@ if (message !== undefined && typeof message === "string") { console.log(message); } else { - console.log("Usage: 'node clientonly --address 192.168.1.10 --port 8080'"); + console.log("Usage: 'node clientonly --address 192.168.1.10 --port 8080 [--use-tls]'"); } process.exit(code); } @@ -56,16 +59,18 @@ getServerAddress(); (config.address && config.port) || fail(); + var prefix = config.tls ? "https://" : "http://"; // Only start the client if a non-local server was provided if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) === -1) { - getServerConfig(`http://${config.address}:${config.port}/config/`) + getServerConfig(`${prefix}${config.address}:${config.port}/config/`) .then(function (configReturn) { // Pass along the server config via an environment variable var env = Object.create(process.env); var options = { env: env }; configReturn.address = config.address; configReturn.port = config.port; + configReturn.tls = config.tls; env.config = JSON.stringify(configReturn); // Spawn electron application diff --git a/js/electron.js b/js/electron.js index f7615b1c..cb839168 100644 --- a/js/electron.js +++ b/js/electron.js @@ -45,8 +45,16 @@ function createWindow() { // and load the index.html of the app. // If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost + + var prefix; + if (config["tls"] !== null && config["tls"]) { + prefix = 'https://'; + } else { + prefix = 'http://'; + } + var address = (config.address === void 0) | (config.address === "") ? (config.address = "localhost") : config.address; - mainWindow.loadURL(`http://${address}:${config.port}`); + mainWindow.loadURL(`${prefix}${address}:${config.port}`); // Open the DevTools if run with "npm start dev" if (process.argv.includes("dev")) {