fixed backward compat, and check if auto before getting addrs
| @@ -8,7 +8,7 @@ cardsCacheCapacity: 100 | ||
| 8 | 8 | listen: false |
| 9 | 9 | # Enables IPv6 and/or IPv4 protocols. Need to have at least one enabled! |
| 10 | 10 | # - Use option "auto" to automatically detect support |
| 11 | 11 | # - Use "enabled"true or "disabled"false (no qoutes) to enable or disable each protocol |
| 12 | 12 | protocol: |
| 13 | 13 | ipv4: auto |
| 14 | 14 | ipv6: auto |
| @@ -257,8 +257,8 @@ const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS); | ||
| 257 | 257 | |
| 258 | 258 | const uploadsPath = path.join(dataRoot, UPLOADS_DIRECTORY); |
| 259 | 259 | |
| 260 | 260 | constlet enableIPv6 = cliArguments.enableIPv6 ?? getConfigValue('protocol.ipv6', DEFAULT_ENABLE_IPV6); |
| 261 | 261 | constlet enableIPv4 = cliArguments.enableIPv4 ?? getConfigValue('protocol.ipv4', DEFAULT_ENABLE_IPV4); |
| 262 | 262 | |
| 263 | 263 | const autorunHostname = cliArguments.autorunHostname ?? getConfigValue('autorunHostname', DEFAULT_AUTORUN_HOSTNAME); |
| 264 | 264 | const autorunPortOverride = cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', DEFAULT_AUTORUN_PORT); |
| @@ -281,7 +281,8 @@ if (dnsPreferIPv6) { | ||
| 281 | 281 | console.log('Preferring IPv4 for DNS resolution'); |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | -const ipOptions = ['enabled', 'auto', 'disabled']; | |
| 284 | + | |
| 285 | +const ipOptions = [true, 'auto', false]; | |
| 285 | 286 | |
| 286 | 287 | if (!ipOptions.includes(enableIPv6)) { |
| 287 | 288 | console.error('`protocol: ipv6` option invalid\n use:', ipOptions); |
| @@ -292,7 +293,7 @@ if (!ipOptions.includes(enableIPv4)) { | ||
| 292 | 293 | process.exit(1); |
| 293 | 294 | } |
| 294 | 295 | |
| 295 | 296 | if (enableIPv6 == 'disabled'= false && enableIPv4 === 'disabled'false) { |
| 296 | 297 | console.error('error: You can\'t disable all internet protocols: at least IPv6 or IPv4 must be enabled.'); |
| 297 | 298 | process.exit(1); |
| 298 | 299 | } |
| @@ -924,10 +925,13 @@ async function startHTTPorHTTPS(useIPv6, useIPv4) { | ||
| 924 | 925 | } |
| 925 | 926 | |
| 926 | 927 | async function startServer() { |
| 927 | 928 | let useIPv6 = (enableIPv6 === 'enabled'true); |
| 928 | 929 | let useIPv4 = (enableIPv4 === 'enabled'true); |
| 930 | + let hasIPv6, hasIPv4; | |
| 931 | + | |
| 929 | 932 | |
| 930 | - const [hasIPv6, hasIPv4] = await getHasIP(); | |
| 933 | + if (enableIPv6 === 'auto' || enableIPv4 === 'auto') { | |
| 934 | + [hasIPv6, hasIPv4] = await getHasIP(); | |
| 931 | 935 | if (enableIPv6 === 'auto') { |
| 932 | 936 | useIPv6 = hasIPv6; |
| 933 | 937 | } |
| @@ -942,9 +946,6 @@ async function startServer() { | ||
| 942 | 946 | |
| 943 | 947 | if (enableIPv4 === 'auto') { |
| 944 | 948 | useIPv4 = hasIPv4; |
| 945 | - if (useIPv4) { | |
| 946 | - console.log(color.green('IPv4 support detected')); | |
| 947 | - } | |
| 948 | 949 | } |
| 949 | 950 | if (hasIPv4) { |
| 950 | 951 | if (useIPv4) { |
| @@ -953,6 +954,7 @@ async function startServer() { | ||
| 953 | 954 | console.log('IPv4 support detected'); |
| 954 | 955 | } |
| 955 | 956 | } |
| 957 | + } | |
| 956 | 958 | |
| 957 | 959 | |
| 958 | 960 | if (enableIPv6 === 'auto' && enableIPv4 === 'auto') { |