fixed cli args and logic bug
| @@ -244,6 +244,12 @@ app.use(helmet({ | |||
| 244 | app.use(compression()); | 244 | app.use(compression()); |
| 245 | app.use(responseTime()); | 245 | app.use(responseTime()); |
| 246 | 246 | ||
| 247 | function stringToBool(str) { | ||
| 248 | if (str === 'true') return true; | ||
| 249 | if (str === 'false') return false; | ||
| 250 | return str; // or throw an error | ||
| 251 | } | ||
| 252 | |||
| 247 | const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT); | 253 | const server_port = cliArguments.port ?? process.env.SILLY_TAVERN_PORT ?? getConfigValue('port', DEFAULT_PORT); |
| 248 | const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl; | 254 | const autorun = (cliArguments.autorun ?? getConfigValue('autorun', DEFAULT_AUTORUN)) && !cliArguments.ssl; |
| 249 | const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN); | 255 | const listen = cliArguments.listen ?? getConfigValue('listen', DEFAULT_LISTEN); |
| @@ -257,8 +263,9 @@ const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS); | |||
| 257 | 263 | ||
| 258 | const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY); | 264 | const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY); |
| 259 | 265 | ||
| 260 | const enableIPv6 = cliArguments.enableIPv6 ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6); | 266 | |
| 261 | const enableIPv4 = cliArguments.enableIPv4 ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4); | 267 | const enableIPv6 = stringToBool(cliArguments.enableIPv6) ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6); |
| 268 | const enableIPv4 = stringToBool(cliArguments.enableIPv4) ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4); | ||
| 262 | 269 | ||
| 263 | const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME); | 270 | const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME); |
| 264 | const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT); | 271 | const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT); |
| @@ -957,6 +964,7 @@ async function startServer() { | |||
| 957 | } | 964 | } |
| 958 | 965 | ||
| 959 | 966 | ||
| 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 | } |
| 966 | 974 | ||
| 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 | } |