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

@@ -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