mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Merge pull request #1963 from AndreKoepke/feature/client_https
add https support for clientonly-mode
This commit is contained in:
commit
172d668416
@ -45,6 +45,7 @@ For more information regarding this major change, please check issue [#1860](htt
|
|||||||
- Added the ability to configure a list of modules that shouldn't be update checked.
|
- Added the ability to configure a list of modules that shouldn't be update checked.
|
||||||
- Run linters on git commits
|
- Run linters on git commits
|
||||||
- Added date functionality to compliments: display birthday wishes or celebrate an anniversary
|
- Added date functionality to compliments: display birthday wishes or celebrate an anniversary
|
||||||
|
- Add HTTPS support for clientonly-mode.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Force declaration of public ip address in config file (ISSUE #1852)
|
- Force declaration of public ip address in config file (ISSUE #1852)
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
["address", "port"].forEach((key) => {
|
["address", "port"].forEach((key) => {
|
||||||
config[key] = getCommandLineParameter(key, process.env[key.toUpperCase()]);
|
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) {
|
function getServerConfig(url) {
|
||||||
@ -48,7 +51,7 @@
|
|||||||
if (message !== undefined && typeof message === "string") {
|
if (message !== undefined && typeof message === "string") {
|
||||||
console.log(message);
|
console.log(message);
|
||||||
} else {
|
} 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);
|
process.exit(code);
|
||||||
}
|
}
|
||||||
@ -56,16 +59,18 @@
|
|||||||
getServerAddress();
|
getServerAddress();
|
||||||
|
|
||||||
(config.address && config.port) || fail();
|
(config.address && config.port) || fail();
|
||||||
|
var prefix = config.tls ? "https://" : "http://";
|
||||||
|
|
||||||
// Only start the client if a non-local server was provided
|
// 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) {
|
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) {
|
.then(function (configReturn) {
|
||||||
// Pass along the server config via an environment variable
|
// Pass along the server config via an environment variable
|
||||||
var env = Object.create(process.env);
|
var env = Object.create(process.env);
|
||||||
var options = { env: env };
|
var options = { env: env };
|
||||||
configReturn.address = config.address;
|
configReturn.address = config.address;
|
||||||
configReturn.port = config.port;
|
configReturn.port = config.port;
|
||||||
|
configReturn.tls = config.tls;
|
||||||
env.config = JSON.stringify(configReturn);
|
env.config = JSON.stringify(configReturn);
|
||||||
|
|
||||||
// Spawn electron application
|
// Spawn electron application
|
||||||
|
@ -45,8 +45,16 @@ function createWindow() {
|
|||||||
|
|
||||||
// and load the index.html of the app.
|
// 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
|
// 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;
|
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"
|
// Open the DevTools if run with "npm start dev"
|
||||||
if (process.argv.includes("dev")) {
|
if (process.argv.includes("dev")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user