From 757af8d89b19165069ae084109c5ab2d604996d6 Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Wed, 25 Feb 2026 13:59:27 +0800 Subject: [PATCH] refactor: rename HOST_* env vars to SLHAF_HUB_* across CLI/TUI, security, docs, and compose --- README.md | 8 ++++---- README.zh-CN.md | 8 ++++---- docker-compose.yml | 4 ++-- src/main/kotlin/work/slhaf/hub/WebSecurity.kt | 2 +- tools/slhaf-hub-cli.kts | 8 ++++---- tools/slhaf-hub-tui.kts | 10 +++++----- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index d86bdad..7bfbb16 100644 --- a/README.md +++ b/README.md @@ -37,15 +37,15 @@ cd slhaf-hub docker build -t slhaf-hub:latest . docker run --rm -p 8080:8080 \ -v "$(pwd)/scripts:/app/scripts" \ - -e HOST_API_TOKEN=your-token \ + -e SLHAF_HUB_TOKEN=your-token \ -e MAX_RUN_CONCURRENCY=8 \ slhaf-hub:latest ``` #### 3) Run with Docker Compose ```bash -# optional: export HOST_API_TOKEN=your-token -# optional: export HOST_PORT=8080 +# optional: export SLHAF_HUB_TOKEN=your-token +# optional: export SLHAF_HUB_PORT=8080 # optional: export MAX_RUN_CONCURRENCY=8 docker compose up -d --build ``` @@ -79,7 +79,7 @@ Auth headers: - `X-Host-Token: ` Token source priority: -1. `HOST_API_TOKEN` env var +1. `SLHAF_HUB_TOKEN` env var 2. `scripts/.host-api-token` 3. Auto-generated token saved to `scripts/.host-api-token` diff --git a/README.zh-CN.md b/README.zh-CN.md index c70e950..1036d16 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -37,15 +37,15 @@ cd slhaf-hub docker build -t slhaf-hub:latest . docker run --rm -p 8080:8080 \ -v "$(pwd)/scripts:/app/scripts" \ - -e HOST_API_TOKEN=your-token \ + -e SLHAF_HUB_TOKEN=your-token \ -e MAX_RUN_CONCURRENCY=8 \ slhaf-hub:latest ``` #### 3) Docker Compose 启动 ```bash -# 可选:export HOST_API_TOKEN=your-token -# 可选:export HOST_PORT=8080 +# 可选:export SLHAF_HUB_TOKEN=your-token +# 可选:export SLHAF_HUB_PORT=8080 # 可选:export MAX_RUN_CONCURRENCY=8 docker compose up -d --build ``` @@ -79,7 +79,7 @@ CLI/TUI 环境变量: - `X-Host-Token: ` Token 来源优先级: -1. 环境变量 `HOST_API_TOKEN` +1. 环境变量 `SLHAF_HUB_TOKEN` 2. `scripts/.host-api-token` 3. 自动生成并写入 `scripts/.host-api-token` diff --git a/docker-compose.yml b/docker-compose.yml index 1f19581..ae02df0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,9 +10,9 @@ services: container_name: slhaf-hub restart: unless-stopped ports: - - "${HOST_PORT:-8080}:8080" + - "${SLHAF_HUB_PORT:-8080}:8080" environment: - HOST_API_TOKEN: ${HOST_API_TOKEN:-} + SLHAF_HUB_TOKEN: ${SLHAF_HUB_TOKEN:-} MAX_RUN_CONCURRENCY: ${MAX_RUN_CONCURRENCY:-} volumes: - ./scripts:/app/scripts diff --git a/src/main/kotlin/work/slhaf/hub/WebSecurity.kt b/src/main/kotlin/work/slhaf/hub/WebSecurity.kt index 0921b2e..671e0a0 100644 --- a/src/main/kotlin/work/slhaf/hub/WebSecurity.kt +++ b/src/main/kotlin/work/slhaf/hub/WebSecurity.kt @@ -8,7 +8,7 @@ import io.ktor.server.response.respondText import java.io.File import java.security.SecureRandom -private const val ENV_API_TOKEN = "HOST_API_TOKEN" +private const val ENV_API_TOKEN = "SLHAF_HUB_TOKEN" private const val TOKEN_FILE_NAME = ".host-api-token" private const val SUBTOKEN_FILE_NAME = ".host-subtokens.db" private const val ALT_TOKEN_HEADER = "X-Host-Token" diff --git a/tools/slhaf-hub-cli.kts b/tools/slhaf-hub-cli.kts index f052162..dc76251 100755 --- a/tools/slhaf-hub-cli.kts +++ b/tools/slhaf-hub-cli.kts @@ -9,8 +9,8 @@ import java.net.http.HttpResponse import java.nio.charset.StandardCharsets import kotlin.system.exitProcess -val ENV_API_BASE_URL = "HOST_API_BASE_URL" -val ENV_API_TOKEN = "HOST_API_TOKEN" +val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL" +val ENV_API_TOKEN = "SLHAF_HUB_TOKEN" data class GlobalOptions( val baseUrl: String, @@ -30,9 +30,9 @@ Usage: kotlin slhaf-hub-cli.kts [global options] [command options] Global options: - --base-url= Default: HOST_API_BASE_URL or http://127.0.0.1:8080 + --base-url= Default: SLHAF_HUB_BASE_URL or http://127.0.0.1:8080 --token= Authorization token - --token-file= Load token from file (fallback: HOST_API_TOKEN env) + --token-file= Load token from file (fallback: SLHAF_HUB_TOKEN env) Commands: health diff --git a/tools/slhaf-hub-tui.kts b/tools/slhaf-hub-tui.kts index b9bdbfb..b49ace9 100755 --- a/tools/slhaf-hub-tui.kts +++ b/tools/slhaf-hub-tui.kts @@ -54,8 +54,8 @@ private val YELLOW = "\u001b[33m" private val RED = "\u001b[31m" private val BG_BLUE = "\u001b[44m" private val FG_BLACK = "\u001b[30m" -val ENV_API_BASE_URL = "HOST_API_BASE_URL" -val ENV_API_TOKEN = "HOST_API_TOKEN" +val ENV_API_BASE_URL = "SLHAF_HUB_BASE_URL" +val ENV_API_TOKEN = "SLHAF_HUB_TOKEN" private fun ok(text: String) = "$GREEN$text$RESET" private fun warn(text: String) = "$YELLOW$text$RESET" @@ -81,8 +81,8 @@ Keys: q Quit Env fallback: - HOST_API_BASE_URL - HOST_API_TOKEN + SLHAF_HUB_BASE_URL + SLHAF_HUB_TOKEN """.trimIndent() fun parseOptions(args: List): Options { @@ -113,7 +113,7 @@ fun readToken(options: Options): String { return file.readText().trim() } return System.getenv(ENV_API_TOKEN)?.trim() - ?: error("Missing token. Use --token or --token-file or HOST_API_TOKEN") + ?: error("Missing token. Use --token or --token-file or SLHAF_HUB_TOKEN") } fun encode(value: String): String = URLEncoder.encode(value, StandardCharsets.UTF_8)