fixed cli args and logic bug

4a8b47a6ffe35e6c85d9f03b4d80d069b43362ec

BPplays <andymalbp@gmail.com>

1 files changed, +11 -3Showing whitespace changes
server.js+11 -3
@@ -244,6 +244,12 @@ app.use(helmet({
244app.use(compression());244app.use(compression());
245app.use(responseTime());245app.use(responseTime());
246246
247function stringToBool(str) {
248 if (str === 'true') return true;
249 if (str === 'false') return false;
250 return str; // or throw an error
251}
252
247const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT);253const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT);
248const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl;254const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl;
249const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN);255const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN);
@@ -257,8 +263,9 @@ const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS);
257263
258const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY);264const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY);
259265
260const enableIPv6 = cliArguments.enableIPv6 ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);266
261const enableIPv4 = cliArguments.enableIPv4 ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);267const enableIPv6 = stringToBool(cliArguments.enableIPv6) ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6);
268const enableIPv4 = stringToBool(cliArguments.enableIPv4) ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4);
262269
263const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME);270const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME);
264const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT);271const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT);
@@ -957,6 +964,7 @@ async function startServer() {
957 }964 }
958965
959966
967
960 if (enableIPv6 === 'auto' && enableIPv4 === 'auto') {968 if (enableIPv6 === 'auto' && enableIPv4 === 'auto') {
961 if (!hasIPv6 && !hasIPv4) {969 if (!hasIPv6 && !hasIPv4) {
962 console.error('Both IPv6 and IPv4 are not detected');970 console.error('Both IPv6 and IPv4 are not detected');
@@ -964,7 +972,7 @@ async function startServer() {
964 }972 }
965 }973 }
966974
967 if (!useIPv6 && !useIPv6) {975 if (!useIPv6 && !useIPv4) {
968 console.error('Both IPv6 and IPv4 are disabled,\nP.S. you should never see this error, at least at one point it was checked for before this, with the rest of the config options');976 console.error('Both IPv6 and IPv4 are disabled,\nP.S. you should never see this error, at least at one point it was checked for before this, with the rest of the config options');
969 process.exit(1);977 process.exit(1);
970 }978 }