add logic to prevent user directly running server binary

This commit is contained in:
CoolElectronics 2023-08-20 09:47:23 -04:00
parent 08a4137071
commit 55dece7bc3
No known key found for this signature in database
GPG key ID: F63593D168636C50
2 changed files with 12 additions and 3 deletions

View file

@ -27,7 +27,7 @@ https.get(
function start() {
console.log(chalk.blue(`Starting adrift...`));
let child = spawn(`${dir}/${appname}`, [], { stdio: ["inherit", "inherit", "pipe"] });
let child = spawn(`${dir}/${appname}`, ["--start"], { stdio: ["inherit", "inherit", "pipe"] });
let errbuf = "";

View file

@ -19,6 +19,7 @@ import fs from "fs";
import { exit } from "process";
import { datadir } from "./lib";
async function config() {
let dir = datadir();
@ -97,7 +98,7 @@ async function login(credentials: any) {
}
}
}
(async () => {
async function start() {
let dir = datadir();
let conf;
@ -152,4 +153,12 @@ async function login(credentials: any) {
}
});
}
})();
}
if (process.argv[2] != "--start") {
console.error(chalk.red.bold("DO NOT LAUNCH THIS DIRECTLY, YOU SHOULD HAVE DOWNLOADED THE 'autoupdater' BINARY"))
setTimeout(() => process.exit(1), 5000);
} else {
start();
}