mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
v1.0.2
This commit is contained in:
17
node/.vscode/launch.json
vendored
Normal file
17
node/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Launch Program",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"program": "${workspaceFolder}\\run_client.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
117
node/configurator.js
Normal file
117
node/configurator.js
Normal file
@@ -0,0 +1,117 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const yargs = require('yargs');
|
||||
const prompt = require('prompt-sync')({sigint: true});
|
||||
const sha256 = require('sha256');
|
||||
const jsonPath = path.join('..', 'olympus.json');
|
||||
|
||||
/* Set the acceptable values */
|
||||
yargs.alias('a', 'address').describe('a', 'Backend address').string('a');
|
||||
yargs.alias('b', 'backendPort').describe('b', 'Backend port').number('b');
|
||||
yargs.alias('c', 'clientPort').describe('c', 'Client port').number('c');
|
||||
yargs.alias('p', 'gameMasterPassword').describe('p', 'Game Master password').string('p');
|
||||
yargs.alias('bp', 'blueCommanderPassword').describe('bp', 'Blue Commander password').string('bp');
|
||||
yargs.alias('rp', 'redCommanderPassword').describe('rp', 'Red Commander password').string('rp');
|
||||
args = yargs.argv;
|
||||
|
||||
async function run() {
|
||||
/* Check that we can read the json */
|
||||
if (fs.existsSync(jsonPath)) {
|
||||
var json = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
|
||||
|
||||
var address = args.address ?? json["server"]["address"];
|
||||
var clientPort = args.clientPort ?? json["client"]["port"];
|
||||
var backendPort = args.backendPort ?? json["server"]["port"];
|
||||
var gameMasterPassword = args.gameMasterPassword? sha256(args.gameMasterPassword): json["authentication"]["gameMasterPassword"];
|
||||
var blueCommanderPassword = args.blueCommanderPassword? sha256(args.blueCommanderPassword): json["authentication"]["blueCommanderPassword"];
|
||||
var redCommanderPassword = args.redCommanderPassword? sha256(args.redCommanderPassword): json["authentication"]["redCommanderPassword"];
|
||||
|
||||
/* Run in interactive mode */
|
||||
if (args.address === undefined && args.clientPort === undefined && args.backendPort === undefined &&
|
||||
args.gameMasterPassword === undefined && args.blueCommanderPassword === undefined && args.redCommanderPassword === undefined) {
|
||||
|
||||
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* _____ _____ _____ ____ _ *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* | __ \\ / ____|/ ____| / __ \\| | *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* | | | | | | (___ | | | | |_ _ _ __ ___ _ __ _ _ ___ *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* | | | | | \\___ \\ | | | | | | | | '_ ` _ \\| '_ \\| | | / __| *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* | |__| | |____ ____) | | |__| | | |_| | | | | | | |_) | |_| \\__ \\ *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* |_____/ \\_____|_____/ \\____/|_|\\__, |_| |_| |_| .__/ \\__,_|___/ *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* __/ | | | *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "* |___/ |_| *");
|
||||
console.log('\x1b[36m%s\x1b[0m', "*********************************************************************");
|
||||
console.log('\x1b[36m%s\x1b[0m', "");
|
||||
|
||||
console.log("DCS Olympus configurator v1.0.2");
|
||||
console.log("");
|
||||
|
||||
var newValue;
|
||||
var result;
|
||||
|
||||
/* Get the new address */
|
||||
newValue = prompt(`Insert an address or press Enter to keep current value ${address}. Use * for any address: `);
|
||||
address = newValue !== ""? newValue: address;
|
||||
|
||||
/* Get the new client port */
|
||||
while (true) {
|
||||
newValue = prompt(`Insert a client port or press Enter to keep current value ${clientPort}. Integers between 1025 and 65535: `);
|
||||
if (newValue === "")
|
||||
break;
|
||||
result = Number(newValue);
|
||||
|
||||
if (!isNaN(result) && Number.isInteger(result) && result > 1024 && result <= 65535)
|
||||
break;
|
||||
}
|
||||
clientPort = newValue? result: clientPort;
|
||||
|
||||
/* Get the new backend port */
|
||||
while (true) {
|
||||
newValue = prompt(`Insert a backend port or press Enter to keep current value ${backendPort}. Integers between 1025 and 65535: `);
|
||||
if (newValue === "")
|
||||
break;
|
||||
result = Number(newValue);
|
||||
|
||||
if (!isNaN(result) && Number.isInteger(result) && result > 1024 && result <= 65535 && result != clientPort)
|
||||
break;
|
||||
|
||||
if (result === clientPort)
|
||||
console.log("Client port and backend port must be different.");
|
||||
}
|
||||
backendPort = newValue? result: backendPort;
|
||||
|
||||
/* Get the new Game Master password */
|
||||
newValue = prompt(`Insert a new Game Master password or press Enter to keep current value: `, {echo: "*"});
|
||||
gameMasterPassword = newValue !== ""? sha256(newValue): gameMasterPassword;
|
||||
|
||||
/* Get the new Blue Commander password */
|
||||
newValue = prompt(`Insert a new Blue Commander password or press Enter to keep current value: `, {echo: "*"});
|
||||
blueCommanderPassword = newValue !== ""? sha256(newValue): blueCommanderPassword;
|
||||
|
||||
/* Get the new Red Commander password */
|
||||
newValue = prompt(`Insert a new Red Commander password or press Enter to keep current value: `, {echo: "*"});
|
||||
redCommanderPassword = newValue !== ""? sha256(newValue): redCommanderPassword;
|
||||
}
|
||||
|
||||
/* Apply the inputs */
|
||||
json["server"]["address"] = address;
|
||||
json["client"]["port"] = clientPort;
|
||||
json["server"]["port"] = backendPort;
|
||||
json["authentication"]["gameMasterPassword"] = gameMasterPassword;
|
||||
json["authentication"]["blueCommanderPassword"] = blueCommanderPassword;
|
||||
json["authentication"]["redCommanderPassword"] = redCommanderPassword;
|
||||
|
||||
/* Write the result to disk */
|
||||
const serialized = JSON.stringify(json, null, 4);
|
||||
fs.writeFileSync(jsonPath, serialized, 'utf8');
|
||||
console.log("Olympus.json updated correctly, goodbye!");
|
||||
}
|
||||
else {
|
||||
console.error("Error, could not read olympus.json file!")
|
||||
}
|
||||
|
||||
/* Wait a bit before closing the window */
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
}
|
||||
|
||||
/* Run the configurator */
|
||||
run();
|
||||
1
node/install_modules.bat
Normal file
1
node/install_modules.bat
Normal file
@@ -0,0 +1 @@
|
||||
start /min npm install yargs prompt-sync sha256 tcp-ping-port
|
||||
Reference in New Issue
Block a user