diff --git a/.github/readme-de_de.md b/.github/readme-de_de.md index 3dcc29dcb..f286ce709 100644 --- a/.github/readme-de_de.md +++ b/.github/readme-de_de.md @@ -320,29 +320,29 @@ Start.bat --port 8000 --listen false ### Unterstützte Argumente -| Option | Beschreibung | Typ | -|-------------------------|----------------------------------------------------------------------------------------------------|----------| -| `--version` | Versionsnummer anzeigen | boolean | -| `--enableIPv6` | Aktiviert IPv6. | boolean | -| `--enableIPv4` | Aktiviert IPv4. | boolean | -| `--port` | Legt den Port fest, unter dem SillyTavern ausgeführt wird. Wenn nicht angegeben, wird auf YAML-Konfiguration „Port“ zurückgegriffen. | number | -| „--dnsPreferIPv6“ | Bevorzugt IPv6 für DNS. Wenn nicht angegeben, wird auf YAML-Konfiguration „preferIPv6“ zurückgegriffen. | boolean | -| „--autorun“ | Startet SillyTavern automatisch im Browser. Wenn nicht angegeben, wird auf YAML-Konfiguration „autorun“ zurückgegriffen.| boolean | -| „--autorunHostname“ | Der Autorun-Hostname, am besten auf „auto“ belassen. | string | -| „--autorunPortOverride“ | Überschreibt den Port für Autorun. | string | -| „--listen“ | SillyTavern lauscht auf allen Netzwerkschnittstellen. Wenn nicht angegeben, wird auf YAML-Konfiguration „listen“ zurückgegriffen.| boolean | -| „--corsProxy“ | Aktiviert CORS-Proxy. Wenn nicht angegeben, wird auf YAML-Konfiguration „enableCorsProxy“ zurückgegriffen. | boolean | -| `--disableCsrf` | Deaktiviert CSRF-Schutz | boolean | -| `--ssl` | Aktiviert SSL | boolean | -| `--certPath` | Pfad zu Ihrer Zertifikatsdatei. | string | -| `--keyPath` | Pfad zu Ihrer privaten Schlüsseldatei. | string | -| `--whitelist` | Aktiviert den Whitelist-Modus | boolean | -| `--dataRoot` | Stammverzeichnis für Datenspeicherung | string | -| `--avoidLocalhost` | Vermeidet die Verwendung von „localhost“ für Autorun im Auto-Modus. | boolean | -| `--basicAuthMode` | Aktiviert die grundlegende Authentifizierung | boolean | -| `--requestProxyEnabled` | Aktiviert die Verwendung eines Proxys für ausgehende Anfragen | boolean | -| `--requestProxyUrl` | Proxy-URL anfordern (HTTP- oder SOCKS-Protokolle) | string | -| `--requestProxyBypass` | Proxy-Bypass-Liste anfordern (durch Leerzeichen getrennte Liste von Hosts) | Array | +| Option | Beschreibung | Typ | +|----------------------------------|--------------------------------------------------------------------------------------------------|----------| +| `--version` | Versionsnummer anzeigen | boolean | +| `--enableIPv6` | Aktiviert IPv6. | boolean | +| `--enableIPv4` | Aktiviert IPv4. | boolean | +| `--port` | Legt den Port fest, unter dem SillyTavern ausgeführt wird. | number | +| `--dnsPreferIPv6` | Bevorzugt IPv6 für DNS. Wenn nicht angegeben. | boolean | +| `--browserLaunchEnabled` | Startet SillyTavern automatisch im Browser. | boolean | +| `--browserLaunchHostname` | Der Autorun-Hostname, am besten auf „auto" belassen. | string | +| `--browserLaunchPort` | Überschreibt den Port für Autorun. | string | +| `--browserLaunchAvoidLocalhost` | Vermeidet die Verwendung von „localhost" für Autorun im Auto-Modus. | boolean | +| `--listen` | SillyTavern lauscht auf allen Netzwerkschnittstellen. | boolean | +| `--corsProxy` | Aktiviert CORS-Proxy. Wenn nicht angegeben. | boolean | +| `--disableCsrf` | Deaktiviert CSRF-Schutz | boolean | +| `--ssl` | Aktiviert SSL | boolean | +| `--certPath` | Pfad zu Ihrer Zertifikatsdatei. | string | +| `--keyPath` | Pfad zu Ihrer privaten Schlüsseldatei. | string | +| `--whitelist` | Aktiviert den Whitelist-Modus | boolean | +| `--dataRoot` | Stammverzeichnis für Datenspeicherung | string | +| `--basicAuthMode` | Aktiviert die grundlegende Authentifizierung | boolean | +| `--requestProxyEnabled` | Aktiviert die Verwendung eines Proxys für ausgehende Anfragen | boolean | +| `--requestProxyUrl` | Proxy-URL anfordern (HTTP- oder SOCKS-Protokolle) | string | +| `--requestProxyBypass` | Proxy-Bypass-Liste anfordern (durch Leerzeichen getrennte Liste von Hosts) | Array | ## Remoteverbindungen diff --git a/.github/readme-ko_kr.md b/.github/readme-ko_kr.md index 80a3a4335..f50c279a1 100644 --- a/.github/readme-ko_kr.md +++ b/.github/readme-ko_kr.md @@ -334,29 +334,29 @@ Start.bat --port 8000 --listen false ### 지원되는 인수 -| 옵션 | 설명 | 타입 | -|-------------------------|------------------------------------------------------------------------------------------------------|----------| -| `--version` | 버전 표시 | boolean | -| `--enableIPv6` | IPv6 활성화 | boolean | -| `--enableIPv4` | IPv4 활성화 | boolean | -| `--port` | SillyTavern이 실행될 포트를 설정합니다. 설정되지 않은 경우 yaml config 'port'를 불러옵니다. | number | -| `--dnsPreferIPv6` | DNS에 IPv6를 우선으로 할당합니다. 설정되지 않은 경우 yaml config를 불러옵니다. | boolean | -| `--autorun` | 브라우저에서 SillyTavern을 자동으로 실행합니다. 설정되지 않은 경우 yaml config 'autorun'를 불러옵니다. | boolean | -| `--autorunHostname` | 자동 실행 호스트 이름, 'auto'가 최적의 설정일 것입니다. | string | -| `--autorunPortOverride` | 자동 실행 포트 덮어쓰기 | string | -| `--listen` | SillyTavern이 모든 네트워크 인터페이스에서 수신 대기합니다. 설정되지 않은 경우 yaml 구성 'listen'을 불러옵니다. | boolean | -| `--corsProxy` | CORS 프록시 활성화. 설정되지 않은 경우 yaml 구성 'enableCorsProxy'을 불러옵니다. | boolean | -| `--disableCsrf` | CSRF 보호 비활성화 | boolean | -| `--ssl` | SSL 활성화 | boolean | -| `--certPath` | 인증서 파일 경로 | string | -| `--keyPath` | 프라이빗 키 파일 경로 | string | -| `--whitelist` | 화이트리스트 모드 활성화 | boolean | -| `--dataRoot` | 데이터 스토리지의 루트 디렉토리 | string | -| `--avoidLocalhost` | 자동 모드에서 자동 실행 시 'localhost' 사용 방지 | boolean | -| `--basicAuthMode` | 기본 인증 활성화 | boolean | -| `--requestProxyEnabled` | 외부 리퀘스트 프록시 활성화 | boolean | -| `--requestProxyUrl` | 프록시 URL 리퀘스트 (HTTP 혹은 SOCKS 프로토콜) | string | -| `--requestProxyBypass` | 프록시 바이패스 리스트 리퀘스트 (공백으로 구분된 호스트 목록) | array | +| 옵션 | 설명 | 타입 | +|-----------------------------------|--------------------------------------------------------------------------------------|----------| +| `--version` | 버전 표시 | boolean | +| `--enableIPv6` | IPv6 활성화 | boolean | +| `--enableIPv4` | IPv4 활성화 | boolean | +| `--port` | SillyTavern이 실행될 포트를 설정합니다. | number | +| `--dnsPreferIPv6` | DNS에 IPv6를 우선으로 할당합니다. | boolean | +| `--browserLaunchEnabled` | 브라우저에서 SillyTavern을 자동으로 실행합니다. | boolean | +| `--browserLaunchHostname` | 자동 실행 호스트 이름, 'auto'가 최적의 설정일 것입니다. | string | +| `--browserLaunchPort` | 자동 실행 포트 덮어쓰기 | string | +| `--browserLaunchAvoidLocalhost` | 자동 모드에서 자동 실행 시 'localhost' 사용 방지 | boolean | +| `--listen` | SillyTavern이 모든 네트워크 인터페이스에서 수신 대기합니다. | boolean | +| `--corsProxy` | CORS 프록시 활성화. | boolean | +| `--disableCsrf` | CSRF 보호 비활성화 | boolean | +| `--ssl` | SSL 활성화 | boolean | +| `--certPath` | 인증서 파일 경로 | string | +| `--keyPath` | 프라이빗 키 파일 경로 | string | +| `--whitelist` | 화이트리스트 모드 활성화 | boolean | +| `--dataRoot` | 데이터 스토리지의 루트 디렉토리 | string | +| `--basicAuthMode` | 기본 인증 활성화 | boolean | +| `--requestProxyEnabled` | 외부 리퀘스트 프록시 활성화 | boolean | +| `--requestProxyUrl` | 프록시 URL 리퀘스트 (HTTP 혹은 SOCKS 프로토콜) | string | +| `--requestProxyBypass` | 프록시 바이패스 리스트 리퀘스트 (공백으로 구분된 호스트 목록) | array | ## 원격 연결 diff --git a/.github/readme-ru_ru.md b/.github/readme-ru_ru.md index 5a7ce8932..1a0929db9 100644 --- a/.github/readme-ru_ru.md +++ b/.github/readme-ru_ru.md @@ -283,29 +283,29 @@ Start.bat --port 8000 --listen false ### Поддерживаемые аргументы -| Аргумент | Описание | Тип | -|-------------------------|----------------------------------------------------------------------------------------------------------------|----------| -| `--version` | Показывает номер версии. | boolean | -| `--enableIPv6` | Включает IPv6. | boolean | -| `--enableIPv4` | Включает IPv4. | boolean | -| `--port` | Устанавливает порт, котрый будет использовать SillyTavern. Если не указан, то используется yaml-конфиг 'port'. | number | -| `--dnsPreferIPv6` | Отдает предпочтение IPv6 для dns. Если не указан, то используется yaml-конфиг 'preferIPv6'. | boolean | -| `--autorun` | Автоматический запуск SillyTavern в браузере. Если не указан, то используется yaml-конфиг 'autorun'. | boolean | -| `--autorunHostname` | Имя хоста автозапуска, лучше оставить на 'auto'. | string | -| `--autorunPortOverride` | Переопределяет порт для автозапуска. | string | -| `--listen` | SillyTavern будет прослушивать все сетевые интерфейсы. Если не указан, то используется yaml-конфиг 'listen'. | boolean | -| `--corsProxy` | Включает CORS-прокси. Если не указан, то используется yaml-конфиг 'enableCorsProxy'. | boolean | -| `--disableCsrf` | Отключает защиту от CSRF. | boolean | -| `--ssl` | Включает SSL. | boolean | -| `--certPath` | Путь к файлу c сертификатом. | string | -| `--keyPath` | Путь к файлу с закрытым ключом. | string | -| `--whitelist` | Включает режим белого списка. | boolean | -| `--dataRoot` | Корневой каталог для хранения данных. | string | -| `--avoidLocalhost` | Избегает использования 'localhost' для автозапуска в режиме 'auto'. | boolean | -| `--basicAuthMode` | Включает простую аутентификацию. | boolean | -| `--requestProxyEnabled` | Разрешает использование прокси для исходящих запросов. | boolean | -| `--requestProxyUrl` | URL-адрес прокси (протоколы HTTP или SOCKS). | string | -| `--requestProxyBypass` | Bypass список прокси (список хостов, разделенных пробелами). | array | +| Аргумент | Описание | Тип | +|------------------------------|-----------------------------------------------------------------------------------------------------------|---------| +| `--version` | Показывает номер версии. | boolean | +| `--enableIPv6` | Включает IPv6. | boolean | +| `--enableIPv4` | Включает IPv4. | boolean | +| `--port` | Устанавливает порт, который будет использовать SillyTavern. | number | +| `--dnsPreferIPv6` | Отдает предпочтение IPv6 для dns. | boolean | +| `--browserLaunchEnabled` | Автоматический запуск SillyTavern в браузере. | boolean | +| `--browserLaunchHostname` | Имя хоста автозапуска, лучше оставить на 'auto'. | string | +| `--browserLaunchPort` | Переопределяет порт для автозапуска. | string | +| `--browserLaunchAvoidLocalhost`| Избегает использования 'localhost' для автозапуска в режиме 'auto'. | boolean | +| `--listen` | SillyTavern будет прослушивать все сетевые интерфейсы. | boolean | +| `--corsProxy` | Включает CORS-прокси. | boolean | +| `--disableCsrf` | Отключает защиту от CSRF. | boolean | +| `--ssl` | Включает SSL. | boolean | +| `--certPath` | Путь к файлу c сертификатом. | string | +| `--keyPath` | Путь к файлу с закрытым ключом. | string | +| `--whitelist` | Включает режим белого списка. | boolean | +| `--dataRoot` | Корневой каталог для хранения данных. | string | +| `--basicAuthMode` | Включает простую аутентификацию. | boolean | +| `--requestProxyEnabled` | Разрешает использование прокси для исходящих запросов. | boolean | +| `--requestProxyUrl` | URL-адрес прокси (протоколы HTTP или SOCKS). | string | +| `--requestProxyBypass` | Bypass список прокси (список хостов, разделенных пробелами). | array | ## Удалённое подключение diff --git a/.github/readme-zh_cn.md b/.github/readme-zh_cn.md index 53d5275ed..db749ccfb 100644 --- a/.github/readme-zh_cn.md +++ b/.github/readme-zh_cn.md @@ -336,32 +336,32 @@ Start.bat --port 8000 --listen false > \[!TIP] > 所有参数都不是必需的。如果您不提供它们,SillyTavern 将使用 `config.yaml` 中的设置。 -| 选项 | 描述 | 类型 | -| ----------------------- | --------------------------------------------- | ------- | -| `--version` | 显示版本号 | boolean | -| `--configPath` | 覆盖 config.yaml 文件的路径 | string | -| `--dataRoot` | 数据存储的根目录 | string | -| `--port` | 设置 SillyTavern 将在其下运行的端口 | number | -| `--listen` | SillyTavern 将侦听所有网络接口 | boolean | -| `--whitelist` | 启用白名单模式 | boolean | -| `--basicAuthMode` | 启用基本身份验证 | boolean | -| `--enableIPv4` | 启用 IPv4 协议 | boolean | -| `--enableIPv6` | 启用 IPv6 协议 | boolean | -| `--listenAddressIPv4` | 要侦听的特定 IPv4 地址 | string | -| `--listenAddressIPv6` | 要侦听的特定 IPv6 地址 | string | -| `--dnsPreferIPv6` | DNS 首选 IPv6 | boolean | -| `--ssl` | 启用 SSL | boolean | -| `--certPath` | 您的证书文件路径 | string | -| `--keyPath` | 您的私钥文件路径 | string | -| `--autorun` | 自动在浏览器中启动 SillyTavern | boolean | -| `--autorunHostname` | 自动运行主机名 | string | -| `--autorunPortOverride` | 覆盖自动运行的端口 | string | -| `--avoidLocalhost` | 在自动模式下避免使用 'localhost' 进行自动运行 | boolean | -| `--corsProxy` | 启用 CORS 代理 | boolean | -| `--requestProxyEnabled` | 为传出请求启用代理 | boolean | -| `--requestProxyUrl` | 请求代理 URL(HTTP 或 SOCKS 协议) | string | -| `--requestProxyBypass` | 请求代理绕过列表(以空格分隔的主机列表) | array | -| `--disableCsrf` | 禁用 CSRF 保护(不推荐) | boolean | +| 选项 | 描述 | 类型 | +| -------------------------------- | ---------------------------------------------- | ------- | +| `--version` | 显示版本号 | boolean | +| `--configPath` | 覆盖 config.yaml 文件的路径 | string | +| `--dataRoot` | 数据存储的根目录 | string | +| `--port` | 设置 SillyTavern 将在其下运行的端口 | number | +| `--listen` | SillyTavern 将侦听所有网络接口 | boolean | +| `--whitelist` | 启用白名单模式 | boolean | +| `--basicAuthMode` | 启用基本身份验证 | boolean | +| `--enableIPv4` | 启用 IPv4 协议 | boolean | +| `--enableIPv6` | 启用 IPv6 协议 | boolean | +| `--listenAddressIPv4` | 要侦听的特定 IPv4 地址 | string | +| `--listenAddressIPv6` | 要侦听的特定 IPv6 地址 | string | +| `--dnsPreferIPv6` | DNS 首选 IPv6 | boolean | +| `--ssl` | 启用 SSL | boolean | +| `--certPath` | 您的证书文件路径 | string | +| `--keyPath` | 您的私钥文件路径 | string | +| `--browserLaunchEnabled` | 自动在浏览器中启动 SillyTavern | boolean | +| `--browserLaunchHostname` | 自动运行主机名 | string | +| `--browserLaunchPort` | 覆盖自动运行的端口 | string | +| `--browserLaunchAvoidLocalhost` | 在自动模式下避免使用 'localhost' 进行自动运行 | boolean | +| `--corsProxy` | 启用 CORS 代理 | boolean | +| `--requestProxyEnabled` | 为传出请求启用代理 | boolean | +| `--requestProxyUrl` | 请求代理 URL(HTTP 或 SOCKS 协议) | string | +| `--requestProxyBypass` | 请求代理绕过列表(以空格分隔的主机列表) | array | +| `--disableCsrf` | 禁用 CSRF 保护(不推荐) | boolean | ## 远程连接 diff --git a/.github/readme-zh_tw.md b/.github/readme-zh_tw.md index 1a4653d6e..7f88e44e6 100644 --- a/.github/readme-zh_tw.md +++ b/.github/readme-zh_tw.md @@ -319,29 +319,29 @@ Start.bat --port 8000 --listen false ### Supported arguments -| Option | Description | Type | -|-------------------------|------------------------------------------------------------------------------------------------------|----------| -| `--version` | 顯示版本序號 | boolean | -| `--enableIPv6` | 啟用 IPv6 | boolean | -| `--enableIPv4` | 啟用 IPv4 | boolean | -| `--port` | 設定 SillyTavern 運行的端口。若未提供,則預設使用 `config.yaml` 中的 'port' | number -| `--dnsPreferIPv6` | 偏好使用 IPv6 解析 DNS。未提供則默認使用 `config.yaml` 中的 'preferIPv6' | boolean | -| `--autorun` | 自動在瀏覽器中啟動 SillyTavern。未提供則默認使用 `config.yaml` 中的 'autorun' | boolean | -| `--autorunHostname` | 自動啟動時的主機名稱,通常建議保持為 'auto' | string | -| `--autorunPortOverride` | 覆蓋自動啟動的端口設定 | string | -| `--listen` | SillyTavern 是否可監聽所有網路接口。若未提供,則默認使用 `config.yaml` 中的 'listen' | boolean | -| `--corsProxy` | 啟用 CORS 代理。若未提供,則默認使用 `config.yaml` 中的 'enableCorsProxy' | boolean | -| `--disableCsrf` | 停用 CSRF 保護 | boolean | -| `--ssl` | 啟用 SSL | boolean | -| `--certPath` | 設定您證書文件的路徑 | string | -| `--keyPath` | 設定您私人金鑰文件的路徑 | string | -| `--whitelist` | 啟用白名單模式 | boolean | -| `--dataRoot` | 設定數據儲存的根目錄 | string | -| `--avoidLocalhost` | 在自動模式下避免使用 'localhost' | boolean | -| `--basicAuthMode` | 啟用基本身份驗證模式 | boolean | -| `--requestProxyEnabled` | 啟用代理以處理外部請求 | boolean | -| `--requestProxyUrl` | 設定請求代理的 URL(支持 HTTP 或 SOCKS 協議) | string | -| `--requestProxyBypass` | 請求代理的例外主機清單(主機列表需以空格分隔) | array | +| Option | Description | Type | +|----------------------------------|---------------------------------------------|---------| +| `--version` | 顯示版本序號 | boolean | +| `--enableIPv6` | 啟用 IPv6 | boolean | +| `--enableIPv4` | 啟用 IPv4 | boolean | +| `--port` | 設定 SillyTavern 運行的端口。 | number | +| `--dnsPreferIPv6` | 偏好使用 IPv6 解析 DNS。 | boolean | +| `--browserLaunchEnabled` | 自動在瀏覽器中啟動 SillyTavern。 | boolean | +| `--browserLaunchHostname` | 自動啟動時的主機名稱,通常建議保持為 'auto' | string | +| `--browserLaunchPort` | 覆蓋自動啟動的端口設定 | string | +| `--browserLaunchAvoidLocalhost` | 在自動模式下避免使用 'localhost' | boolean | +| `--listen` | SillyTavern 是否可監聽所有網路接口。 | boolean | +| `--corsProxy` | 啟用 CORS 代理。 | boolean | +| `--disableCsrf` | 停用 CSRF 保護 | boolean | +| `--ssl` | 啟用 SSL | boolean | +| `--certPath` | 設定您證書文件的路徑 | string | +| `--keyPath` | 設定您私人金鑰文件的路徑 | string | +| `--whitelist` | 啟用白名單模式 | boolean | +| `--dataRoot` | 設定數據儲存的根目錄 | string | +| `--basicAuthMode` | 啟用基本身份驗證模式 | boolean | +| `--requestProxyEnabled` | 啟用代理以處理外部請求 | boolean | +| `--requestProxyUrl` | 設定請求代理的 URL(支持 HTTP 或 SOCKS 協議)| string | +| `--requestProxyBypass` | 請求代理的例外主機清單(主機列表需以空格分隔)| array | ## 遠端連線 diff --git a/.github/readme.md b/.github/readme.md index e2ff2f365..c9ec85d83 100644 --- a/.github/readme.md +++ b/.github/readme.md @@ -333,32 +333,32 @@ Start.bat --port 8000 --listen false > \[!TIP] > None of the arguments are required. If you don't provide them, SillyTavern will use the settings in `config.yaml`. -| Option | Description | Type | -|-------------------------|----------------------------------------------------------------------|----------| -| `--version` | Show version number | boolean | -| `--configPath` | Override the path to the config.yaml file | string | -| `--dataRoot` | Root directory for data storage | string | -| `--port` | Sets the port under which SillyTavern will run | number | -| `--listen` | SillyTavern will listen on all network interfaces | boolean | -| `--whitelist` | Enables whitelist mode | boolean | -| `--basicAuthMode` | Enables basic authentication | boolean | -| `--enableIPv4` | Enables IPv4 protocol | boolean | -| `--enableIPv6` | Enables IPv6 protocol | boolean | -| `--listenAddressIPv4` | Specific IPv4 address to listen to | string | -| `--listenAddressIPv6` | Specific IPv6 address to listen to | string | -| `--dnsPreferIPv6` | Prefers IPv6 for DNS | boolean | -| `--ssl` | Enables SSL | boolean | -| `--certPath` | Path to your certificate file | string | -| `--keyPath` | Path to your private key file | string | -| `--autorun` | Automatically launch SillyTavern in the browser | boolean | -| `--autorunHostname` | Autorun hostname | string | -| `--autorunPortOverride` | Overrides the port for autorun | string | -| `--avoidLocalhost` | Avoids using 'localhost' for autorun in auto mode | boolean | -| `--corsProxy` | Enables CORS proxy | boolean | -| `--requestProxyEnabled` | Enables a use of proxy for outgoing requests | boolean | -| `--requestProxyUrl` | Request proxy URL (HTTP or SOCKS protocols) | string | -| `--requestProxyBypass` | Request proxy bypass list (space separated list of hosts) | array | -| `--disableCsrf` | Disables CSRF protection (NOT RECOMMENDED) | boolean | +| Option | Description | Type | +|---------------------------------|----------------------------------------------------------------------|----------| +| `--version` | Show version number | boolean | +| `--configPath` | Override the path to the config.yaml file | string | +| `--dataRoot` | Root directory for data storage | string | +| `--port` | Sets the port under which SillyTavern will run | number | +| `--listen` | SillyTavern will listen on all network interfaces | boolean | +| `--whitelist` | Enables whitelist mode | boolean | +| `--basicAuthMode` | Enables basic authentication | boolean | +| `--enableIPv4` | Enables IPv4 protocol | boolean | +| `--enableIPv6` | Enables IPv6 protocol | boolean | +| `--listenAddressIPv4` | Specific IPv4 address to listen to | string | +| `--listenAddressIPv6` | Specific IPv6 address to listen to | string | +| `--dnsPreferIPv6` | Prefers IPv6 for DNS | boolean | +| `--ssl` | Enables SSL | boolean | +| `--certPath` | Path to your certificate file | string | +| `--keyPath` | Path to your private key file | string | +| `--browserLaunchEnabled` | Automatically launch SillyTavern in the browser | boolean | +| `--browserLaunchHostname` | Browser launch hostname | string | +| `--browserLaunchPort` | Overrides the port for browser launch | string | +| `--browserLaunchAvoidLocalhost` | Avoids using 'localhost' for browser launch in auto mode | boolean | +| `--corsProxy` | Enables CORS proxy | boolean | +| `--requestProxyEnabled` | Enables a use of proxy for outgoing requests | boolean | +| `--requestProxyUrl` | Request proxy URL (HTTP or SOCKS protocols) | string | +| `--requestProxyBypass` | Request proxy bypass list (space separated list of hosts) | array | +| `--disableCsrf` | Disables CSRF protection (NOT RECOMMENDED) | boolean | ## Remote connections diff --git a/default/config.yaml b/default/config.yaml index afc0ada2d..975d53087 100644 --- a/default/config.yaml +++ b/default/config.yaml @@ -16,16 +16,27 @@ protocol: ipv6: false # Prefers IPv6 for DNS. Enable this on ISPs that don't have issues with IPv6 dnsPreferIPv6: false -# The hostname that autorun opens. -# - Use "auto" to let the server decide -# - Use options like 'localhost', 'st.example.com' -autorunHostname: "auto" +# -- BROWSER LAUNCH CONFIGURATION -- +browserLaunch: + # Open the browser automatically on server startup. + enabled: true + # Browser to use for opening the URL. + # - Use "default" to use the system default browser + # - Use "firefox", "chrome", "edge" + browser: 'default' + # Overrides the hostname that opens in the browser. + # - Use "auto" to let the server decide + # - Use options like 'localhost', 'st.example.com' + hostname: 'auto' + # Overrides the port for run in the browser. + # - Use -1 to use the server port. + # - Specify a port to override the default. + port: -1 + # Avoids using 'localhost' as the hostname in auto mode. + # Use if you don't have 'localhost' in your hosts file + avoidLocalhost: false # Server port port: 8000 -# Overrides the port for autorun in browser. -# - Use -1 to use the server port. -# - Specify a port to override the default. -autorunPortOverride: -1 # -- SSL options -- ssl: enabled: false @@ -98,12 +109,6 @@ rateLimiting: # Use X-Real-IP header instead of socket IP for rate limiting # Only enable this if you are using a properly configured reverse proxy (like Nginx/traefik/Caddy) preferRealIpHeader: false -# -- ADVANCED CONFIGURATION -- -# Open the browser automatically -autorun: true -# Avoids using 'localhost' for autorun in auto mode. -# use if you don't have 'localhost' in your hosts file -avoidLocalhost: false ## BACKUP CONFIGURATION backups: diff --git a/package-lock.json b/package-lock.json index 676853195..78d67952a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,7 +77,7 @@ "multer": "^2.0.1", "node-fetch": "^3.3.2", "node-persist": "^4.0.4", - "open": "^8.4.2", + "open": "^10.1.2", "png-chunk-text": "^1.0.0", "png-chunks-extract": "^1.0.0", "proxy-agent": "^6.5.0", @@ -2991,6 +2991,21 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "license": "MIT" }, + "node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -3764,6 +3779,34 @@ "dev": true, "license": "MIT" }, + "node_modules/default-browser": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", + "integrity": "sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==", + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.0.tgz", + "integrity": "sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defer-to-connect": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-2.0.1.tgz", @@ -3791,12 +3834,15 @@ } }, "node_modules/define-lazy-prop": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", - "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", "license": "MIT", "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/degenerator": { @@ -5545,6 +5591,24 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-path-inside": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", @@ -5567,27 +5631,15 @@ } }, "node_modules/is-wsl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", - "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", + "integrity": "sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==", "license": "MIT", "dependencies": { - "is-docker": "^2.0.0" + "is-inside-container": "^1.0.0" }, "engines": { - "node": ">=8" - } - }, - "node_modules/is-wsl/node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" + "node": ">=16" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -6367,32 +6419,18 @@ } }, "node_modules/open": { - "version": "8.4.2", - "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", - "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/open/-/open-10.1.2.tgz", + "integrity": "sha512-cxN6aIDPz6rm8hbebcP7vrQNhvRcveZoJU72Y7vskh4oIm+BZwBECnx5nTmrlres1Qapvx27Qo1Auukpf8PKXw==", "license": "MIT", "dependencies": { - "define-lazy-prop": "^2.0.0", - "is-docker": "^2.1.1", - "is-wsl": "^2.2.0" + "default-browser": "^5.2.1", + "define-lazy-prop": "^3.0.0", + "is-inside-container": "^1.0.0", + "is-wsl": "^3.1.0" }, "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/open/node_modules/is-docker": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", - "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", - "license": "MIT", - "bin": { - "is-docker": "cli.js" - }, - "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -7219,6 +7257,18 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/run-applescript": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.0.0.tgz", + "integrity": "sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index 305786dde..8db1d1fef 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "multer": "^2.0.1", "node-fetch": "^3.3.2", "node-persist": "^4.0.4", - "open": "^8.4.2", + "open": "^10.1.2", "png-chunk-text": "^1.0.0", "png-chunks-extract": "^1.0.0", "proxy-agent": "^6.5.0", diff --git a/src/command-line.js b/src/command-line.js index cb1dd1015..9e6e9a4b1 100644 --- a/src/command-line.js +++ b/src/command-line.js @@ -15,24 +15,24 @@ import { initConfig } from './config-init.js'; * @property {boolean|string} enableIPv4 If enable IPv4 protocol ("auto" is also allowed) * @property {boolean|string} enableIPv6 If enable IPv6 protocol ("auto" is also allowed) * @property {boolean} dnsPreferIPv6 If prefer IPv6 for DNS - * @property {boolean} autorun If automatically launch SillyTavern in the browser - * @property {string} autorunHostname Autorun hostname - * @property {number} autorunPortOverride Autorun port override (-1 is use server port) + * @property {boolean} browserLaunchEnabled If automatically launch SillyTavern in the browser + * @property {string} browserLaunchHostname Browser launch hostname + * @property {number} browserLaunchPort Browser launch port override (-1 is use server port) + * @property {boolean} browserLaunchAvoidLocalhost If avoid using 'localhost' for browser launch in auto mode * @property {boolean} enableCorsProxy If enable CORS proxy * @property {boolean} disableCsrf If disable CSRF protection * @property {boolean} ssl If enable SSL * @property {string} certPath Path to certificate * @property {string} keyPath Path to private key * @property {boolean} whitelistMode If enable whitelist mode - * @property {boolean} avoidLocalhost If avoid using 'localhost' for autorun in auto mode * @property {boolean} basicAuthMode If enable basic authentication * @property {boolean} requestProxyEnabled If enable outgoing request proxy * @property {string} requestProxyUrl Request proxy URL * @property {string[]} requestProxyBypass Request proxy bypass list * @property {function(): URL} getIPv4ListenUrl Get IPv4 listen URL * @property {function(): URL} getIPv6ListenUrl Get IPv6 listen URL - * @property {function(import('./server-startup.js').ServerStartupResult): Promise} getAutorunHostname Get autorun hostname - * @property {function(string): URL} getAutorunUrl Get autorun URL + * @property {function(import('./server-startup.js').ServerStartupResult): Promise} getBrowserLaunchHostname Get browser launch hostname + * @property {function(string): URL} getBrowserLaunchUrl Get browser launch URL */ /** @@ -51,16 +51,16 @@ export class CommandLineParser { enableIPv4: true, enableIPv6: false, dnsPreferIPv6: false, - autorun: false, - autorunHostname: 'auto', - autorunPortOverride: -1, + browserLaunchEnabled: false, + browserLaunchHostname: 'auto', + browserLaunchPort: -1, + browserLaunchAvoidLocalhost: false, enableCorsProxy: false, disableCsrf: false, ssl: false, certPath: 'certs/cert.pem', keyPath: 'certs/privkey.pem', whitelistMode: true, - avoidLocalhost: false, basicAuthMode: false, requestProxyEnabled: false, requestProxyUrl: '', @@ -71,11 +71,11 @@ export class CommandLineParser { getIPv6ListenUrl: function () { throw new Error('getIPv6ListenUrl is not implemented'); }, - getAutorunHostname: async function () { - throw new Error('getAutorunHostname is not implemented'); + getBrowserLaunchHostname: async function () { + throw new Error('getBrowserLaunchHostname is not implemented'); }, - getAutorunUrl: function () { - throw new Error('getAutorunUrl is not implemented'); + getBrowserLaunchUrl: function () { + throw new Error('getBrowserLaunchUrl is not implemented'); }, }); @@ -100,90 +100,133 @@ export class CommandLineParser { type: 'string', default: null, describe: 'Enables IPv6 protocol', - }).option('enableIPv4', { + }) + .option('enableIPv4', { type: 'string', default: null, describe: 'Enables IPv4 protocol', - }).option('port', { + }) + .option('port', { type: 'number', default: null, describe: 'Sets the server listening port', - }).option('dnsPreferIPv6', { + }) + .option('dnsPreferIPv6', { type: 'boolean', default: null, describe: 'Prefers IPv6 for DNS\nYou should probably have the enabled if you\'re on an IPv6 only network', - }).option('autorun', { + }) + .option('browserLaunchEnabled', { type: 'boolean', default: null, describe: 'Automatically launch SillyTavern in the browser', - }).option('autorunHostname', { + }) + .option('browserLaunchHostname', { type: 'string', default: null, - describe: 'Sets the autorun hostname, probably best left on \'auto\'.\nUse values like \'localhost\', \'st.example.com\'', - }).option('autorunPortOverride', { - type: 'string', + describe: 'Sets the browser launch hostname, best left on \'auto\'.\nUse values like \'localhost\', \'st.example.com\'', + }) + .option('browserLaunchPort', { + type: 'number', default: null, - describe: 'Overrides the port for autorun with open your browser with this port and ignore what port the server is running on. -1 is use server port', - }).option('listen', { + describe: 'Overrides the port for browser launch with open your browser with this port and ignore what port the server is running on. -1 is use server port', + }) + .option('browserLaunchAvoidLocalhost', { + type: 'boolean', + default: null, + describe: 'Avoids using \'localhost\' for browser launch in auto mode.\nUse if you don\'t have \'localhost\' in your hosts file', + }) + .option('listen', { type: 'boolean', default: null, describe: 'Whether to listen on all network interfaces', - }).option('listenAddressIPv6', { + }) + .option('listenAddressIPv6', { type: 'string', default: null, describe: 'Specific IPv6 address to listen to', - }).option('listenAddressIPv4', { + }) + .option('listenAddressIPv4', { type: 'string', default: null, describe: 'Specific IPv4 address to listen to', - }).option('corsProxy', { + }) + .option('corsProxy', { type: 'boolean', default: null, describe: 'Enables CORS proxy', - }).option('disableCsrf', { + }) + .option('disableCsrf', { type: 'boolean', default: null, describe: 'Disables CSRF protection - NOT RECOMMENDED', - }).option('ssl', { + }) + .option('ssl', { type: 'boolean', default: null, describe: 'Enables SSL', - }).option('certPath', { + }) + .option('certPath', { type: 'string', default: null, describe: 'Path to SSL certificate file', - }).option('keyPath', { + }) + .option('keyPath', { type: 'string', default: null, describe: 'Path to SSL private key file', - }).option('whitelist', { + }) + .option('whitelist', { type: 'boolean', default: null, describe: 'Enables whitelist mode', - }).option('dataRoot', { + }) + .option('dataRoot', { type: 'string', default: null, describe: 'Root directory for data storage', - }).option('avoidLocalhost', { - type: 'boolean', - default: null, - describe: 'Avoids using \'localhost\' for autorun in auto mode.\nUse if you don\'t have \'localhost\' in your hosts file', - }).option('basicAuthMode', { + }) + .option('basicAuthMode', { type: 'boolean', default: null, describe: 'Enables basic authentication', - }).option('requestProxyEnabled', { + }) + .option('requestProxyEnabled', { type: 'boolean', default: null, describe: 'Enables a use of proxy for outgoing requests', - }).option('requestProxyUrl', { + }) + .option('requestProxyUrl', { type: 'string', default: null, describe: 'Request proxy URL (HTTP or SOCKS protocols)', - }).option('requestProxyBypass', { + }) + .option('requestProxyBypass', { type: 'array', describe: 'Request proxy bypass list (space separated list of hosts)', - }).parseSync(); + }) + /* DEPRECATED options */ + .option('autorun', { + type: 'boolean', + default: null, + describe: 'DEPRECATED: Use "browserLaunchEnabled" instead.', + }) + .option('autorunHostname', { + type: 'string', + default: null, + describe: 'DEPRECATED: Use "browserLaunchHostname" instead.', + }) + .option('autorunPortOverride', { + type: 'number', + default: null, + describe: 'DEPRECATED: Use "browserLaunchPort" instead.', + }) + .option('avoidLocalhost', { + type: 'boolean', + default: null, + describe: 'DEPRECATED: Use "browserLaunchAvoidLocalhost" instead.', + }) + .parseSync(); const configPath = cliArguments.configPath ?? this.default.configPath; initConfig(configPath); @@ -198,16 +241,16 @@ export class CommandLineParser { enableIPv4: stringToBool(cliArguments.enableIPv4) ?? stringToBool(getConfigValue('protocol.ipv4', this.default.enableIPv4)) ?? this.default.enableIPv4, enableIPv6: stringToBool(cliArguments.enableIPv6) ?? stringToBool(getConfigValue('protocol.ipv6', this.default.enableIPv6)) ?? this.default.enableIPv6, dnsPreferIPv6: cliArguments.dnsPreferIPv6 ?? getConfigValue('dnsPreferIPv6', this.default.dnsPreferIPv6, 'boolean'), - autorun: cliArguments.autorun ?? getConfigValue('autorun', this.default.autorun, 'boolean'), - autorunHostname: cliArguments.autorunHostname ?? getConfigValue('autorunHostname', this.default.autorunHostname), - autorunPortOverride: cliArguments.autorunPortOverride ?? getConfigValue('autorunPortOverride', this.default.autorunPortOverride, 'number'), + browserLaunchEnabled: cliArguments.browserLaunchEnabled ?? cliArguments.autorun ?? getConfigValue('browserLaunch.enabled', this.default.browserLaunchEnabled, 'boolean'), + browserLaunchHostname: cliArguments.browserLaunchHostname ?? cliArguments.autorunHostname ?? getConfigValue('browserLaunch.hostname', this.default.browserLaunchHostname), + browserLaunchPort: cliArguments.browserLaunchPort ?? cliArguments.autorunPortOverride ?? getConfigValue('browserLaunch.port', this.default.browserLaunchPort, 'number'), + browserLaunchAvoidLocalhost: cliArguments.browserLaunchAvoidLocalhost ?? cliArguments.avoidLocalhost ?? getConfigValue('browserLaunch.avoidLocalhost', this.default.browserLaunchAvoidLocalhost, 'boolean'), enableCorsProxy: cliArguments.corsProxy ?? getConfigValue('enableCorsProxy', this.default.enableCorsProxy, 'boolean'), disableCsrf: cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', this.default.disableCsrf, 'boolean'), ssl: cliArguments.ssl ?? getConfigValue('ssl.enabled', this.default.ssl, 'boolean'), certPath: cliArguments.certPath ?? getConfigValue('ssl.certPath', this.default.certPath), keyPath: cliArguments.keyPath ?? getConfigValue('ssl.keyPath', this.default.keyPath), whitelistMode: cliArguments.whitelist ?? getConfigValue('whitelistMode', this.default.whitelistMode, 'boolean'), - avoidLocalhost: cliArguments.avoidLocalhost ?? getConfigValue('avoidLocalhost', this.default.avoidLocalhost, 'boolean'), basicAuthMode: cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', this.default.basicAuthMode, 'boolean'), requestProxyEnabled: cliArguments.requestProxyEnabled ?? getConfigValue('requestProxy.enabled', this.default.requestProxyEnabled, 'boolean'), requestProxyUrl: cliArguments.requestProxyUrl ?? getConfigValue('requestProxy.url', this.default.requestProxyUrl), @@ -228,12 +271,12 @@ export class CommandLineParser { (':' + this.port), ); }, - getAutorunHostname: async function ({ useIPv6, useIPv4 }) { - if (this.autorunHostname === 'auto') { - let localhostResolve = await canResolve('localhost', useIPv6, useIPv4); + getBrowserLaunchHostname: async function ({ useIPv6, useIPv4 }) { + if (this.browserLaunchHostname === 'auto') { + const localhostResolve = await canResolve('localhost', useIPv6, useIPv4); if (useIPv6 && useIPv4) { - return (this.avoidLocalhost || !localhostResolve) ? '[::1]' : 'localhost'; + return (this.browserLaunchAvoidLocalhost || !localhostResolve) ? '[::1]' : 'localhost'; } if (useIPv6) { @@ -245,15 +288,15 @@ export class CommandLineParser { } } - return this.autorunHostname; + return this.browserLaunchHostname; }, - getAutorunUrl: function (hostname) { - const autorunPort = (this.autorunPortOverride >= 0) ? this.autorunPortOverride : this.port; + getBrowserLaunchUrl: function (hostname) { + const browserLaunchPort = (this.browserLaunchPort >= 0) ? this.browserLaunchPort : this.port; return new URL( (this.ssl ? 'https://' : 'http://') + (hostname) + (':') + - (autorunPort), + (browserLaunchPort), ); }, }; diff --git a/src/config-init.js b/src/config-init.js index 826929b50..b372f8e82 100644 --- a/src/config-init.js +++ b/src/config-init.js @@ -4,7 +4,7 @@ import yaml from 'yaml'; import color from 'chalk'; import _ from 'lodash'; import { serverDirectory } from './server-directory.js'; -import { setConfigFilePath } from './util.js'; +import { keyToEnv, setConfigFilePath } from './util.js'; const keyMigrationMap = [ { @@ -98,6 +98,26 @@ const keyMigrationMap = [ migrate: () => void 0, remove: true, }, + { + oldKey: 'autorun', + newKey: 'browserLaunch.enabled', + migrate: (value) => value, + }, + { + oldKey: 'autorunHostname', + newKey: 'browserLaunch.hostname', + migrate: (value) => value, + }, + { + oldKey: 'autorunPortOverride', + newKey: 'browserLaunch.port', + migrate: (value) => value, + }, + { + oldKey: 'avoidLocalhost', + newKey: 'browserLaunch.avoidLocalhost', + migrate: (value) => value, + }, ]; /** @@ -133,6 +153,18 @@ export function addMissingConfigValues(configPath) { // Migrate old keys to new keys const migratedKeys = []; for (const { oldKey, newKey, migrate, remove } of keyMigrationMap) { + // Migrate environment variables + const oldEnvKey = keyToEnv(oldKey); + const newEnvKey = keyToEnv(newKey); + if (process.env[oldEnvKey] && !process.env[newEnvKey]) { + const oldValue = process.env[oldEnvKey]; + const newValue = migrate(oldValue); + process.env[newEnvKey] = newValue; + delete process.env[oldEnvKey]; + console.warn(color.yellow(`Warning: Using a deprecated environment variable: ${oldEnvKey}. Please use ${newEnvKey} instead.`)); + console.log(`Redirecting ${color.blue(oldEnvKey)}=${oldValue} -> ${color.blue(newEnvKey)}=${newValue}`); + } + if (_.has(config, oldKey)) { if (remove) { _.unset(config, oldKey); diff --git a/src/server-main.js b/src/server-main.js index 28b9afc10..2153c9b8b 100644 --- a/src/server-main.js +++ b/src/server-main.js @@ -14,7 +14,7 @@ import multer from 'multer'; import responseTime from 'response-time'; import helmet from 'helmet'; import bodyParser from 'body-parser'; -import open from 'open'; +import open, { apps } from 'open'; // local library imports import './fetch-patch.js'; @@ -65,6 +65,7 @@ import { safeReadFileSync, setupLogLevel, setWindowTitle, + getConfigValue, } from './util.js'; import { UPLOADS_DIRECTORY } from './constants.js'; import { ensureThumbnailCache } from './endpoints/thumbnails.js'; @@ -83,6 +84,7 @@ util.inspect.defaultOptions.maxArrayLength = null; util.inspect.defaultOptions.maxStringLength = null; util.inspect.defaultOptions.depth = 4; +/** @type {import('./command-line.js').CommandLineArguments} */ const cliArgs = globalThis.COMMAND_LINE_ARGS; if (!cliArgs.enableIPv6 && !cliArgs.enableIPv4) { @@ -321,13 +323,22 @@ async function preSetupTasks() { * @returns {Promise} */ async function postSetupTasks(result) { - const autorunHostname = await cliArgs.getAutorunHostname(result); - const autorunUrl = cliArgs.getAutorunUrl(autorunHostname); + const browserLaunchHostname = await cliArgs.getBrowserLaunchHostname(result); + const browserLaunchUrl = cliArgs.getBrowserLaunchUrl(browserLaunchHostname); + const browserLaunchApp = String(getConfigValue('browserLaunch.browser', 'default') ?? ''); - if (cliArgs.autorun) { + if (cliArgs.browserLaunchEnabled) { try { - console.log('Launching in a browser...'); - await open(autorunUrl.toString()); + const validBrowsers = { + 'firefox': apps.firefox, + 'chrome': apps.chrome, + 'edge': apps.edge, + }; + const appName = validBrowsers[browserLaunchApp.trim().toLowerCase()]; + const openOptions = appName ? { app: { name: appName } } : {}; + + console.log(`Launching in a browser: ${browserLaunchApp}...`); + await open(browserLaunchUrl.toString(), openOptions); } catch (error) { console.error('Failed to launch the browser. Open the URL manually.'); } @@ -349,7 +360,7 @@ async function postSetupTasks(result) { ); } - const goToLog = 'Go to: ' + color.blue(autorunUrl) + ' to open SillyTavern'; + const goToLog = `Go to: ${color.blue(browserLaunchUrl)} to open SillyTavern`; const plainGoToLog = removeColorFormatting(goToLog); console.log(logListen); @@ -363,7 +374,7 @@ async function postSetupTasks(result) { console.log('\n' + getSeparator(plainGoToLog.length) + '\n'); setupLogLevel(); - serverEvents.emit(EVENT_NAMES.SERVER_STARTED, { url: autorunUrl }); + serverEvents.emit(EVENT_NAMES.SERVER_STARTED, { url: browserLaunchUrl }); } /**