mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
formatting changes
This commit is contained in:
12
server.js
12
server.js
@@ -735,6 +735,8 @@ const preSetupTasks = async function () {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the hostname to use for autorun in the browser.
|
* Gets the hostname to use for autorun in the browser.
|
||||||
|
* @param {boolean} useIPv6 If use IPv6
|
||||||
|
* @param {boolean} useIPv4 If use IPv4
|
||||||
* @returns Promise<string> The hostname to use for autorun
|
* @returns Promise<string> The hostname to use for autorun
|
||||||
*/
|
*/
|
||||||
async function getAutorunHostname(useIPv6, useIPv4) {
|
async function getAutorunHostname(useIPv6, useIPv4) {
|
||||||
@@ -861,6 +863,8 @@ function logSecurityAlert(message) {
|
|||||||
* Handles the case where the server failed to start on one or both protocols.
|
* Handles the case where the server failed to start on one or both protocols.
|
||||||
* @param {boolean} v6Failed If the server failed to start on IPv6
|
* @param {boolean} v6Failed If the server failed to start on IPv6
|
||||||
* @param {boolean} v4Failed If the server failed to start on IPv4
|
* @param {boolean} v4Failed If the server failed to start on IPv4
|
||||||
|
* @param {boolean} useIPv6 If use IPv6
|
||||||
|
* @param {boolean} useIPv4 If use IPv4
|
||||||
*/
|
*/
|
||||||
function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
|
function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
|
||||||
if (v6Failed && !useIPv4) {
|
if (v6Failed && !useIPv4) {
|
||||||
@@ -882,6 +886,7 @@ function handleServerListenFail(v6Failed, v4Failed, useIPv6, useIPv4) {
|
|||||||
/**
|
/**
|
||||||
* Creates an HTTPS server.
|
* Creates an HTTPS server.
|
||||||
* @param {URL} url The URL to listen on
|
* @param {URL} url The URL to listen on
|
||||||
|
* @param {number} ipVersion the ip version to use
|
||||||
* @returns {Promise<void>} A promise that resolves when the server is listening
|
* @returns {Promise<void>} A promise that resolves when the server is listening
|
||||||
* @throws {Error} If the server fails to start
|
* @throws {Error} If the server fails to start
|
||||||
*/
|
*/
|
||||||
@@ -909,6 +914,7 @@ function createHttpsServer(url, ipVersion) {
|
|||||||
/**
|
/**
|
||||||
* Creates an HTTP server.
|
* Creates an HTTP server.
|
||||||
* @param {URL} url The URL to listen on
|
* @param {URL} url The URL to listen on
|
||||||
|
* @param {number} ipVersion the ip version to use
|
||||||
* @returns {Promise<void>} A promise that resolves when the server is listening
|
* @returns {Promise<void>} A promise that resolves when the server is listening
|
||||||
* @throws {Error} If the server fails to start
|
* @throws {Error} If the server fails to start
|
||||||
*/
|
*/
|
||||||
@@ -929,6 +935,12 @@ function createHttpServer(url, ipVersion) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the server using http or https depending on config
|
||||||
|
* @param {boolean} useIPv6 If use IPv6
|
||||||
|
* @param {boolean} useIPv4 If use IPv4
|
||||||
|
*/
|
||||||
async function startHTTPorHTTPS(useIPv6, useIPv4) {
|
async function startHTTPorHTTPS(useIPv6, useIPv4) {
|
||||||
let v6Failed = false;
|
let v6Failed = false;
|
||||||
let v4Failed = false;
|
let v4Failed = false;
|
||||||
|
@@ -696,6 +696,7 @@ export function isValidUrl(url) {
|
|||||||
/**
|
/**
|
||||||
* removes starting `[` or ending `]` from hostname.
|
* removes starting `[` or ending `]` from hostname.
|
||||||
* @param {string} hostname hostname to use
|
* @param {string} hostname hostname to use
|
||||||
|
* @returns {string} hostname plus the modifications
|
||||||
*/
|
*/
|
||||||
export function urlHostnameToIPv6(hostname) {
|
export function urlHostnameToIPv6(hostname) {
|
||||||
if (hostname.startsWith('[')) {
|
if (hostname.startsWith('[')) {
|
||||||
@@ -712,6 +713,7 @@ export function urlHostnameToIPv6(hostname) {
|
|||||||
* @param {string} name Domain name to use
|
* @param {string} name Domain name to use
|
||||||
* @param {boolean} useIPv6 If use IPv6
|
* @param {boolean} useIPv6 If use IPv6
|
||||||
* @param {boolean} useIPv4 If use IPv4
|
* @param {boolean} useIPv4 If use IPv4
|
||||||
|
* @returns Promise<boolean> If the URL is valid
|
||||||
*/
|
*/
|
||||||
export async function canResolve(name, useIPv6 = true, useIPv4 = true) {
|
export async function canResolve(name, useIPv6 = true, useIPv4 = true) {
|
||||||
try {
|
try {
|
||||||
@@ -747,6 +749,7 @@ export async function canResolve(name, useIPv6 = true, useIPv4 = true) {
|
|||||||
/**
|
/**
|
||||||
* converts string to boolean accepts 'true' or 'false' else it returns the string put in
|
* converts string to boolean accepts 'true' or 'false' else it returns the string put in
|
||||||
* @param {string} str Input string
|
* @param {string} str Input string
|
||||||
|
* @returns {boolean|string} boolean else original input string
|
||||||
*/
|
*/
|
||||||
export function stringToBool(str) {
|
export function stringToBool(str) {
|
||||||
if (str === 'true') return true;
|
if (str === 'true') return true;
|
||||||
|
Reference in New Issue
Block a user