Add warning on daemon startup if non-local host is set and secure connections not enabled

This commit is contained in:
hensm
2023-02-26 23:44:39 +00:00
parent b5bb949d79
commit 7031009616
3 changed files with 16 additions and 7 deletions

View File

@@ -8,6 +8,7 @@
"bplist-creator": "^0.1.0",
"bplist-parser": "^0.3.1",
"castv2": "^0.1.10",
"chalk": "^4.1.2",
"fast-srp-hap": "^2.0.4",
"mdns": "^2.7.2",
"mime-types": "^2.1.35",
@@ -420,7 +421,6 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
@@ -929,7 +929,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
@@ -1911,7 +1910,6 @@
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
@@ -2586,7 +2584,6 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
@@ -2966,8 +2963,7 @@
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"has-unicode": {
"version": "2.0.1",
@@ -3674,7 +3670,6 @@
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}

View File

@@ -10,6 +10,7 @@
"bplist-creator": "^0.1.0",
"bplist-parser": "^0.3.1",
"castv2": "^0.1.10",
"chalk": "^4.1.2",
"fast-srp-hap": "^2.0.4",
"mdns": "^2.7.2",
"mime-types": "^2.1.35",

View File

@@ -3,6 +3,7 @@ import https from "https";
import { ChildProcess, spawn } from "child_process";
import { Readable } from "stream";
import chalk from "chalk";
import WebSocket from "ws";
import { DecodeTransform, EncodeTransform } from "./transforms.js";
@@ -131,6 +132,18 @@ export function init(opts: DaemonOpts) {
res.end();
});
if (
opts.host !== "localhost" &&
opts.host !== "127.0.0.1" &&
!opts.secure
) {
process.stdout.write(
chalk.red(
"WARNING: A non-local host is set, but secure connections are not enabled!\n"
)
);
}
process.stdout.write(
`Starting WebSocket server at ${opts.secure ? "wss" : "ws"}://${
opts.host.includes(":") ? `[${opts.host}]` : opts.host