This commit is contained in:
BPplays 2024-12-30 03:01:04 -08:00
parent f67abf9e03
commit f27b3361e5
2 changed files with 7 additions and 7 deletions

View File

@ -289,11 +289,11 @@ if (dnsPreferIPv6) {
const ipOptions = [true, 'auto', false]; const ipOptions = [true, 'auto', false];
if (!ipOptions.includes(enableIPv6)) { if (!ipOptions.includes(enableIPv6)) {
console.warn(color.red('`protocol: ipv6` option invalid'), "\n use:", ipOptions, "\n setting to: auto"); console.warn(color.red('`protocol: ipv6` option invalid'), '\n use:', ipOptions, '\n setting to: auto');
enableIPv6 = 'auto'; enableIPv6 = 'auto';
} }
if (!ipOptions.includes(enableIPv4)) { if (!ipOptions.includes(enableIPv4)) {
console.warn(color.red('`protocol: ipv4` option invalid'), "\n use:", ipOptions, "\n setting to: auto"); console.warn(color.red('`protocol: ipv4` option invalid'), '\n use:', ipOptions, '\n setting to: auto');
enableIPv4 = 'auto'; enableIPv4 = 'auto';
} }
@ -887,7 +887,7 @@ function createHttpsServer(url, ipVersion) {
server.on('error', reject); server.on('error', reject);
server.on('listening', resolve); server.on('listening', resolve);
let host = url.hostname let host = url.hostname;
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname); if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
server.listen({ server.listen({
host: host, host: host,
@ -910,7 +910,7 @@ function createHttpServer(url, ipVersion) {
server.on('error', reject); server.on('error', reject);
server.on('listening', resolve); server.on('listening', resolve);
let host = url.hostname let host = url.hostname;
if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname); if (ipVersion === 6) host = urlHostnameToIPv6(url.hostname);
server.listen({ server.listen({
host: host, host: host,

View File

@ -693,13 +693,13 @@ export function isValidUrl(url) {
} }
export function urlHostnameToIPv6(hostname) { export function urlHostnameToIPv6(hostname) {
if (hostname.startsWith("[")) { if (hostname.startsWith('[')) {
hostname = hostname.slice(1); hostname = hostname.slice(1);
} }
if (hostname.endsWith("]")) { if (hostname.endsWith(']')) {
hostname = hostname.slice(0, -1); hostname = hostname.slice(0, -1);
} }
return hostname return hostname;
} }
export function stringToBool(str) { export function stringToBool(str) {