formatting changes
| @@ -735,6 +735,8 @@ const preSetupTasks = async function () { | |||
| 735 | 735 | ||
| 736 | /** | 736 | /** |
| 737 | * Gets the hostname to use for autorun in the browser. | 737 | * Gets the hostname to use for autorun in the browser. |
| 738 | * @param {boolean} useIPv6 If use IPv6 | ||
| 739 | * @param {boolean} useIPv4 If use IPv4 | ||
| 738 | * @returns Promise<string> The hostname to use for autorun | 740 | * @returns Promise<string> The hostname to use for autorun |
| 739 | */ | 741 | */ |
| 740 | async function getAutorunHostname(useIPv6, useIPv4) { | 742 | async function getAutorunHostname(useIPv6, useIPv4) { |
| @@ -861,6 +863,8 @@ function logSecurityAlert(message) { | |||
| 861 | * Handles the case where the server failed to start on one or both protocols. | 863 | * Handles the case where the server failed to start on one or both protocols. |
| 862 | * @param {boolean} v6Failed If the server failed to start on IPv6 | 864 | * @param {boolean} v6Failed If the server failed to start on IPv6 |
| 863 | * @param {boolean} v4Failed If the server failed to start on IPv4 | 865 | * @param {boolean} v4Failed If the server failed to start on IPv4 |
| 866 | * @param {boolean} useIPv6 If use IPv6 | ||
| 867 | * @param {boolean} useIPv4 If use IPv4 | ||
| 864 | */ | 868 | */ |
| 865 | function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) { | 869 | function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) { |
| 866 | if (v6Failed && !useIPv4) { | 870 | if (v6Failed && !useIPv4) { |
| @@ -882,6 +886,7 @@ function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) { | |||
| 882 | /** | 886 | /** |
| 883 | * Creates an HTTPS server. | 887 | * Creates an HTTPS server. |
| 884 | * @param {URL} url The URL to listen on | 888 | * @param {URL} url The URL to listen on |
| 889 | * @param {number} ipVersion the ip version to use | ||
| 885 | * @returns {Promise<void>} A promise that resolves when the server is listening | 890 | * @returns {Promise<void>} A promise that resolves when the server is listening |
| 886 | * @throws {Error} If the server fails to start | 891 | * @throws {Error} If the server fails to start |
| 887 | */ | 892 | */ |
| @@ -909,6 +914,7 @@ function createHttpsServer(url, ipVersion) { | |||
| 909 | /** | 914 | /** |
| 910 | * Creates an HTTP server. | 915 | * Creates an HTTP server. |
| 911 | * @param {URL} url The URL to listen on | 916 | * @param {URL} url The URL to listen on |
| 917 | * @param {number} ipVersion the ip version to use | ||
| 912 | * @returns {Promise<void>} A promise that resolves when the server is listening | 918 | * @returns {Promise<void>} A promise that resolves when the server is listening |
| 913 | * @throws {Error} If the server fails to start | 919 | * @throws {Error} If the server fails to start |
| 914 | */ | 920 | */ |
| @@ -929,6 +935,12 @@ function createHttpServer(url, ipVersion) { | |||
| 929 | }); | 935 | }); |
| 930 | } | 936 | } |
| 931 | 937 | ||
| 938 | |||
| 939 | /** | ||
| 940 | * Starts the server using http or https depending on config | ||
| 941 | * @param {boolean} useIPv6 If use IPv6 | ||
| 942 | * @param {boolean} useIPv4 If use IPv4 | ||
| 943 | */ | ||
| 932 | async function startHTTPorHTTPS(useIPv6, useIPv4) { | 944 | async function startHTTPorHTTPS(useIPv6, useIPv4) { |
| 933 | let v6Failed = false; | 945 | let v6Failed = false; |
| 934 | let v4Failed = false; | 946 | let v4Failed = false; |
| @@ -696,6 +696,7 @@ export function isValidUrl(url) { | |||
| 696 | /** | 696 | /** |
| 697 | * removes starting `[` or ending `]` from hostname. | 697 | * removes starting `[` or ending `]` from hostname. |
| 698 | * @param {string} hostname hostname to use | 698 | * @param {string} hostname hostname to use |
| 699 | * @returns {string} hostname plus the modifications | ||
| 699 | */ | 700 | */ |
| 700 | export function urlHostnameToIPv6(hostname) { | 701 | export function urlHostnameToIPv6(hostname) { |
| 701 | if (hostname.startsWith('[')) { | 702 | if (hostname.startsWith('[')) { |
| @@ -712,6 +713,7 @@ export function urlHostnameToIPv6(hostname) { | |||
| 712 | * @param {string} name Domain name to use | 713 | * @param {string} name Domain name to use |
| 713 | * @param {boolean} useIPv6 If use IPv6 | 714 | * @param {boolean} useIPv6 If use IPv6 |
| 714 | * @param {boolean} useIPv4 If use IPv4 | 715 | * @param {boolean} useIPv4 If use IPv4 |
| 716 | * @returns Promise<boolean> If the URL is valid | ||
| 715 | */ | 717 | */ |
| 716 | export async function canResolve(name, useIPv6 = true, useIPv4 = true) { | 718 | export async function canResolve(name, useIPv6 = true, useIPv4 = true) { |
| 717 | try { | 719 | try { |
| @@ -747,6 +749,7 @@ export async function canResolve(name, useIPv6 = true, useIPv4 = true) { | |||
| 747 | /** | 749 | /** |
| 748 | * converts string to boolean accepts 'true' or 'false' else it returns the string put in | 750 | * converts string to boolean accepts 'true' or 'false' else it returns the string put in |
| 749 | * @param {string} str Input string | 751 | * @param {string} str Input string |
| 752 | * @returns {boolean|string} boolean else original input string | ||
| 750 | */ | 753 | */ |
| 751 | export function stringToBool(str) { | 754 | export function stringToBool(str) { |
| 752 | if (str === 'true') return true; | 755 | if (str === 'true') return true; |