From cb531a0f69f14bc4f297481be2af46992be26a64 Mon Sep 17 00:00:00 2001 From: eries Date: Tue, 20 Oct 2026 22:40:19 +0800 Subject: [PATCH] ci(release): add full, clash-api and native-api artifacts --- .agents/rules/configuration.md | 2 +- .agents/rules/real-ebpf.md | 2 +- .agents/rules/release.md | 8 +- .github/ci/check-debug-artifacts.sh | 18 ++++- .github/ci/test-debug-artifacts.sh | 14 +++- .github/workflows/ci.yml | 2 + .github/workflows/release.yml | 81 +++++++++++++------- Justfile | 19 ++++- README.md | 4 +- README.zh.md | 4 +- crates/honk-config/conformance/manifest.toml | 16 ++-- doc/en/configuration.md | 2 +- doc/en/design/control-plane.md | 2 +- doc/en/design/overview.md | 2 +- doc/en/how-to-start.md | 16 ++-- doc/en/reference/api.md | 6 +- doc/en/reference/experimental.md | 4 +- doc/zh/configuration.md | 2 +- doc/zh/design/control-plane.md | 2 +- doc/zh/design/overview.md | 2 +- doc/zh/how-to-start.md | 16 ++-- doc/zh/reference/api.md | 6 +- doc/zh/reference/experimental.md | 4 +- 23 files changed, 156 insertions(+), 78 deletions(-) diff --git a/.agents/rules/configuration.md b/.agents/rules/configuration.md index b1151522..650bd4d4 100644 --- a/.agents/rules/configuration.md +++ b/.agents/rules/configuration.md @@ -66,7 +66,7 @@ Owned nftables names and firewall restrictions: `crates/honk-nfqueue`. - DNS upstream URI schemes: `udp://` (bare default), `tcp://`, `tcp+udp://`, `tls://` (DoT), `https://` (DoH), `h3://`/`http3://` (DoH3), `quic://` (DoQ); optional dial-path proxy `name: 'uri' -> ` (or legacy `outbound:` key). DNS transport retry decisions live in `transport/retry.rs`; typed deterministic HTTP/DNS responses and packet refusals remain terminal through session-error wrappers. DoH/H3/DoQ reset retires only the observed session; `LifecycleSlot` retains one teardown future so cancelled close can be resumed by acquire or shutdown without touching replacements. DoH3 GOAWAY uses the query-level retry's close outside the query deadline; never close a session inside `exchange_once`'s cancellable timeout. Direct UDP cold and cached-current paths reacquire through `UpstreamPool::udp_pool`, replacing closed/stopped sockets before exchange. Linux `udp_pool/error_queue.rs` owns `IP_RECVERR`/`IPV6_RECVERR`: READABLE and ERROR readiness have separate consumers, and only a complete quoted DNS ID/question may fail its matching pending request. Unattributed receive errors leave other requests pending; only a socket-fatal receive error fans out and stops the pool. Preserve raw I/O causes, ID quarantine, and the one absolute send/response deadline. A send syscall failure retains the existing current-exchange error behavior; it is not quote-attributed or retried within that exchange. - Clash UI: `assets.ui.url` (legacy alias `experimental.clash_api.external_ui_download_url`) selects HTTP(S) dashboard ZIP; empty uses built-in zashboard. `HONK_UI_DOWNLOAD_URL` overrides both. Nonempty `assets.ui.route` (legacy alias `external_ui_download_detour`, falling back to `assets.route`; `routing` means empty) forces the initial download and every redirect through its node/group; empty uses per-URL traffic routing. Both config fields require restart. -- Native API: opt-in `native-api` (build with `--features native-api` or `native-ui`; release builds include it), default-off independent `experimental.native_api` listener; every configured field is restart-required. Default-true flow, traffic, memory, log and DNS-log recording uses bounded process-local stores; disabled stores do not collect. Shared admission validates bearer/anonymous loopback, numeric listen and Host/Origin. Probes, geodata and shared downloads use configured targets without an address or port allowlist. Whoever can write the configuration or control subscription content decides those targets; provider content is trusted configuration. The removed keys `probe_allowed_cidrs` and `probe_allowed_ports` are ignored by dae and compatibility structured loaders with one warning per key and are absent from the config schema and serialization. `ui` is a trusted directory or `embedded` with default-off `native-ui`; no runtime download/extraction/build. Native/Clash share per-network Selector identities; Clash writes both and displays TCP. Icons are explicit configured values. Group PATCH and main-source node/provider create/delete use parser-owned edits; automatic-policy pin/clear is available; native runtime mode and full transparency remain gated. +- Native API: opt-in `native-api` (build with `--features native-api` or `native-ui`; the full and `-native-api` release artifacts include it), default-off independent `experimental.native_api` listener; every configured field is restart-required. Default-true flow, traffic, memory, log and DNS-log recording uses bounded process-local stores; disabled stores do not collect. Shared admission validates bearer/anonymous loopback, numeric listen and Host/Origin. Probes, geodata and shared downloads use configured targets without an address or port allowlist. Whoever can write the configuration or control subscription content decides those targets; provider content is trusted configuration. The removed keys `probe_allowed_cidrs` and `probe_allowed_ports` are ignored by dae and compatibility structured loaders with one warning per key and are absent from the config schema and serialization. `ui` is a trusted directory or `embedded` with default-off `native-ui`; no runtime download/extraction/build. Native/Clash share per-network Selector identities; Clash writes both and displays TCP. Icons are explicit configured values. Group PATCH and main-source node/provider create/delete use parser-owned edits; automatic-policy pin/clear is available; native runtime mode and full transparency remain gated. Auto flows require successful flow reads or explicit flow-event SSE demand; Auto logs require admitted `/logs` SSE, and Auto DNS logs require successful `/dns/log` GET. Ordinary events enable events only. Each demand has independent leases and 60-second last-demand grace; other demand kinds, ordinary APIs, validation, failed GETs and HEAD do not renew it. General `grace_remaining_seconds` is not a diagnostic countdown. Explicit runtime On/Off, configuration prohibitions and activation resets remain authoritative. Captured condition text uses source spelling cached with the compiled generation, never per-flow GeoIP network expansion; real text truncation remains visible loss. - Native configuration authority: only startup-captured genuine `.dae` sources enable source management. Content is returned to any admitted request; `config_write` defaults false and requires a nonempty configured secret or `password_auth`. Every accepted non-credential source is writable; credential-bearing sources stay read-only and only their listener-secret values are masked, by value. Metadata paths and rule-source file labels keep canonical entry-directory-relative names and also carry the absolute path; administrator content is exact, and masked content is never a save payload. Source/dependency admission is bounded to 32 references and 8 MiB including cached subscriptions and repeated materialized aliases, with the existing 64 KiB HTTP JSON ceiling. Standard geodata has a separate 256 MiB per-file bound and remains hashed for revalidation. Never-fetched subscriptions are admitted with a warning and no cached nodes; other missing/invalid dependencies fail. Full validation uses effective runtime data paths and read-only local dependencies, never network or runtime publication. - Configuration db (`--store db`, `native_api/store/`): `SourceStore` is the coordinator's only source seam; `FileStore` edits `-c`, `DbStore` keeps `.dae` revisions in the state db (`state.rs`, `/state/honk.db`) with listener secrets stripped and stored apart; retention counts stored JSON. `dependency_root()` is `None` in db mode, so the imported tree authorizes no dependency. `commit` only fences `head`; `promote` records after activation commits, and a promote failure or unconfirmed activation blocks writes until restart or a re-activation of `head`. `store_value()` reads only cached state; SQLite work runs in `spawn_blocking`. Import, export, revision list and activate: `doc/en/reference/api.md`. diff --git a/.agents/rules/real-ebpf.md b/.agents/rules/real-ebpf.md index 47eef2a6..31ee81e9 100644 --- a/.agents/rules/real-ebpf.md +++ b/.agents/rules/real-ebpf.md @@ -7,7 +7,7 @@ The proxy engine (library `honk_core` + `honk-core` binary). Cargo features: - `default = ["clash-api", "mimalloc", "rprx"]` - `ebpf` — aya real backend + `honk-nfqueue`, requires Linux kernel 6.12+; otherwise `MockEbpfBackend`. NFQUEUE activation follows `configuration.md`. - `clash-api` — Clash-compatible REST/WS API (pulls in optional axum/tower-http). -- `native-api` — independent, opt-in native HTTP observations/control with a default-off listener; build with `--features native-api` (or `native-ui`); release builds include it. It can run with mock or real eBPF and without Clash; real-kernel CI enables it for lifecycle regression coverage. +- `native-api` — independent, opt-in native HTTP observations/control with a default-off listener; build with `--features native-api` (or `native-ui`); the full and `-native-api` release artifacts include it. It can run with mock or real eBPF and without Clash; real-kernel CI enables it for lifecycle regression coverage. - `mimalloc` — shipped binary allocates through mimalloc (see Technology stack in `AGENTS.md`); build with `--no-default-features --features "clash-api,ebpf,rprx,native-ui"` for the release capabilities with stock malloc. `native-ui` embeds the pinned doona build and fails without an absolute `HONK_DOONA_DIR` (`export HONK_DOONA_DIR=$(ci/fetch-doona.sh)`); use `native-api` instead only when embedded hosting (`ui: embedded`) is not needed. - `rprx` — forwards to `honk-outbound/rprx`: registers VLESS (VLESS Encryption and xtls-rprx-vision) and VMess handlers; without it VLESS/VMess nodes parse fine but fail at dial with "No handler for protocol". diff --git a/.agents/rules/release.md b/.agents/rules/release.md index adfb91f9..9106076d 100644 --- a/.agents/rules/release.md +++ b/.agents/rules/release.md @@ -25,17 +25,17 @@ Each of those steps runs `ci/run-exact-ignored-tests.sh ...`, whi The independent weekly `fuzz` job uses the nightly channel from `crates/honk-ebpf/rust-toolchain.toml` and `CARGO_FUZZ_VERSION` from `pins.env`. It runs `document`, `share_link`, and `lexer` sequentially with two workers, 480 seconds per target, a 10-second input timeout and a 2048 MiB RSS limit. The job has a 40-minute timeout and uploads `fuzz-inputs` on success or failure. It keeps `contents: read` and opens no issues. -`.github/workflows/release.yml` on `v*` and `debug.*`: `cargo test --workspace --no-fail-fast` (`cmake` + `libclang-dev` required for boring-sys), then `honk-core --features ebpf` for `x86_64`/`aarch64` × `gnu`/`musl`. Native gnu uses `cargo build`; the other three use **zig cc/c++ `ci/zigcc` / `ci/zigcxx` wrappers**. Cross CMake injects ASM `--target` flags rejected by GCC and, in Rust-triple spelling, zig; wrappers strip/re-anchor on `$ZIGCC_TARGET`. Musl sets `link-self-contained=no` for zig CRT. Each target ships default mimalloc and `-stock` without `mimalloc` (lower RSS high-water on small gateways). The host compiler comes from the root `rust-toolchain.toml`; build eBPF once on the host with `crates/honk-ebpf/rust-toolchain.toml` and pinned prebuilt `bpf-linker`; **verify `.BTF`** before packaging. Each tarball carries doona's `LICENSE`, `LICENSES/`, `NOTICE` and `THIRD-PARTY-NOTICES.txt` under `doona/`, and the release job attaches `doona-source-.tar.gz` from `ci/fetch-doona.sh --source` to every tag release and Debug release (GPL-3.0 section 6). Publish GitHub Release tarballs; formal `alpha`/`beta`/`rc` tags and all Debug builds are prereleases. +`.github/workflows/release.yml` on `v*` and `debug.*`: `cargo test --workspace --no-fail-fast` (`cmake` + `libclang-dev` required for boring-sys), then sixteen release-profile builds. Three variants: full (`clash-api,native-ui`), clash-api-only (`clash-api`) and native-api-only (`native-api`); the full build covers `x86_64`/`aarch64` × `gnu`/`musl`, while the lean variants ship only for the static gateway (`musl`) targets. Every build passes `--no-default-features` plus its exact feature list, so native-api-only really drops the default-on `clash-api`. Native gnu uses `cargo build`; the other three use **zig cc/c++ `ci/zigcc` / `ci/zigcxx` wrappers**. Cross CMake injects ASM `--target` flags rejected by GCC and, in Rust-triple spelling, zig; wrappers strip/re-anchor on `$ZIGCC_TARGET`. Musl sets `link-self-contained=no` for zig CRT. Each target ships default mimalloc and `-stock` without `mimalloc` (lower RSS high-water on small gateways). The host compiler comes from the root `rust-toolchain.toml`; build eBPF once on the host with `crates/honk-ebpf/rust-toolchain.toml` and pinned prebuilt `bpf-linker`; **verify `.BTF`** before packaging. Each full tarball carries doona's `LICENSE`, `LICENSES/`, `NOTICE` and `THIRD-PARTY-NOTICES.txt` under `doona/`; the lean variants embed no UI and carry no `doona/` directory. The release job attaches `doona-source-.tar.gz` from `ci/fetch-doona.sh --source` to every tag release and Debug release (GPL-3.0 section 6). Publish GitHub Release tarballs; formal `alpha`/`beta`/`rc` tags and all Debug builds are prereleases. Before upload, every x86_64 matrix entry extracts its packaged tarball into a clean temporary directory and runs the nested `honk-core --version`. This covers the loader and early startup for gnu/musl and both allocators, not configuration or datapath behavior. aarch64 artifacts are not executed. Manual release runs keep the same build checks; publication remains restricted to `v*` and `debug.*` tag refs, never branches. ### Debug releases -- Push a source tag such as `debug.2026.9.19.score.1`; the trigger accepts `debug.*` without prescribing a date or component format. It runs the same tests and eight release-profile builds as formal tags. -- Before publishing, `.github/ci/check-debug-artifacts.sh` requires all eight expected tarballs to be regular, nonempty files. Missing or empty inputs fail without publishing. The release test job runs `.github/ci/test-debug-artifacts.sh` against the same check. +- Push a source tag such as `debug.2026.9.19.score.1`; the trigger accepts `debug.*` without prescribing a date or component format. It runs the same tests and sixteen release-profile builds as formal tags. +- Before publishing, `.github/ci/check-debug-artifacts.sh` requires all sixteen expected tarballs to be regular, nonempty files. Missing or empty inputs fail without publishing. The release test job runs `.github/ci/test-debug-artifacts.sh` against the same check. - Each source tag gets its own release, titled with the tag, at `/releases/tag/`. Earlier Debug releases are never moved or overwritten. Every Debug release is a prerelease with `make_latest: false`; notes identify the source tag, commit and workflow run. - After the tag release, the workflow force-moves `refs/tags/debug` to the same commit and updates the release titled `Debug` at `/releases/tag/debug` with the same tarballs, so that page and `/releases/download/debug/` always serve the newest published build. Assets the new build does not have, such as the previous `doona-source-.tar.gz`, are deleted. Downstream pins name the per-tag release, never `debug`. Updating `debug` cannot retrigger `debug.*`. -- Assets keep the fixed `honk-core-debug-[-stock].tar.gz` names inside each release. Re-running the same tag replaces that release's attachments only. Retrying only the release job requires all build artifacts to remain available; if any have expired (one-day retention) or been deleted, use **Re-run all jobs** to rebuild the complete set. +- Assets keep the fixed `honk-core-debug-[-stock][-clash-api|-native-api].tar.gz` names inside each release; the unsuffixed name remains the full build. Re-running the same tag replaces that release's attachments only. Retrying only the release job requires all build artifacts to remain available; if any have expired (one-day retention) or been deleted, use **Re-run all jobs** to rebuild the complete set. - All Debug workflows share a concurrency group with `cancel-in-progress: false`, so a new push does not interrupt a running publication. `contents: write` stays confined to the publication job; formal `v*` publication remains independent. ### Release process (standing convention) diff --git a/.github/ci/check-debug-artifacts.sh b/.github/ci/check-debug-artifacts.sh index 2fa47d9e..db4111e5 100755 --- a/.github/ci/check-debug-artifacts.sh +++ b/.github/ci/check-debug-artifacts.sh @@ -1,9 +1,25 @@ #!/usr/bin/env bash set -euo pipefail -for artifact in dist/honk-core-debug-{x86_64,aarch64}-unknown-linux-{gnu,musl}{,-stock}.tar.gz; do +check() { + local artifact=$1 if [[ ! -f "$artifact" || ! -s "$artifact" ]]; then printf '::error::Missing or empty Debug artifact: %s. Re-run all jobs to rebuild the complete set.\n' "$artifact" >&2 exit 1 fi +} + +# Full: both APIs and the embedded UI, gnu and musl. +for target in x86_64-unknown-linux-gnu x86_64-unknown-linux-musl aarch64-unknown-linux-gnu aarch64-unknown-linux-musl; do + for suffix in '' -stock; do + check "dist/honk-core-debug-$target$suffix.tar.gz" + done +done + +# Lean variants ship for the static gateway targets only. +for target in x86_64-unknown-linux-musl aarch64-unknown-linux-musl; do + for suffix in '' -stock; do + check "dist/honk-core-debug-$target$suffix-clash-api.tar.gz" + check "dist/honk-core-debug-$target$suffix-native-api.tar.gz" + done done diff --git a/.github/ci/test-debug-artifacts.sh b/.github/ci/test-debug-artifacts.sh index 4602a99b..785853f9 100755 --- a/.github/ci/test-debug-artifacts.sh +++ b/.github/ci/test-debug-artifacts.sh @@ -12,6 +12,12 @@ for target in x86_64-unknown-linux-gnu x86_64-unknown-linux-musl aarch64-unknown printf 'artifact\n' > "dist/honk-core-debug-$target$suffix.tar.gz" done done +for target in x86_64-unknown-linux-musl aarch64-unknown-linux-musl; do + for suffix in '' -stock; do + printf 'artifact\n' > "dist/honk-core-debug-$target$suffix-clash-api.tar.gz" + printf 'artifact\n' > "dist/honk-core-debug-$target$suffix-native-api.tar.gz" + done +done bash "$ci_dir/check-debug-artifacts.sh" expect_rejection() { @@ -24,7 +30,13 @@ expect_rejection() { fi } -artifact=dist/honk-core-debug-aarch64-unknown-linux-musl-stock.tar.gz +artifact=dist/honk-core-debug-aarch64-unknown-linux-musl-stock-native-api.tar.gz +mv "$artifact" saved.tar.gz +expect_rejection +mv saved.tar.gz "$artifact" +bash "$ci_dir/check-debug-artifacts.sh" + +artifact=dist/honk-core-debug-x86_64-unknown-linux-gnu.tar.gz mv "$artifact" saved.tar.gz expect_rejection mv saved.tar.gz "$artifact" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5ab39a8f..0a1c5fa2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -917,6 +917,8 @@ jobs: zstd -dc "$archive" | tar -xf - -C "$CARGO_HOME/bin" bpf-linker --version - run: cargo check -p honk-core --features ebpf,native-api --tests + # The release native-api-only artifact drops the default-on clash-api. + - run: cargo check -p honk-core --no-default-features --features ebpf,native-api,rprx,mimalloc - name: Write eBPF compile-guard CI report if: always() uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af164851..4914139a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,38 +73,51 @@ jobs: - run: cargo test --workspace --no-fail-fast build: - name: build ${{ matrix.target }}${{ matrix.suffix }} + name: build ${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }} runs-on: ubuntu-latest timeout-minutes: 40 - env: - ARTIFACT_NAME: honk-core-${{ startsWith(github.ref, 'refs/tags/debug.') && 'debug' || github.ref_name }}-${{ matrix.target }}${{ matrix.suffix }} strategy: fail-fast: false matrix: include: - # Both arches ship two binaries: mimalloc (default, faster QUIC) - # and stock malloc (lower RSS high-water on small gateways). - - target: x86_64-unknown-linux-gnu - suffix: "" - - target: x86_64-unknown-linux-gnu - suffix: "-stock" - - target: x86_64-unknown-linux-musl - suffix: "" - - target: x86_64-unknown-linux-musl - suffix: "-stock" - - target: aarch64-unknown-linux-gnu - suffix: "" - - target: aarch64-unknown-linux-gnu - suffix: "-stock" - - target: aarch64-unknown-linux-musl - suffix: "" - - target: aarch64-unknown-linux-musl - suffix: "-stock" + # Full: Clash API + native API + embedded doona UI. Both arches ship + # two binaries: mimalloc (default, faster QUIC) and stock malloc + # (lower RSS high-water on small gateways). + - {target: x86_64-unknown-linux-gnu, suffix: "", variant: full, name_suffix: ""} + - {target: x86_64-unknown-linux-gnu, suffix: "-stock", variant: full, name_suffix: ""} + - {target: x86_64-unknown-linux-musl, suffix: "", variant: full, name_suffix: ""} + - {target: x86_64-unknown-linux-musl, suffix: "-stock", variant: full, name_suffix: ""} + - {target: aarch64-unknown-linux-gnu, suffix: "", variant: full, name_suffix: ""} + - {target: aarch64-unknown-linux-gnu, suffix: "-stock", variant: full, name_suffix: ""} + - {target: aarch64-unknown-linux-musl, suffix: "", variant: full, name_suffix: ""} + - {target: aarch64-unknown-linux-musl, suffix: "-stock", variant: full, name_suffix: ""} + # Lean variants apply to the static gateway builds only; the gnu + # artifacts stay full. The unsuffixed names remain the full build. + - {target: x86_64-unknown-linux-musl, suffix: "", variant: clash-api, name_suffix: "-clash-api"} + - {target: x86_64-unknown-linux-musl, suffix: "-stock", variant: clash-api, name_suffix: "-clash-api"} + - {target: aarch64-unknown-linux-musl, suffix: "", variant: clash-api, name_suffix: "-clash-api"} + - {target: aarch64-unknown-linux-musl, suffix: "-stock", variant: clash-api, name_suffix: "-clash-api"} + - {target: x86_64-unknown-linux-musl, suffix: "", variant: native-api, name_suffix: "-native-api"} + - {target: x86_64-unknown-linux-musl, suffix: "-stock", variant: native-api, name_suffix: "-native-api"} + - {target: aarch64-unknown-linux-musl, suffix: "", variant: native-api, name_suffix: "-native-api"} + - {target: aarch64-unknown-linux-musl, suffix: "-stock", variant: native-api, name_suffix: "-native-api"} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 + # Manual runs can select a branch whose name contains '/', which cannot + # appear in an asset path. Tags keep the existing debug/v* spelling. + - name: Resolve artifact name + run: | + set -euo pipefail + if [[ "$GITHUB_REF" == refs/tags/debug.* ]]; then + prefix=debug + else + prefix=${GITHUB_REF_NAME//\//-} + fi + echo "ARTIFACT_NAME=honk-core-$prefix-${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }}" >> "$GITHUB_ENV" + - name: Read Rust toolchains id: toolchain run: | @@ -125,7 +138,7 @@ jobs: components: rust-src, llvm-tools - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2 with: - key: ${{ matrix.target }}${{ matrix.suffix }} + key: ${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }} cache-on-failure: true save-if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }} workspaces: | @@ -173,17 +186,26 @@ jobs: version: 0.14.1 - name: Fetch doona for the embedded UI + if: matrix.variant == 'full' run: | set -euo pipefail dir=$(ci/fetch-doona.sh) echo "HONK_DOONA_DIR=$dir" >> "$GITHUB_ENV" - # Allocator variants must expose the same protocol and API capabilities. + # The release builds from an exact feature set: `--no-default-features` + # below means the native-api-only variant really drops the default-on + # clash-api. Allocator variants keep the same protocol and API features. - name: Resolve feature set shell: bash run: | set -euo pipefail - features=clash-api,ebpf,rprx,native-ui + case "${{ matrix.variant }}" in + full) features=clash-api,native-ui ;; + clash-api) features=clash-api ;; + native-api) features=native-api ;; + *) printf 'unknown variant: %s\n' "${{ matrix.variant }}" >&2; exit 1 ;; + esac + features="ebpf,rprx,$features" if [[ "${{ matrix.suffix }}" != "-stock" ]]; then features+=,mimalloc fi @@ -227,9 +249,12 @@ jobs: mkdir -p "dist/$name" cp "target/${{ matrix.target }}/release/honk-core" "dist/$name/" cp LICENSE README.md "dist/$name/" - # The embedded doona UI keeps its own license and notices. - mkdir "dist/$name/doona" - cp -r "$HONK_DOONA_DIR"/{LICENSE,LICENSES,NOTICE,THIRD-PARTY-NOTICES.txt} "dist/$name/doona/" + # The embedded doona UI keeps its own license and notices; lean + # variants do not embed it and carry no doona directory. + if [[ "${{ matrix.variant }}" == full ]]; then + mkdir "dist/$name/doona" + cp -r "$HONK_DOONA_DIR"/{LICENSE,LICENSES,NOTICE,THIRD-PARTY-NOTICES.txt} "dist/$name/doona/" + fi tar -czf "$name.tar.gz" -C dist "$name" - name: Start the packaged x86_64 artifact @@ -244,7 +269,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: honk-core-${{ matrix.target }}${{ matrix.suffix }} + name: honk-core-${{ matrix.target }}${{ matrix.suffix }}${{ matrix.name_suffix }} path: ${{ env.ARTIFACT_NAME }}.tar.gz retention-days: 1 diff --git a/Justfile b/Justfile index 52e9a4c7..9dcee239 100644 --- a/Justfile +++ b/Justfile @@ -17,11 +17,10 @@ build: build-core: cargo build --release -p honk-core --features "ebpf" -# Build honk-core with eBPF only -build-core-ebpf: - cargo build --release -p honk-core --features ebpf - # Build honk-core for VyOS/Debian (static musl, portable) +# The features argument adds to the crate defaults (clash-api,mimalloc,rprx), +# so `just build-musl ebpf` is the clash-api-only shape; use build-musl-native +# for the exact native-api-only feature set. # Uses zig cc/c++ as the musl toolchain (ci/zigcc, ci/zigcxx): boring-sys # (BoringSSL, C++) needs a clang-compatible compiler — under cross, CMake # injects clang-style --target flags into the ASM rules that real GCC rejects @@ -47,6 +46,18 @@ build-musl-embedded-ui: doona="${HONK_DOONA_DIR:-$(ci/fetch-doona.sh)}" HONK_DOONA_DIR="$doona" {{just_executable()}} build-musl "ebpf,native-ui" +# Native-api-only musl build (no clash-api), matching the release asset. +# Unlike build-musl, this passes --no-default-features for an exact set. +build-musl-native: + ZIGCC_TARGET=x86_64-linux-musl \ + CC_x86_64_unknown_linux_musl={{justfile_directory()}}/ci/zigcc \ + CXX_x86_64_unknown_linux_musl={{justfile_directory()}}/ci/zigcxx \ + CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER={{justfile_directory()}}/ci/zigcc \ + CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C link-self-contained=no" \ + BINDGEN_EXTRA_CLANG_ARGS="$({{justfile_directory()}}/ci/zig-bindgen-env x86_64-linux-musl)" \ + cargo build --release -p honk-core --no-default-features --features "ebpf,native-api,rprx,mimalloc" --target x86_64-unknown-linux-musl + @echo "Binary: target/x86_64-unknown-linux-musl/release/honk-core" + # Build eBPF object standalone (optional; honk-core build.rs auto-builds it) # NOTE: an environment RUSTFLAGS overrides crates/honk-ebpf/.cargo/config.toml # rustflags (--btf, debuginfo) — the object then silently loses its .BTF diff --git a/README.md b/README.md index 97117bbb..7eacb538 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The [documentation index](doc/README.md) links all bilingual guides, references, ## Opt-in native observation API -Build with `--features native-api` (release builds include it) and configure `experimental.native_api` for independent observations and controls on `127.0.0.1:9527`: bounded flows/logs/DNS history, probes, provider status/refresh, per-network Selector control and exact connection closure. Captured `.dae` sources remain authoritative, with opt-in source/Group PATCH transactions, synchronous main-file node/provider creation and removal, and verified-geodata operations; existing entries are edited through source PUT. `--store db` records accepted sources as revisions in a state database instead. A bearer secret or password login is required unless anonymous loopback is explicitly enabled. Serve a trusted directory, or build `--features native-ui` and set `ui: embedded` for the pinned doona build without runtime downloads. Native runtime_mode and full kernel transparency remain unavailable. See [native settings](doc/en/reference/experimental.md#native_api) and the [API contract](doc/en/reference/api.md#native-api). +Build with `--features native-api` (the full and `-native-api` release artifacts include it) and configure `experimental.native_api` for independent observations and controls on `127.0.0.1:9527`: bounded flows/logs/DNS history, probes, provider status/refresh, per-network Selector control and exact connection closure. Captured `.dae` sources remain authoritative, with opt-in source/Group PATCH transactions, synchronous main-file node/provider creation and removal, and verified-geodata operations; existing entries are edited through source PUT. `--store db` records accepted sources as revisions in a state database instead. A bearer secret or password login is required unless anonymous loopback is explicitly enabled. Serve a trusted directory, or build `--features native-ui` and set `ui: embedded` for the pinned doona build without runtime downloads. Native runtime_mode and full kernel transparency remain unavailable. See [native settings](doc/en/reference/experimental.md#native_api) and the [API contract](doc/en/reference/api.md#native-api). ## Development @@ -47,7 +47,7 @@ For unprivileged userspace development, use [mock mode](doc/en/how-to-start.md#u Maintainer `debug.*` tags update the rolling [Debug prerelease](https://github.com/daeuniverse/honk/releases/tag/debug), not Latest. These are release-profile binaries, not Cargo debug-profile builds. The rolling tag and assets are replaced; source tags remain, and release notes record the source commit and workflow run. Pending intermediate runs may be superseded. -Publication requires all eight expected archives to be present and nonempty. If artifacts have expired or been deleted, use **Re-run all jobs**. Publication is not transactional; a failed update may leave the tag, notes, and assets inconsistent until recovery. +Publication requires all sixteen expected archives to be present and nonempty. If artifacts have expired or been deleted, use **Re-run all jobs**. Publication is not transactional; a failed update may leave the tag, notes, and assets inconsistent until recovery. ## Review status diff --git a/README.zh.md b/README.zh.md index 0f6f880e..1da6764a 100644 --- a/README.zh.md +++ b/README.zh.md @@ -35,7 +35,7 @@ honk 是用 Rust 编写的实验性 Linux 透明代理引擎。其 eBPF 数据 ## 可选原生观测 API -以 `--features native-api` 构建(release 构建已包含)并配置 `experimental.native_api`,可在 `127.0.0.1:9527` 独立观测用户态连接与记录流、节点与组健康、出站计数、RSS/cgroup、历史、事件、结构化安全日志、DNS 与 provider 状态。支持有界探测、路由模拟、精确连接关闭与缓存失效、provider refresh、分网络 Selector 控制与临时设置。除显式启用的匿名 loopback 访问外,均要求 bearer secret 或密码登录。可托管可信目录,或以 `--features native-ui` 和 `ui: embedded` 使用固定版本的 doona,运行时不下载 UI。 +以 `--features native-api` 构建(full 与 `-native-api` 发布产物已包含)并配置 `experimental.native_api`,可在 `127.0.0.1:9527` 独立观测用户态连接与记录流、节点与组健康、出站计数、RSS/cgroup、历史、事件、结构化安全日志、DNS 与 provider 状态。支持有界探测、路由模拟、精确连接关闭与缓存失效、provider refresh、分网络 Selector 控制与临时设置。除显式启用的匿名 loopback 访问外,均要求 bearer secret 或密码登录。可托管可信目录,或以 `--features native-ui` 和 `ui: embedded` 使用固定版本的 doona,运行时不下载 UI。 `.dae` 仍是唯一配置权威。启动时捕获的源支持元数据读取、离线校验、授权源 PUT 和受限组 PATCH。主文件节点/provider 的创建与删除在实际激活后才返回成功,geodata 更新 operation 激活已验证的内容。编辑已有条目继续使用源 PUT;`--store db` 将已接受的源记录为状态数据库中的 revision。凭据源只读,返回正文时遮蔽 listener secret 值。启用原生 API 时,与 Clash 共用非持久化模式;成功的显式激活(含 no-op)重置 Rule 与设置,provider/network refresh 保留它们。原生 runtime mode、暂停/恢复与完整内核 flow 观测仍未开放。详见[原生 API 参考](doc/zh/reference/api.md#原生-api)。 @@ -49,7 +49,7 @@ honk 是用 Rust 编写的实验性 Linux 透明代理引擎。其 eBPF 数据 维护者推送 `debug.*` tag 会更新滚动的 [Debug 预发布](https://github.com/daeuniverse/honk/releases/tag/debug),而不是 Latest。这些是 release profile 二进制,并非 Cargo debug profile 构建。滚动 tag 和附件会被替换;源 tag 保留,release 说明记录源 commit 和 workflow run。等待中的中间运行可能被后续运行取代。 -发布要求八个预期归档齐全且非空。若 artifact 已过期或被删除,使用 **Re-run all jobs**。发布不是原子操作;更新失败可能使 tag、说明和附件暂时不一致,需恢复后才能重新一致。 +发布要求十六个预期归档齐全且非空。若 artifact 已过期或被删除,使用 **Re-run all jobs**。发布不是原子操作;更新失败可能使 tag、说明和附件暂时不一致,需恢复后才能重新一致。 ## Review 状态 diff --git a/crates/honk-config/conformance/manifest.toml b/crates/honk-config/conformance/manifest.toml index 8a74f115..ab9c3dcf 100644 --- a/crates/honk-config/conformance/manifest.toml +++ b/crates/honk-config/conformance/manifest.toml @@ -1609,7 +1609,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-en-how-to-start-01" -source = { file = "doc/en/how-to-start.md", lines = "168-179" } +source = { file = "doc/en/how-to-start.md", lines = "174-185" } wrap = "" layer = "structure" honk = "accept" @@ -1620,7 +1620,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-en-how-to-start-02" -source = { file = "doc/en/how-to-start.md", lines = "200-213" } +source = { file = "doc/en/how-to-start.md", lines = "206-219" } wrap = "" layer = "structure" honk = "accept" @@ -1631,7 +1631,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-en-how-to-start-03" -source = { file = "doc/en/how-to-start.md", lines = "219-219" } +source = { file = "doc/en/how-to-start.md", lines = "225-225" } wrap = "global" layer = "structure" honk = "accept" @@ -1642,7 +1642,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-en-how-to-start-04" -source = { file = "doc/en/how-to-start.md", lines = "321-330" } +source = { file = "doc/en/how-to-start.md", lines = "327-336" } wrap = "" layer = "structure" honk = "accept" @@ -1926,7 +1926,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-zh-how-to-start-01" -source = { file = "doc/zh/how-to-start.md", lines = "168-179" } +source = { file = "doc/zh/how-to-start.md", lines = "174-185" } wrap = "" layer = "structure" honk = "accept" @@ -1937,7 +1937,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-zh-how-to-start-02" -source = { file = "doc/zh/how-to-start.md", lines = "200-213" } +source = { file = "doc/zh/how-to-start.md", lines = "206-219" } wrap = "" layer = "structure" honk = "accept" @@ -1948,7 +1948,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-zh-how-to-start-03" -source = { file = "doc/zh/how-to-start.md", lines = "219-219" } +source = { file = "doc/zh/how-to-start.md", lines = "225-225" } wrap = "global" layer = "structure" honk = "accept" @@ -1959,7 +1959,7 @@ unknown_sections = 0 [[case]] id = "honk-doc-zh-how-to-start-04" -source = { file = "doc/zh/how-to-start.md", lines = "321-330" } +source = { file = "doc/zh/how-to-start.md", lines = "327-336" } wrap = "" layer = "structure" honk = "accept" diff --git a/doc/en/configuration.md b/doc/en/configuration.md index 3a113ede..c07773af 100644 --- a/doc/en/configuration.md +++ b/doc/en/configuration.md @@ -278,7 +278,7 @@ See the [subscription reference](./reference/subscription.md). ## Enabling the Clash API, cache file, and held-first-packet UDP -**Native API.** `native-api` is opt-in: build with `--features native-api` (or `native-ui`); release builds include it. The listener requires `experimental.native_api.enabled: true` and one of a bearer `secret`, `password_auth: true`, or `allow_anonymous_loopback: true` on a loopback `listen`. honk sets no minimum `secret` length; use a long random value. The default address is `127.0.0.1:9527`; explicitly anonymous loopback is for local development only. All effective native fields require restart. An optional `ui` directory needs readable `index.html`; alternatively `--features native-ui` enables `ui: embedded` with pinned real doona. Neither mode downloads/builds the UI at runtime. Traffic/memory histories default on and retain at most 600 points/600 seconds. See [native settings](./reference/experimental.md#native_api) and the [API contract](./reference/api.md#native-api). +**Native API.** `native-api` is opt-in: build with `--features native-api` (or `native-ui`); the full and `-native-api` release artifacts include it. The listener requires `experimental.native_api.enabled: true` and one of a bearer `secret`, `password_auth: true`, or `allow_anonymous_loopback: true` on a loopback `listen`. honk sets no minimum `secret` length; use a long random value. The default address is `127.0.0.1:9527`; explicitly anonymous loopback is for local development only. All effective native fields require restart. An optional `ui` directory needs readable `index.html`; alternatively `--features native-ui` enables `ui: embedded` with pinned real doona. Neither mode downloads/builds the UI at runtime. Traffic/memory histories default on and retain at most 600 points/600 seconds. See [native settings](./reference/experimental.md#native_api) and the [API contract](./reference/api.md#native-api). For a captured `.dae` startup, source metadata, offline validation and real reload operations share the existing engine. Configuration reads return accepted content with only listener-secret values masked, including duplicate/overridden values and their other occurrences; credential-bearing sources remain read-only with original-byte hashes. Source `path` remains relative and `absolute_path` adds the canonical absolute path. Admitted anonymous loopback requests read the same data as bearer-authenticated requests. `config_write` defaults false and requires a nonempty secret or `password_auth`. Main-source node/provider creation and deletion, authorized whole-source PUT and restricted Group PATCH reuse this authority; all accepted noncredential includes qualify for source edits when `config_write` is enabled, but not dedicated entry deletion. Configured geodata updates use verified immutable bytes and the same reload owner. Written bytes are not automatically rolled back after activation failure. Avoid concurrent external edits; see [configuration safety](./reference/api.md#accepted-configuration-and-reload-operations) and [entry and geodata management](./reference/api.md#managed-entries-and-geodata). diff --git a/doc/en/design/control-plane.md b/doc/en/design/control-plane.md index 224a5fc4..9e74ff59 100644 --- a/doc/en/design/control-plane.md +++ b/doc/en/design/control-plane.md @@ -315,7 +315,7 @@ Body acceptance and runtime publication are reported separately. A collection-ad ## Native observation API -The independent, opt-in `native-api` feature (build with `--features native-api` or `native-ui`; release builds include it) supplies a default-off listener that binds before control-plane admission when enabled. Its optional phase watch reports running only after admission opens, and draining before shutdown fencing. The existing health handle can refine running to degraded. Reads hold the config publication barrier through generation and health observation without changing publication lock order. HTTP availability is not datapath health. +The independent, opt-in `native-api` feature (build with `--features native-api` or `native-ui`; the full and `-native-api` release artifacts include it) supplies a default-off listener that binds before control-plane admission when enabled. Its optional phase watch reports running only after admission opens, and draining before shutdown fencing. The existing health handle can refine running to degraded. Reads hold the config publication barrier through generation and health observation without changing publication lock order. HTTP availability is not datapath health. `native_api/server.rs` owns its listener, 64-connection JoinSet, one one-second sampler and native tracker consumer through joined shutdown. Header budget is five seconds; the 30-second read-idle deadline applies only while no request is in flight on that connection (from the end of a request body until its response resolves), and stalled writes have an independent 30-second deadline, so healthy SSE and slow handlers can outlive 30 seconds. Accept errors are logged and retried, backing off 100 ms on EMFILE/ENFILE/ENOBUFS/ENOMEM; a failed connection task is logged, never fatal to the server. Shutdown has one five-second HTTP connection grace budget, followed by the actual join of any admitted blocking credential job. `crate::observe` (`observe.rs` `Observation`, flows, rules, catalog identity, `DnsRecorder`) retains process identity and bounded engine-side stores independently of clients; `native_api` holds only the HTTP projection. Without `native-api` the observation hooks compile as zero-cost inert twins. Actual TCP/UDP/DNS producer hooks capture immutable source evidence; accepted publication emits generation events under existing barriers. Per-flow completeness describes the captured execution frontier, independently of lifecycle and global coverage. Native-only final handoffs still avoid legacy rule recomputation. Traffic/memory histories share the sampler, skip missed ticks and retain at most 600 points/600 seconds; unreadable RSS/cgroup fields remain null. Backend-owned datapath observations are partial, never full kernel transparency or kernel-memory accounting. diff --git a/doc/en/design/overview.md b/doc/en/design/overview.md index d2f7d636..d1a05165 100644 --- a/doc/en/design/overview.md +++ b/doc/en/design/overview.md @@ -64,7 +64,7 @@ Shared configuration schema/parsers. Pure-Rust deps: serde, regex, url, base64, - `src/share_link.rs` is the sole `Node::from_share_link` parser. `src/share_link/options.rs` maps URI packet encoding and independent mux controls into the canonical protocol model, then normalization/validation precedes identity derivation. It does not retain a second VLESS mode model. - `src/node/wire.rs` is the sole flat serde adapter. It rejects the removed VLESS legacy field by raw presence, including `null`; the same field on non-VLESS input remains only a compatibility artifact. `VlessConfig.network`, `udp_encoding`, and `multiplex` determine identity, so a canonical cutover can change a VLESS `Node.id` without changing VMess behavior or identity. - Canonical VLESS behavior is summarized in [Outbound design](./outbound.md#vless-wire-contracts); field-level syntax and URI values belong in the [node reference](../reference/nodes.md). -- `src/experimental.rs`: `ExperimentalConfig` owns `clash_api`, `native_api`, and `cache_file`. Native settings are strict, independent and require a restart. Opt-in `native-api` (build with `--features native-api` or `native-ui`; release builds include it) provides userspace observations, bounded histories, source-owned Group PATCH and main-entry administration, plus verified-geodata activation. Its listener is disabled by default. `.dae` remains authoritative. Per-network automatic-policy pin/clear is enabled; pins belong to the current GroupManager and disappear on activation. Credential-bearing sources are read-only. Returned content masks listener-secret values rather than omitting bodies. Native mode and full kernel transparency stay gated. Default-off `native-ui` embeds licensed pinned doona assets obtained at packaging time through `ci/fetch-doona.sh` and `.github/ci/pins.env`. `build.rs` reads the absolute `HONK_DOONA_DIR`, with no runtime fetching or frontend build. The dae parser explicitly whitelists the nested sections. It accepts the deprecated `udp_nfqueue` section only as a migration input and warns; `enabled` is copied to `GlobalConfig::nfqueue_enable` only when `global.nfqueue_enable` is absent. +- `src/experimental.rs`: `ExperimentalConfig` owns `clash_api`, `native_api`, and `cache_file`. Native settings are strict, independent and require a restart. Opt-in `native-api` (build with `--features native-api` or `native-ui`; the full and `-native-api` release artifacts include it) provides userspace observations, bounded histories, source-owned Group PATCH and main-entry administration, plus verified-geodata activation. Its listener is disabled by default. `.dae` remains authoritative. Per-network automatic-policy pin/clear is enabled; pins belong to the current GroupManager and disappear on activation. Credential-bearing sources are read-only. Returned content masks listener-secret values rather than omitting bodies. Native mode and full kernel transparency stay gated. Default-off `native-ui` embeds licensed pinned doona assets obtained at packaging time through `ci/fetch-doona.sh` and `.github/ci/pins.env`. `build.rs` reads the absolute `HONK_DOONA_DIR`, with no runtime fetching or frontend build. The dae parser explicitly whitelists the nested sections. It accepts the deprecated `udp_nfqueue` section only as a migration input and warns; `enabled` is copied to `GlobalConfig::nfqueue_enable` only when `global.nfqueue_enable` is absent. - `src/subscription.rs`, `src/types.rs` (`NodeProtocol` 11 variants (Direct/Block reserved for the built-ins), `DialMode` ip/domain/domain+/domain++, `SubscriptionType`, `DnsProtocol`, plus the shared `default_true`/`parse_duration_secs` helpers), `src/error.rs` (`ConfigError`). ## High-level data path diff --git a/doc/en/how-to-start.md b/doc/en/how-to-start.md index c0752a5c..20598991 100644 --- a/doc/en/how-to-start.md +++ b/doc/en/how-to-start.md @@ -88,16 +88,22 @@ bpf /sys/fs/bpf bpf defaults 0 0 ### Prebuilt binaries -Download the package matching the device architecture from [GitHub Releases](https://github.com/daeuniverse/honk/releases): +Download the package matching the device architecture from [GitHub Releases](https://github.com/daeuniverse/honk/releases). The unsuffixed name is the full build: -- `x86_64-unknown-linux-musl` -- `aarch64-unknown-linux-musl` +| Variant | Package suffix | Contents | +|---|---|---| +| full | none | Clash API, native API and the embedded doona UI (`x86_64`/`aarch64`, gnu and musl) | +| clash-api | `-clash-api` | Clash API only; no native API and no embedded UI (musl only) | +| native-api | `-native-api` | Native API only; no Clash API and no embedded UI (musl only) | The musl packages are static binaries intended for gateways. Packages without the `-stock` suffix use mimalloc for throughput; `-stock` packages use the system allocator and suit small devices where the RSS high-water mark matters more. +The lean variants fail closed: enabling `experimental.native_api` on `-clash-api`, or `ui: embedded` without `native-ui`, fails startup. `--store db` and native configuration administration require `native-api`. + ```shell -tar -xzf honk-core--.tar.gz -sudo install -m 0755 honk-core--/honk-core /usr/local/bin/honk-core +pkg=honk-core-- # append -stock, -clash-api or -native-api as downloaded +tar -xzf "$pkg.tar.gz" +sudo install -m 0755 "$pkg/honk-core" /usr/local/bin/honk-core honk-core --version ``` diff --git a/doc/en/reference/api.md b/doc/en/reference/api.md index cc0cbd98..171180d1 100644 --- a/doc/en/reference/api.md +++ b/doc/en/reference/api.md @@ -4,7 +4,7 @@ honk provides a native HTTP API, a Clash-compatible HTTP API and a userspace sta ## Native API -The `native-api` Cargo feature is opt-in: build with `--features native-api` (or `native-ui`); both release allocator variants include it together with the embedded UI (`native-ui`). The listener remains disabled until [`experimental.native_api`](./experimental.md#native_api) is enabled. `--no-default-features --features native-api` works without Clash. `.dae` remains the configuration format. Source administration edits the `-c` files, or with `--store db` records revisions in a SQLite configuration db ([Configuration db](#configuration-db---store-db)). +The `native-api` Cargo feature is opt-in: build with `--features native-api` (or `native-ui`); the full release artifacts include it together with the embedded UI (`native-ui`), the `-native-api` artifacts include it without Clash or the UI, and the `-clash-api` artifacts omit it. The listener remains disabled until [`experimental.native_api`](./experimental.md#native_api) is enabled. `--no-default-features --features native-api` works without Clash. `.dae` remains the configuration format. Source administration edits the `-c` files, or with `--store db` records revisions in a SQLite configuration db ([Configuration db](#configuration-db---store-db)). The native contract, including authentication, node/provider management, geodata and automatic-policy overrides, is [api-standardize e6b0dbab5599689d965bc18a71be67c809d99d0f](https://github.com/daeuniverse/api-standardize/tree/e6b0dbab5599689d965bc18a71be67c809d99d0f); `crates/honk-core/tests/fixtures/native_api_openapi.yaml` tracks this bundle. Native runtime mode remains gated, and `full_transparency` is not advertised. Source administration requires a captured `.dae` startup; writes additionally require `config_write` and either a nonempty secret or `password_auth`. Discover current capabilities and source permissions rather than inferring availability from route names. @@ -84,7 +84,7 @@ HTTP transport boundary: Hyper can reject malformed or hard-limit HTTP with 400/ Application target/header budgets apply to Hyper's parsed, normalized representation, not the original wire bytes. Hyper may remove a request-target fragment or coalesce equal `Content-Length` fields before application counting; oversized original text in those forms can therefore reach a normal response instead of 413. Raw input remains subject to Hyper's transport handling. This is an accepted boundary difference, not a second HTTP parser or a raw-wire size guarantee; body limits still cover all delivered body bytes. -With `ui` configured, `/` and `/ui` redirect to `/ui/`. Directory hosting retains extensionless SPA fallback; missing static assets, fonts/icons, manifest or service worker return 404, never HTML. Build with `--features native-ui` (release builds do) and set `ui: embedded` to serve the pinned real doona distribution without filesystem extraction or network access. Its hash router uses `/ui/#/...`; other safe embedded navigation paths redirect to `/ui/` so relative assets and the service worker resolve correctly. The embedded UI is stored precompressed and served as brotli or gzip when the browser accepts it; directory hosting serves the administrator's `.br`/`.gz` siblings the same way. Content-hashed files under `assets/` are cached as immutable for a year; other static responses use `no-cache`. Static responses use `nosniff` and carry no framing header, so dashboards such as LuCI can embed the UI; a deployment that needs clickjacking protection adds `X-Frame-Options` or `Content-Security-Policy: frame-ancestors` at its reverse proxy. Assets remain public behind Host/Origin admission. Discovery and password setup/login use the public exceptions above; other API requests require a bearer. No credentials are injected into the UI. +With `ui` configured, `/` and `/ui` redirect to `/ui/`. Directory hosting retains extensionless SPA fallback; missing static assets, fonts/icons, manifest or service worker return 404, never HTML. Build with `--features native-ui` (the full release builds do) and set `ui: embedded` to serve the pinned real doona distribution without filesystem extraction or network access. Its hash router uses `/ui/#/...`; other safe embedded navigation paths redirect to `/ui/` so relative assets and the service worker resolve correctly. The embedded UI is stored precompressed and served as brotli or gzip when the browser accepts it; directory hosting serves the administrator's `.br`/`.gz` siblings the same way. Content-hashed files under `assets/` are cached as immutable for a year; other static responses use `no-cache`. Static responses use `nosniff` and carry no framing header, so dashboards such as LuCI can embed the UI; a deployment that needs clickjacking protection adds `X-Frame-Options` or `Content-Security-Policy: frame-ancestors` at its reverse proxy. Assets remain public behind Host/Origin admission. Discovery and password setup/login use the public exceptions above; other API requests require a bearer. No credentials are injected into the UI. ### Authentication discovery and password sessions @@ -335,7 +335,7 @@ Automatic updates are on by default, every 24 hours; `auto_update.enabled: false ### Embedded doona provenance -Default-off `native-ui` implies `native-api` and embeds the doona build that Cargo reads at compile time from the absolute directory in `HONK_DOONA_DIR`; without it the build fails. `ci/fetch-doona.sh` downloads the release pinned in `.github/ci/pins.env` (currently doona `0.1.0-beta.20`, commit `6acdabdc7cef8e452cf8de96b630fad6a7a85caf`), checks its SHA-256 and that it carries `THIRD-PARTY-NOTICES.txt` and every `LICENSES/` file its `NOTICE` names, drops any fonts and prints the directory: `export HONK_DOONA_DIR=$(ci/fetch-doona.sh)`. `just lint` and `just test-ci` run it when the variable is unset. Release builds include the embedded UI. The binary embeds the notices shipped in doona's program archive, and every release tarball carries them under `doona/`. The Noto Sans TC and SC fonts are not embedded. doona's CSS declares those fonts with `font-display: optional`, so the browser falls back to system fonts when the font requests return 404. To use Noto Sans, extract `doona-.tar.gz` and `doona-fonts-.tar.gz` from the [doona release](https://github.com/Zakkaus/doona/releases) into one directory and point `ui` at it, or install the `doona` and `doona-fonts` packages and set `ui: /usr/share/doona`. The corresponding GPL-3.0-only source is the doona tag [`v0.1.0-beta.20`](https://github.com/Zakkaus/doona/tree/v0.1.0-beta.20). The release workflow attaches `doona-source-0.1.0-beta.20.tar.gz` to the tag release and to the rolling Debug release; `ci/fetch-doona.sh --source` checks that the tag still points at the pinned commit and generates it with `git archive --format=tar --prefix=doona/ v0.1.0-beta.20 | gzip -n` (GNU gzip). Whoever redistributes a `native-ui` binary must provide that source archive and the notices with it (GPL-3.0 section 6). +Default-off `native-ui` implies `native-api` and embeds the doona build that Cargo reads at compile time from the absolute directory in `HONK_DOONA_DIR`; without it the build fails. `ci/fetch-doona.sh` downloads the release pinned in `.github/ci/pins.env` (currently doona `0.1.0-beta.20`, commit `6acdabdc7cef8e452cf8de96b630fad6a7a85caf`), checks its SHA-256 and that it carries `THIRD-PARTY-NOTICES.txt` and every `LICENSES/` file its `NOTICE` names, drops any fonts and prints the directory: `export HONK_DOONA_DIR=$(ci/fetch-doona.sh)`. `just lint` and `just test-ci` run it when the variable is unset. Full release builds include the embedded UI; the lean `-clash-api` and `-native-api` artifacts do not. The binary embeds the notices shipped in doona's program archive, and every full release tarball carries them under `doona/`. The Noto Sans TC and SC fonts are not embedded. doona's CSS declares those fonts with `font-display: optional`, so the browser falls back to system fonts when the font requests return 404. To use Noto Sans, extract `doona-.tar.gz` and `doona-fonts-.tar.gz` from the [doona release](https://github.com/Zakkaus/doona/releases) into one directory and point `ui` at it, or install the `doona` and `doona-fonts` packages and set `ui: /usr/share/doona`. The corresponding GPL-3.0-only source is the doona tag [`v0.1.0-beta.20`](https://github.com/Zakkaus/doona/tree/v0.1.0-beta.20). The release workflow attaches `doona-source-0.1.0-beta.20.tar.gz` to the tag release and to the rolling Debug release; `ci/fetch-doona.sh --source` checks that the tag still points at the pinned commit and generates it with `git archive --format=tar --prefix=doona/ v0.1.0-beta.20 | gzip -n` (GNU gzip). Whoever redistributes a `native-ui` binary must provide that source archive and the notices with it (GPL-3.0 section 6). To reproduce the assets, extract the source archive into its own directory, use Node 22+ and `pnpm@11.15.1`, then run `pnpm install --frozen-lockfile`, `pnpm build` and `SOURCE_DATE_EPOCH=1791741741 pnpm package`. The epoch is the pinned upstream commit's timestamp; the source archive has no Git history. Use GNU tar and GNU gzip on `PATH` (verified with tar 1.35 and gzip 1.15); another gzip implementation can produce different archive hashes from identical tar bytes. Cargo builds embed only the files in `HONK_DOONA_DIR` and never build or download the frontend. That source's checker is `tools/conformance.mjs`; its live walk is read-only and skips controls, diagnostics and missing observed IDs. Check base and management contracts, and exercise browser actions separately: schema passes alone are not full UI, kernel or platform acceptance. diff --git a/doc/en/reference/experimental.md b/doc/en/reference/experimental.md index 33b46bcd..546f6c2a 100644 --- a/doc/en/reference/experimental.md +++ b/doc/en/reference/experimental.md @@ -14,7 +14,7 @@ ## `native_api` -Requires the opt-in `native-api` Cargo feature (build with `--features native-api` or `native-ui`; release builds include it). It does not require `clash-api`, and the listener is disabled by default. Enabling it without that feature fails startup. All effective fields require restart: SIGHUP rejects changes and preserves the active listener and configuration generation. Unknown fields, nested scalar blocks, malformed booleans, and empty security-list members are errors. +Requires the opt-in `native-api` Cargo feature (build with `--features native-api` or `native-ui`; the full and `-native-api` release artifacts include it). It does not require `clash-api`, and the listener is disabled by default. Enabling it without that feature fails startup. All effective fields require restart: SIGHUP rejects changes and preserves the active listener and configuration generation. Unknown fields, nested scalar blocks, malformed booleans, and empty security-list members are errors. | Field | Default | Meaning | | --- | --- | --- | @@ -61,7 +61,7 @@ Lists use individually quoted comma-separated entries, such as `allow_origins: ' Relative UI paths follow the existing dependency search: an existing path under `global.data_dir`, then `/var/share/honk`, then the working directory; a missing dependency resolves under `global.data_dir` and startup fails. The administrator owns the directory and any symlink targets. See the [native API contract](./api.md#native-api). -For a single binary, use a release build or `HONK_DOONA_DIR=$(ci/fetch-doona.sh) cargo build -p honk-core --features native-ui`, and set `ui: embedded`; `native-ui` includes `native-api` without requiring Clash. Without `native-ui`, enabled embedded hosting fails startup. The assets receive no injected credentials; clients use public discovery to select static-token entry or password setup/login. Asset/source identities, corresponding-source distribution and the management contract are documented in the [API reference](./api.md#embedded-doona-provenance). +For a single binary, use a full release build or `HONK_DOONA_DIR=$(ci/fetch-doona.sh) cargo build -p honk-core --features native-ui`, and set `ui: embedded`; `native-ui` includes `native-api` without requiring Clash. Without `native-ui`, enabled embedded hosting fails startup. The assets receive no injected credentials; clients use public discovery to select static-token entry or password setup/login. Asset/source identities, corresponding-source distribution and the management contract are documented in the [API reference](./api.md#embedded-doona-provenance). File-configured geodata sources are administrator-controlled, restart-required and cannot be changed through source writes. With a state db, downloads can also use authenticated URL overrides or built-in sources. Userinfo, fragments, redirects and content encoding are rejected. Direct hostname sources require `global.bootstrap_resolver`; no system-DNS fallback is used. `assets.geodata.route` or the stored route can send downloads through the routing rules or a group instead, and a route that cannot carry a request never falls back to direct. Updates use the applicable configured, stored or built-in sources. The [management contract](./api.md#managed-entries-and-geodata) distinguishes network limits, verified-byte activation and partial durable replacement from rollback. diff --git a/doc/zh/configuration.md b/doc/zh/configuration.md index 1bdaba26..be4e24a1 100644 --- a/doc/zh/configuration.md +++ b/doc/zh/configuration.md @@ -282,7 +282,7 @@ dns { ## 启用 Clash API、缓存文件与首包保留 UDP -**原生 API。** `native-api` 需显式编译:以 `--features native-api`(或 `native-ui`)构建;发布产物包含它。listener 须配置 `experimental.native_api.enabled: true`,并满足以下条件之一:配置 bearer `secret`、设置 `password_auth: true`,或在 loopback `listen` 上设置 `allow_anonymous_loopback: true`。honk 不限制 `secret` 的最短长度,应使用足够长的随机值。默认监听地址为 `127.0.0.1:9527`,匿名 loopback 访问仅供本地开发。所有生效的原生字段均需重启。用户态观测、事件与有界历史独立于 Clash;流量/内存历史默认保留最多 600 点/600 秒。可选 `ui` 目录需已有可读 `index.html`,也可用 `--features native-ui` 与 `ui: embedded` 内嵌固定版本的 doona;运行时不下载或构建 UI。 +**原生 API。** `native-api` 需显式编译:以 `--features native-api`(或 `native-ui`)构建;full 与 `-native-api` 发布产物包含它。listener 须配置 `experimental.native_api.enabled: true`,并满足以下条件之一:配置 bearer `secret`、设置 `password_auth: true`,或在 loopback `listen` 上设置 `allow_anonymous_loopback: true`。honk 不限制 `secret` 的最短长度,应使用足够长的随机值。默认监听地址为 `127.0.0.1:9527`,匿名 loopback 访问仅供本地开发。所有生效的原生字段均需重启。用户态观测、事件与有界历史独立于 Clash;流量/内存历史默认保留最多 600 点/600 秒。可选 `ui` 目录需已有可读 `index.html`,也可用 `--features native-ui` 与 `ui: embedded` 内嵌固定版本的 doona;运行时不下载或构建 UI。 `.dae` 仍是唯一配置权威。启动时捕获来源、离线校验和 reload 共用引擎。配置读取返回已接受正文,仅遮蔽监听凭据值,包括重复、被覆盖的值及其在其他位置的出现。凭据源仍只读,哈希仍对应原始字节。源 `path` 保持相对路径,`absolute_path` 另行提供规范化绝对路径。获准访问的匿名 loopback 请求与 bearer 认证请求读取相同的数据。`config_write` 默认 false,要求非空 secret 或 `password_auth`。主文件节点/provider 创建删除、授权源 PUT 和受限组 PATCH 复用该权威。启用 `config_write` 后,所有已接受的非凭据 include 均可编辑源,但不授予专用条目删除权限。配置的 geodata 更新将不可变的已验证字节交给同一 reload owner。激活失败不会自动回滚已写字节,应避免并发外部编辑。详见[原生设置](./reference/experimental.md#native_api)与 [主文件条目与 geodata 契约](./reference/api.md#主文件条目与-geodata-管理)。 diff --git a/doc/zh/design/control-plane.md b/doc/zh/design/control-plane.md index b1c61015..cae3d443 100644 --- a/doc/zh/design/control-plane.md +++ b/doc/zh/design/control-plane.md @@ -302,7 +302,7 @@ UI 与 geodata 的生效设置包含从 `assets.route` 继承的值;该默认 ## 原生观测 API -独立且需显式编译的 `native-api` feature(以 `--features native-api` 或 `native-ui` 构建;发布产物包含)提供默认关闭的 listener,启用后在控制面准入前绑定。按需 phase watch 仅在真实 admission-open 成功后报告 running,在关闭栅栏前报告 draining;现有 health handle 可将 running 细化为 degraded。读取 generation 与 health 期间保留 config 发布屏障,不改变发布锁序。HTTP 可用不代表数据面健康。 +独立且需显式编译的 `native-api` feature(以 `--features native-api` 或 `native-ui` 构建;full 与 `-native-api` 发布产物包含)提供默认关闭的 listener,启用后在控制面准入前绑定。按需 phase watch 仅在真实 admission-open 成功后报告 running,在关闭栅栏前报告 draining;现有 health handle 可将 running 细化为 degraded。读取 generation 与 health 期间保留 config 发布屏障,不改变发布锁序。HTTP 可用不代表数据面健康。 `native_api/server.rs` 完整持有 listener、64 连接 JoinSet、唯一一秒 sampler 与 native tracker consumer,直到关闭 join。Header 预算五秒,30 秒读空闲期限仅在该连接没有进行中请求时生效(请求自 body 结束至响应完成视为进行中),停滞写入另有独立 30 秒期限,健康 SSE 与慢 handler 可持续超过 30 秒;accept 错误记录日志后重试,EMFILE/ENFILE/ENOBUFS/ENOMEM 退避 100 ms;连接任务失败只记录日志,不终止 server;HTTP 关闭共享五秒 grace,随后等待已准入的真实阻塞凭据任务结束。`crate::observe`(`observe.rs` 的 `Observation`、flows、rules、catalog 身份、`DnsRecorder`)拥有进程身份与引擎侧有界存储,独立于客户端;`native_api` 只负责 HTTP 投影。未启用 `native-api` 时观测 hook 编译为零开销 inert 替身。TCP/UDP/DNS producer 在真实执行点捕获不可变来源证据,已接受发布在既有屏障下发出 generation 事件。逐 flow 完整性描述已捕获的执行进度,独立于生命周期与总体覆盖;native-only final handoff 不重复生成旧选路证据,不宣称完整内核透明观测。日志直接捕获审查过的结构化安全字段,不转发 Clash 格式化输出;`/events` 与 `/logs` 续传均为 ready → replay → live。 diff --git a/doc/zh/design/overview.md b/doc/zh/design/overview.md index 32d11e1a..85046952 100644 --- a/doc/zh/design/overview.md +++ b/doc/zh/design/overview.md @@ -75,7 +75,7 @@ flowchart LR - `src/experimental.rs` — `ExperimentalConfig` { `clash_api: ClashApiConfig`, `cache_file: CacheFileConfig` }。dae parser 显式允许当前两个嵌套节,旧 `udp_nfqueue` 仅作为迁移输入:发出告警,仅在未配置 `global.nfqueue_enable` 时将 `enabled` 复制到 `GlobalConfig::nfqueue_enable`。 - `src/subscription.rs`、`src/types.rs`(`NodeProtocol` 有 11 个变体,Direct/Block 留给内建节点;`DialMode` 为 ip/domain/domain+/domain++;另有 `SubscriptionType`、`DnsProtocol` 与共享 `default_true`/`parse_duration_secs` helper)、`src/error.rs`(`ConfigError`)。 -`src/experimental.rs` 的 `ExperimentalConfig` 持有 `clash_api`、`native_api` 与 `cache_file`。原生设置严格校验、独立启用且均需重启。需显式编译的 `native-api`(以 `--features native-api` 或 `native-ui` 构建;发布产物包含)提供用户态观测、有界历史、由源文件管理的组 PATCH/主文件条目管理,以及已验证 geodata 激活;listener 仍默认关闭。`.dae` 仍是唯一配置权威,原文披露与写入权限独立。凭据源只读,返回正文时遮蔽 listener secret 值,而非省略正文。自动策略已支持按网络 pin/clear 成员,pin 属于当前 GroupManager,激活后失效;原生 mode 与完整内核透明仍未开放。默认关闭的 `native-ui` 在打包时通过 `ci/fetch-doona.sh` 与 `.github/ci/pins.env` 获取带许可及版本记录的 doona 发行资产。`build.rs` 读取绝对路径 `HONK_DOONA_DIR`,不在运行时获取资产或构建前端。弃用的 `udp_nfqueue` 块仅将 `enabled` 迁移到 `GlobalConfig::nfqueue_enable` 并告警。 +`src/experimental.rs` 的 `ExperimentalConfig` 持有 `clash_api`、`native_api` 与 `cache_file`。原生设置严格校验、独立启用且均需重启。需显式编译的 `native-api`(以 `--features native-api` 或 `native-ui` 构建;full 与 `-native-api` 发布产物包含)提供用户态观测、有界历史、由源文件管理的组 PATCH/主文件条目管理,以及已验证 geodata 激活;listener 仍默认关闭。`.dae` 仍是唯一配置权威,原文披露与写入权限独立。凭据源只读,返回正文时遮蔽 listener secret 值,而非省略正文。自动策略已支持按网络 pin/clear 成员,pin 属于当前 GroupManager,激活后失效;原生 mode 与完整内核透明仍未开放。默认关闭的 `native-ui` 在打包时通过 `ci/fetch-doona.sh` 与 `.github/ci/pins.env` 获取带许可及版本记录的 doona 发行资产。`build.rs` 读取绝对路径 `HONK_DOONA_DIR`,不在运行时获取资产或构建前端。弃用的 `udp_nfqueue` 块仅将 `enabled` 迁移到 `GlobalConfig::nfqueue_enable` 并告警。 ## 高层数据路径 diff --git a/doc/zh/how-to-start.md b/doc/zh/how-to-start.md index d4b18d4f..8ff1cd5f 100644 --- a/doc/zh/how-to-start.md +++ b/doc/zh/how-to-start.md @@ -88,16 +88,22 @@ bpf /sys/fs/bpf bpf defaults 0 0 ### 预编译二进制 -从 [GitHub Releases](https://github.com/daeuniverse/honk/releases) 下载与设备架构匹配的包: +从 [GitHub Releases](https://github.com/daeuniverse/honk/releases) 下载与设备架构匹配的包。无后缀名为 full 构建: -- `x86_64-unknown-linux-musl` -- `aarch64-unknown-linux-musl` +| 变体 | 包后缀 | 内容 | +|---|---|---| +| full | 无 | Clash API、原生 API 与内嵌 doona UI(`x86_64`/`aarch64`,gnu 与 musl) | +| clash-api | `-clash-api` | 仅 Clash API;不含原生 API 与内嵌 UI(仅 musl) | +| native-api | `-native-api` | 仅原生 API;不含 Clash API 与内嵌 UI(仅 musl) | musl 包是静态二进制,适合网关部署。无 `-stock` 后缀的包使用 mimalloc,优先考虑吞吐;`-stock` 包使用系统 allocator,更适合关注内存峰值的小内存设备。 +精简变体按 fail-closed 处理:在 `-clash-api` 上启用 `experimental.native_api`,或没有 `native-ui` 却设置 `ui: embedded`,都会启动失败。`--store db` 与原生配置管理需要 `native-api`。 + ```shell -tar -xzf honk-core--.tar.gz -sudo install -m 0755 honk-core--/honk-core /usr/local/bin/honk-core +pkg=honk-core-- # 按下载的包追加 -stock、-clash-api 或 -native-api +tar -xzf "$pkg.tar.gz" +sudo install -m 0755 "$pkg/honk-core" /usr/local/bin/honk-core honk-core --version ``` diff --git a/doc/zh/reference/api.md b/doc/zh/reference/api.md index acba98ac..5b8f0bfe 100644 --- a/doc/zh/reference/api.md +++ b/doc/zh/reference/api.md @@ -4,7 +4,7 @@ ## 原生 API -`native-api` Cargo feature 需显式启用:以 `--features native-api`(或 `native-ui`)构建;两种 allocator 发布产物均包含它及内嵌 UI(`native-ui`)。listener 默认关闭,须显式启用 [`experimental.native_api`](./experimental.md#native_api)。`--no-default-features --features native-api` 可脱离 Clash 使用。`.dae` 仍是配置格式;显式授权后可读取与替换已接受的源文件,或以 `--store db` 把 revision 记录在 SQLite 配置数据库中(见[配置数据库](#配置数据库--store-db))。 +`native-api` Cargo feature 需显式启用:以 `--features native-api`(或 `native-ui`)构建;full 发布产物包含它及内嵌 UI(`native-ui`),`-native-api` 产物包含它但不含 Clash 与 UI,`-clash-api` 产物不含它。listener 默认关闭,须显式启用 [`experimental.native_api`](./experimental.md#native_api)。`--no-default-features --features native-api` 可脱离 Clash 使用。`.dae` 仍是配置格式;显式授权后可读取与替换已接受的源文件,或以 `--store db` 把 revision 记录在 SQLite 配置数据库中(见[配置数据库](#配置数据库--store-db))。 原生契约(包括认证、节点/provider 管理、geodata 与自动策略 override)为 [api-standardize e6b0dbab5599689d965bc18a71be67c809d99d0f](https://github.com/daeuniverse/api-standardize/tree/e6b0dbab5599689d965bc18a71be67c809d99d0f);`crates/honk-core/tests/fixtures/native_api_openapi.yaml` 跟踪该 bundle。原生 runtime mode 仍未开放,不声明 `full_transparency`。源管理要求真实 `.dae` 启动,写入还需启用 `config_write` 并配置非空 secret 或 `password_auth`。可用功能以 capabilities 和逐源权限为准,不按路由名称推断。 @@ -85,7 +85,7 @@ TCP 在 copy 成功读取或 splice 成功写入目标 socket 时实时入账, 应用 target/header 上限作用于 Hyper **解析并规范化后的表示**,不是原始 wire 字节。Hyper 可能先移除 request-target fragment,或合并相同 `Content-Length` 字段,再交给应用计量;这些形式的原始文本即使超过应用上限,也可能得到正常响应而不是 413。原始输入仍受 Hyper 传输处理约束。这是已接受的边界差异,不另写 HTTP parser,也不宣称原始 wire 大小保证;body 限制仍覆盖全部交付的 body 字节。 -配置 `ui` 后,`/` 与 `/ui` 重定向到 `/ui/`。目录托管保留无扩展名 SPA fallback;缺失静态资产、fonts/icons、manifest 或 service worker 返回 404,不返回 HTML。以 `--features native-ui` 构建(发布产物已启用)并设置 `ui: embedded`,即可直接提供固定真实 doona 产物,不解压到磁盘、不联网。其 hash router 使用 `/ui/#/...`;其他合法内嵌导航路径重定向回 `/ui/`,确保相对资产与 service worker 路径正确。内嵌 UI 以预压缩形式存储,浏览器接受时以 brotli 或 gzip 传输;目录托管以同样方式提供管理员放置的 `.br`/`.gz` 同名文件。`assets/` 下带内容哈希的文件按 immutable 缓存一年,其他静态响应使用 `no-cache`。静态响应带 `nosniff`,不带 framing header,以便 LuCI 等面板嵌入 UI;需要防御 clickjacking 的部署应在反向代理添加 `X-Frame-Options` 或 `Content-Security-Policy: frame-ancestors`。公开资产仍经过 Host/Origin 校验。Discovery 与密码 setup/login 使用上述公共例外,其他 API 请求要求 bearer;不向 UI 注入凭据。 +配置 `ui` 后,`/` 与 `/ui` 重定向到 `/ui/`。目录托管保留无扩展名 SPA fallback;缺失静态资产、fonts/icons、manifest 或 service worker 返回 404,不返回 HTML。以 `--features native-ui` 构建(full 发布产物已启用)并设置 `ui: embedded`,即可直接提供固定真实 doona 产物,不解压到磁盘、不联网。其 hash router 使用 `/ui/#/...`;其他合法内嵌导航路径重定向回 `/ui/`,确保相对资产与 service worker 路径正确。内嵌 UI 以预压缩形式存储,浏览器接受时以 brotli 或 gzip 传输;目录托管以同样方式提供管理员放置的 `.br`/`.gz` 同名文件。`assets/` 下带内容哈希的文件按 immutable 缓存一年,其他静态响应使用 `no-cache`。静态响应带 `nosniff`,不带 framing header,以便 LuCI 等面板嵌入 UI;需要防御 clickjacking 的部署应在反向代理添加 `X-Frame-Options` 或 `Content-Security-Policy: frame-ancestors`。公开资产仍经过 Host/Origin 校验。Discovery 与密码 setup/login 使用上述公共例外,其他 API 请求要求 bearer;不向 UI 注入凭据。 ### 认证发现与密码会话 @@ -352,7 +352,7 @@ DELETE 不接受 body/query:带有任一项时返回 `400 invalid_request`,b ### 内嵌 doona 来源 -默认关闭的 `native-ui` 隐含 `native-api`,编译时从 `HONK_DOONA_DIR` 指定的绝对路径目录读取 doona 构建产物并内嵌;未设置该变量时构建失败。`ci/fetch-doona.sh` 下载 `.github/ci/pins.env` 固定的发布包(当前为 doona `0.1.0-beta.20`、提交 `6acdabdc7cef8e452cf8de96b630fad6a7a85caf`),校验 SHA-256,确认包内含 `THIRD-PARTY-NOTICES.txt` 及 `NOTICE` 引用的全部 `LICENSES/` 文件,删除字体并输出目录:`export HONK_DOONA_DIR=$(ci/fetch-doona.sh)`。未设置该变量时,`just lint` 与 `just test-ci` 自动执行该脚本。发布产物包含内嵌 UI;二进制内嵌 doona 程序包自带的 notices,每个发布 tarball 也在 `doona/` 目录附带这些文件。内嵌产物不含 Noto Sans TC 与 SC 字体。doona 的 CSS 以 `font-display: optional` 声明这些字体,因此字体请求返回 404 时浏览器使用系统字体。需要 Noto Sans 时,将 [doona 发布页](https://github.com/Zakkaus/doona/releases)的 `doona-.tar.gz` 与 `doona-fonts-.tar.gz` 解压到同一目录并让 `ui` 指向该目录,或安装 `doona` 与 `doona-fonts` 软件包并设置 `ui: /usr/share/doona`。对应的 GPL-3.0-only 源码是 doona 标签 [`v0.1.0-beta.20`](https://github.com/Zakkaus/doona/tree/v0.1.0-beta.20)。发布流程将 `doona-source-0.1.0-beta.20.tar.gz` 附加到正式标签发布与滚动 Debug 发布;该包由 `ci/fetch-doona.sh --source` 生成:先确认标签仍指向固定提交,再执行 `git archive --format=tar --prefix=doona/ v0.1.0-beta.20 | gzip -n`(GNU gzip)。再分发 `native-ui` 二进制时,须按 GPL-3.0 第 6 条一并提供该源码包与 notices。 +默认关闭的 `native-ui` 隐含 `native-api`,编译时从 `HONK_DOONA_DIR` 指定的绝对路径目录读取 doona 构建产物并内嵌;未设置该变量时构建失败。`ci/fetch-doona.sh` 下载 `.github/ci/pins.env` 固定的发布包(当前为 doona `0.1.0-beta.20`、提交 `6acdabdc7cef8e452cf8de96b630fad6a7a85caf`),校验 SHA-256,确认包内含 `THIRD-PARTY-NOTICES.txt` 及 `NOTICE` 引用的全部 `LICENSES/` 文件,删除字体并输出目录:`export HONK_DOONA_DIR=$(ci/fetch-doona.sh)`。未设置该变量时,`just lint` 与 `just test-ci` 自动执行该脚本。full 发布产物包含内嵌 UI,精简的 `-clash-api`/`-native-api` 产物不包含;二进制内嵌 doona 程序包自带的 notices,每个 full 发布 tarball 也在 `doona/` 目录附带这些文件。内嵌产物不含 Noto Sans TC 与 SC 字体。doona 的 CSS 以 `font-display: optional` 声明这些字体,因此字体请求返回 404 时浏览器使用系统字体。需要 Noto Sans 时,将 [doona 发布页](https://github.com/Zakkaus/doona/releases)的 `doona-.tar.gz` 与 `doona-fonts-.tar.gz` 解压到同一目录并让 `ui` 指向该目录,或安装 `doona` 与 `doona-fonts` 软件包并设置 `ui: /usr/share/doona`。对应的 GPL-3.0-only 源码是 doona 标签 [`v0.1.0-beta.20`](https://github.com/Zakkaus/doona/tree/v0.1.0-beta.20)。发布流程将 `doona-source-0.1.0-beta.20.tar.gz` 附加到正式标签发布与滚动 Debug 发布;该包由 `ci/fetch-doona.sh --source` 生成:先确认标签仍指向固定提交,再执行 `git archive --format=tar --prefix=doona/ v0.1.0-beta.20 | gzip -n`(GNU gzip)。再分发 `native-ui` 二进制时,须按 GPL-3.0 第 6 条一并提供该源码包与 notices。 复现时将源码包解压到独立目录,用 Node 22+、`pnpm@11.15.1` 执行 `pnpm install --frozen-lockfile`、`pnpm build`、`SOURCE_DATE_EPOCH=1791741741 pnpm package`。该 epoch 是固定上游提交的时间;源码包不含 Git 历史。`PATH` 中须使用 GNU tar 和 GNU gzip(已验证 tar 1.35、gzip 1.15);其他 gzip 实现即使压缩相同 tar 字节,也可能产生不同包摘要。Cargo 构建只内嵌 `HONK_DOONA_DIR` 中的文件,不构建也不下载前端。该源码的 checker 为 `tools/conformance.mjs`;live walk 只读,跳过控制、诊断和缺少已观测 ID 的资源。基础与管理契约应分别核对,浏览器操作另行验收;schema 通过不等于完整 UI、内核或部署矩阵通过。 diff --git a/doc/zh/reference/experimental.md b/doc/zh/reference/experimental.md index 8975d5c5..4f134ac3 100644 --- a/doc/zh/reference/experimental.md +++ b/doc/zh/reference/experimental.md @@ -14,7 +14,7 @@ ## `native_api` -需要显式编译 Cargo feature `native-api`(以 `--features native-api` 或 `native-ui` 构建;发布产物包含),不依赖 `clash-api`,listener 仍默认关闭。未编译该 feature 却启用配置时,启动报错。所有生效字段都要求重启;SIGHUP 拒绝其变更并保留当前 listener 与配置代次。未知字段、标量中的嵌套块、无效布尔值及安全列表空成员均报错。 +需要显式编译 Cargo feature `native-api`(以 `--features native-api` 或 `native-ui` 构建;full 与 `-native-api` 发布产物包含),不依赖 `clash-api`,listener 仍默认关闭。未编译该 feature 却启用配置时,启动报错。所有生效字段都要求重启;SIGHUP 拒绝其变更并保留当前 listener 与配置代次。未知字段、标量中的嵌套块、无效布尔值及安全列表空成员均报错。 | 字段 | 默认值 | 含义 | | --- | --- | --- | @@ -63,7 +63,7 @@ experimental { 相对 UI 路径沿用依赖搜索顺序:`global.data_dir` 下已有路径、`/var/share/honk` 下已有路径、工作目录已有路径;均不存在时定位到 `global.data_dir` 并在启动时报错。目录及其符号链接目标均由可信管理员负责。参见[原生 API 契约](./api.md#原生-api)。 -单文件部署可使用发布产物,或执行 `HONK_DOONA_DIR=$(ci/fetch-doona.sh) cargo build -p honk-core --features native-ui`,并设置 `ui: embedded`;`native-ui` 隐含 `native-api`,不要求 Clash。没有 `native-ui` 时启用内嵌托管会启动失败。静态资源不注入凭据;客户端通过公共 discovery 选择静态 token 输入或密码 setup/login。产物/源码身份、对应源码分发和管理契约见 [API 参考](./api.md#内嵌-doona-来源)。 +单文件部署可使用 full 发布产物,或执行 `HONK_DOONA_DIR=$(ci/fetch-doona.sh) cargo build -p honk-core --features native-ui`,并设置 `ui: embedded`;`native-ui` 隐含 `native-api`,不要求 Clash。没有 `native-ui` 时启用内嵌托管会启动失败。静态资源不注入凭据;客户端通过公共 discovery 选择静态 token 输入或密码 setup/login。产物/源码身份、对应源码分发和管理契约见 [API 参考](./api.md#内嵌-doona-来源)。 配置文件中的 geodata 来源由管理员配置、需重启,不能通过源写入修改。启用状态数据库时,下载还可使用已认证的 URL 覆盖或内置来源;拒绝 userinfo、fragment、redirect 与 content encoding。直连的域名来源要求 `global.bootstrap_resolver`,不回退系统 DNS。`assets.geodata.route` 或已存储的路由可改为遵循路由规则或经过组下载;路由无法承载请求时不会回退到直连。更新使用适用的配置文件、已存储或内置来源。[主文件条目与 geodata 契约](./api.md#主文件条目与-geodata-管理)区分网络期限、已验证字节激活及部分耐久替换,不承诺回滚。