Files
Zakk ef00efc3d4 docs: take over honk guidance from the doona manual (#521)
* docs(start): add service, log and OpenWrt guidance from the doona manual

* docs(reference): add startup and geodata diagnostics, link UI topics to doona
2026-11-19 00:06:52 +11:00

29 KiB
Raw Permalink Blame History

Experimental Configuration Reference

experimental { ... } configures the Clash-compatible HTTP API, the native API and persistent runtime state. It shares its name with the Clash/mihomo experimental section but not its keys.

Example

experimental {
    clash_api {
        external_controller: '127.0.0.1:9090'
        external_ui: 'zashboard'
        secret: 'replace-me'
        default_mode: Rule
    }
    cache_file {
        enabled: true
        store_dns: true
    }
}
assets {
    ui {
        url: 'https://example.com/dashboard.zip'
        route: proxy
    }
}

Nested sections

Nested section Purpose
clash_api Clash-compatible HTTP API and external dashboard.
cache_file Runtime choices, mode, delay samples and optional DNS state in the state db.
native_api Opt-in observation, bounded diagnostics, runtime and source control, and the local UI directory.
udp_nfqueue Deprecated; use global.nfqueue_enable. See udp_nfqueue.

Every effective key in native_api, clash_api and cache_file is startup-owned. A configuration change takes effect only after a restart, and SIGHUP rejects a candidate that changes any of them, so the active listener and configuration generation stay in place. The legacy cache_file keys are the exception; see Legacy keys.

udp_nfqueue

udp_nfqueue { enabled: ... } is deprecated; set global.nfqueue_enable instead. Dae and structured loaders still accept the section and print a migration warning. They read its enabled value for global.nfqueue_enable only when the global key is absent. enabled takes a boolean and defaults to false, so an empty udp_nfqueue {} disables NFQUEUE. Delete the section to keep the global setting, which defaults to true.

The global key wins in this example, so NFQUEUE stays off:

global {
    nfqueue_enable: false
}
experimental {
    udp_nfqueue {
        enabled: true
    }
}

native_api

The native_api section requires the opt-in native-api Cargo feature. Build with --features native-api or --features native-ui, or use a full release or a release whose name contains -native-api. It does not require clash-api. The listener is off by default, and enabling it in a build without the feature fails startup.

These startup errors point at a misplaced setting. native API setting belongs inside native_api { } means the field sits directly under experimental; move it into the nested block. unknown experimental setting means the key is not part of any experimental section; enabled and secret also produce it because they belong to several blocks. native-api feature is required means the build lacks the feature while enabled is true.

Unknown fields, nested scalar blocks, malformed booleans and empty security-list members are errors.

Boolean keys take true or false; the loader also accepts yes/no, 1/0 and on/off in any case. Any other spelling, such as t, produces an invalid-config-value error. The dialect reference lists the strict settings.

Key Default Meaning
enabled false Start the independent native listener.
listen "127.0.0.1:9527" Numeric IP plus port 1–65535; no hostname and no :port shorthand.
secret "" Static bearer token, independent of the Clash credential. See native_api.secret.
password_auth false Administrator password login in place of a token. See native_api.password_auth.
allow_anonymous_loopback false Credential-free requests on a loopback listener. See native_api.allow_anonymous_loopback.
allow_origins Omitted Additional HTTP(S) origins allowed for browser pages. See native_api.allow_origins.
allowed_hosts Omitted Additional HTTP Host authorities accepted. See native_api.allowed_hosts.
ui "" Local dashboard directory or embedded assets. See native_api.ui.
record_flows true Permit bounded userspace flow recording under flow diagnostic demand or an explicit runtime pin.
record_traffic true Keep up to 600 traffic samples for 600 seconds, even without clients.
record_memory true Keep up to 600 memory samples for 600 seconds, even without clients.
record_logs true Permit up to 512 structured logs for 60 seconds under an admitted /logs SSE demand or an explicit runtime pin.
record_dns_log true Permit client DNS history under a successful /dns/log GET or an explicit runtime pin, bounded to 512 records and 8 MiB.
config_write false Allow whole-source replacement and reload of the accepted main file and includes. See native_api.config_write.
experimental {
    native_api {
        enabled: true
        listen: '127.0.0.1:9527'
        secret: 'operator-supplied-random-token'
        allow_anonymous_loopback: false
        ui: '/usr/share/doona'
    }
}

native_api.secret

A static bearer token for the native listener, independent of the Clash credential. A nonempty value selects token mode, and token mode cannot be combined with password_auth. The value must be visible ASCII without whitespace or commas, matching the HTTP bearer parser; unsupported bytes fail shared configuration admission instead of creating an unusable listener.

Native API responses mask this value and clash_api.secret by value. A value shorter than 8 bytes is not masked and is reported at startup.

Use an unpredictable token of at least 16 bytes. In token mode, an enabled non-loopback listener emits one WARN at startup activation and at each accepted configuration reactivation when the secret is shorter than 16 bytes; a wildcard binding counts as non-loopback. The WARN records only the structured listen and secret_length fields, never the secret, and does not reject the configuration. Loopback-only listeners and password mode do not emit this advisory. It is separate from the masking warning above.

native_api.password_auth

true selects administrator password login instead of a token. It takes effect only when secret is empty. It cannot be combined with allow_anonymous_loopback. The default is false.

native_api.allow_anonymous_loopback

true permits credential-free requests only when secret is empty, password_auth is false, and the actual listening IP is loopback. The default is false.

experimental {
    native_api {
        listen: '127.0.0.1:9527'
        allow_anonymous_loopback: true
    }
}

native_api.allow_origins

Additional explicit HTTP(S) origins allowed for browser pages, without paths, credentials, query, fragment, null or wildcards. An omitted port means 80 for http and 443 for https. The default is an empty list.

experimental {
    native_api {
        allow_origins: 'http://localhost:3000', 'https://panel.example'
    }
}

native_api.allowed_hosts

Additional explicit HTTP Host authorities accepted, without URL schemes, paths, credentials or wildcards. An omitted port means 80, not the listener's port. The default is an empty list.

experimental {
    native_api {
        allowed_hosts: 'panel.example', 'panel.example:443'
    }
}

native_api.ui

"" disables hosting. Otherwise the value is a trusted local directory with a readable index.html, or embedded / embedded-lite with the default-off native-ui feature. embedded-lite is the lighter doona lite edition (preview). honk performs no download, extraction or frontend build at startup.

experimental {
    native_api {
        ui: '/usr/share/doona'
    }
}

native_api.config_write

Allow whole-source replacement and reload of the accepted main file and of every accepted include, and allow creating new .dae files that an include loads. Listener-credential-bearing sources are excluded. The key requires a nonempty secret or password_auth: true.

Authentication modes

Choose one authentication mode:

  • Static token: set a nonempty secret.
  • Password login: leave secret empty and set password_auth: true. Do not combine this with allow_anonymous_loopback.
  • Local development without credentials: leave secret empty, keep password_auth false, explicitly enable anonymous loopback and bind to an actual loopback address.

An enabled listener with none of these modes fails validation, and config_write: true requires token or password mode.

Replace the example secret. For local credential-free development, omit secret and explicitly set allow_anonymous_loopback: true. Never publish that anonymous listener through a reverse proxy. A token over plain HTTP on a non-loopback network is not a secure deployment; terminate TLS at a trusted proxy.

Host and Origin checks

Host and Origin checks apply independently of authentication:

  • By default, Host must name the concrete listening authority. A loopback listener also accepts localhost, 127.0.0.1 and [::1] at that port.
  • A wildcard bind accepts any IP-literal Host, and localhost, at the listening port, because these name the listener itself on whichever interface received the request. A DNS name still needs authorization, because a name can be rebound.
  • Only directly corresponding plain-HTTP origins are automatically allowed. On a wildcard bind, the origin must name the request's own Host. A page served from another address at the same port needs allow_origins.
  • A TLS proxy preserving Host: panel.example needs allowed_hosts: 'panel.example' and allow_origins: 'https://panel.example'. If it preserves Host: panel.example:443, add allowed_hosts: 'panel.example', 'panel.example:443'.

Forwarded headers do not grant authorization.

A host in either list is an IPv4 address, a bracketed IPv6 address such as [::1]:9527, or an ASCII DNS name. A DNS name uses letters, digits and inner hyphens only: no underscores, empty labels or trailing dot. An explicit port is 1 to 65535.

Lists are comma-separated, such as allow_origins: 'http://localhost:3000', 'https://panel.example'. Entries may be quoted individually or left bare. Omit a list to leave it empty. JSON brackets and a single aggregate-quoted list are not accepted.

A relative ui path follows 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 fails startup. The administrator owns the directory and any symlink targets. See the native API contract.

Embedded UI

To serve the UI from a single binary, use a full release build. Alternatively, build with HONK_DOONA_DIR=$(ci/fetch-doona.sh) cargo build -p honk-core --features native-ui, then set ui: embedded or ui: embedded-lite. The native-ui feature includes native-api without requiring Clash. Enabled embedded hosting fails startup in a build without it. The assets receive no injected credentials; sign-in and administrator setup are described in the doona manual. The API reference documents asset and source identities, corresponding-source distribution, and the management contract.

Geodata sources

An administrator controls file-configured geodata sources, and changing them requires a restart. Source writes cannot change them. 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; honk does not fall back to system DNS. assets.geodata.route or the stored route can send downloads through the routing rules or a group instead. 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 distinguishes network limits, verified-byte activation and partial durable replacement from rollback.

Geodata download URLs and routes belong to assets.geodata. The former native_api keys are still accepted, with a warning for each, and the assets reference lists the replacement for each one.

Shared sampling and optional history

Traffic and memory histories share the one-second sampler. A missing sample stays a gap or a null; honk neither zero-fills nor interpolates it. A memory reading is the process RSS and available cgroup-v2 data, not kernel accounting. The histories live in memory only and are cleared on restart.

record_flows: false prohibits flow recording, including explicit runtime pins. record_logs: false prohibits log capture, and record_dns_log: false prohibits DNS history. record_traffic: false and record_memory: false disable that history and release its buffer on restart. Live counters, runtime readings, outbound readings, memory readings, console logging and Clash logging stay available.

Automatic flow, log and DNS-log capture each have their own 60-second grace. Ordinary events enable event capture only. A successful flow read or an explicit flow-event filter enables flow capture. /logs SSE enables log capture, and a successful /dns/log GET enables DNS-log capture. Other API requests, validation, failed GETs and HEAD never enable diagnostic capture; runtime On/Off and configuration prohibitions follow the recorded userspace flows contract.

PATCH /api/v1/runtime/settings can transiently adjust the supported log/DNS-log/flow limits and native log level, but cannot enable a disabled recorder. The merged settings take effect atomically after validation. An accepted explicit activation, including a no-op, restores the configured values, and a provider or network refresh preserves the overrides. Activation reset behavior is described in native logs and runtime settings.

Configuration management trust boundary

Configuration metadata, validation and reload operations require a genuine .dae source snapshot captured at startup. Programmatic configs and compatibility serde loaders do not supply one.

  • Reads return the accepted content and mask only declared listener-secret values. This covers duplicate and overridden declarations, and every other occurrence of the same value. Admitted anonymous loopback requests read the same data as bearer-authenticated requests.
  • Credential-bearing sources stay read-only and retain original-byte hashes.
  • Source path stays entry-directory-relative; absolute_path exposes the canonical absolute path.
  • To make the main source editable, move credentials to a dedicated read-only include locally, then restart. The API cannot change or move API credentials, or alter native settings; both require a local edit and restart.

With config_write: true, every accepted noncredential include is writable, and ordinary include glob, ordering and no-match semantics remain unchanged. Accepted sources and their dependencies share one admission budget of 32 sources and 8 MiB, and a dependency referenced more than once is charged once per reference. HTTP JSON bodies stay capped at 64 KiB.

Reading a body and writing it are separate permissions. A credential-bearing source stays readable with its secrets masked, and its masked body cannot be written back. Selector writes, restricted Group PATCH, and main-source creation and deletion reuse the same source write permissions. Fixed members from automatic policies apply only at runtime and are never written back to a source.

To save a source, send its opaque source ID with an RFC 9110 If-Match header over the disk-content SHA-256, then run the real reload operation. The header accepts strong tags, a list or multiple field lines, or *. Weak tags never match. A successful write does not mean activation succeeded, and an editor that does not coordinate externally can still race the final check and rename. Restricted Group PATCH uses the same source transaction, but it requires the accepted group or config ETag, checked before writing and again before activation, with the source and its dependencies checked separately. That revision is not the disk hash. See source safety and failure semantics.

Probe targets

Probe targets come only from accepted configuration. Resolution, IPv4-mapped IPv6 normalization and selected-IP pinning still apply. Callers cannot supply URLs, and probes do not follow redirects. 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, and provider content is trusted configuration.

probe_allowed_cidrs and probe_allowed_ports are removed. Both keys are still accepted in dae configuration and in compatibility structured loaders, with one warning per key. Their values are ignored, the keys can be deleted, and neither key is serialized.

clash_api

The clash_api section requires the default-on clash-api Cargo feature. A build without it ignores external_controller.

--store db does not run the Clash API. A non-empty external_controller refuses startup in that mode; see Configuration db.

Key Default Meaning
external_controller "" Listen address as IP and port; an empty value disables the API server. See clash_api.external_controller.
external_ui "" External dashboard directory; an empty value disables serving and download. See clash_api.external_ui.
secret "" API authentication token; an empty value disables authentication. See clash_api.secret.
default_mode "Rule" Startup mode with the native API disabled. See clash_api.default_mode.

clash_api.external_controller

A listen address as an IP and port, such as 127.0.0.1:9090 or [::1]:9090. :9090 means 0.0.0.0:9090. Hostnames are not accepted. An empty value disables the API server. An invalid address logs a warning and the engine starts without the listener.

experimental {
    clash_api {
        external_controller: '127.0.0.1:9090'
    }
}

clash_api.secret

An API authentication token; an empty value disables authentication. A value shorter than 8 bytes is not masked in native API responses.

experimental {
    clash_api {
        secret: 'replace-me'
    }
}

Authentication and transport

With a non-empty secret, API requests use Authorization: Bearer <secret>. WebSocket upgrades may instead pass ?token=<secret>. Static /ui content is outside this authentication middleware.

The built-in listener serves plain HTTP and provides no TLS. Bind it to a loopback address such as 127.0.0.1, or put an authenticated TLS reverse proxy in front of it, and do not expose it directly on an untrusted network. See the Clash API reference for the endpoint inventory.

A non-loopback bind that is explicitly enabled with an empty secret emits unsafe-api-bind at experimental.clash_api.external_controller; structured input is no exception. The diagnostic contains neither the endpoint nor the secret. Sample configurations that bind loopback do not warn. This warning does not change bind, authentication or CORS policy.

clash_api.external_ui

An absolute external_ui path is used literally. A relative path selects the first existing path, file or directory, below global.data_dir. If nothing exists there, it tries /var/share/honk, then the working directory. If the first match is a file, honk uses it instead of skipping to a directory. If none exists, honk creates the target below global.data_dir.

Dashboard download URL and route belong to assets.ui. A missing or empty target triggers a background dashboard ZIP download. A non-empty assets.ui.url replaces the built-in zashboard URL, and HONK_UI_DOWNLOAD_URL has highest precedence over both.

assets.ui.route takes precedence over assets.route for the initial request and every redirect. direct downloads directly. block aborts when routing rules select it. A group resolves its authoritative leaf for each exchange. With no configured route, each URL follows the normal traffic routing decision. An unavailable tag, download failure, or extraction failure is logged without stopping the engine.

The archive is written to an unnamed private file in the target directory, not to memory, and honk removes it after extraction or a failed download. Extraction is refused past 10,000 entries or 128 MiB of content, the same bound as the archive itself. The partly written directory is emptied, so the next start downloads again.

A download follows at most five redirects. Each HTTP exchange has a 30-second timeout; through a proxy, the timeout starts after the tunnel is dialed. When every ZIP entry sits under one top-level directory, that directory is stripped, so dist/index.html becomes index.html. Entries whose path has an empty, . or .. component or a backslash are skipped.

clash_api.default_mode

With the native API disabled, default_mode accepts Rule, Global, and Direct in any case. With cache_file.enabled: true, a valid cached Clash mode takes precedence, and invalid values fall back to Rule.

With the native API enabled, both APIs share one transient mode owner. It does not restore or persist a mode, starts at Rule, and returns to Rule on every accepted explicit activation, a no-op included, when the backend reset succeeds. It keeps its mode across a provider or network refresh. A reset failure after commit retains the previous mode, closes admission and returns CommittedDegraded. Native Global mode targets a stable node/group identity and fails closed if a refresh removes it. See runtime mode.

cache_file

Key Default Meaning
enabled Omitted Persist runtime state in the state db, <data_dir>/state/honk.db. See cache_file.enabled.
store_dns false With enabled: true, also persist and restore DNS cache answers. See cache_file.store_dns.

cache_file.enabled

enabled selects which runtime-cache tables the state db keeps. Omitting the key keeps Selector choices and delay samples; true also keeps the Clash mode and GLOBAL selection and allows store_dns; false keeps no runtime state.

Upgrade note: set enabled: true to keep the Clash mode and GLOBAL selection, and store_dns: true separately to keep DNS answers. Explicit false disables these runtime-cache stores. It does not affect configuration, credential or subscription storage.

experimental {
    cache_file {
        enabled: true
    }
}

cache_file.store_dns

With enabled: true, also persist and restore DNS cache answers. The default is false.

experimental {
    cache_file {
        enabled: true
        store_dns: true
    }
}

Legacy keys

path, cache_id and store_fakeip are no longer settings. They still parse, emit a legacy-cache-file warning and have no effect, and SIGHUP accepts edits to them. path and cache_id are read once, to import a legacy cache.db (see Upgrading from cache.db).

An omitted or empty path means cache.db, and an omitted cache_id means "", which leaves keys without a prefix.

Persisted state

Unless enabled is false, honk keeps per-network (TCP and UDP) Selector choices and each node's last real delay sample in the state db, like mihomo's store-selected. Only enabled: true also restores and persists the Clash mode and the Clash GLOBAL selection, and only with the native API disabled. With the native API disabled and no restored mode, a restart starts in default_mode. With the native API enabled, it always starts in Rule. Delay samples are written as one batch every minute. Restoration discards zero samples and samples older than 24 hours. Liveness is not restored.

When neither --store db nor native_api.password_auth is set, database failures have these outcomes:

  • Corrupt database: after taking the instance lock, honk moves honk.db and honk.db-wal to honk.db.corrupt and honk.db.corrupt-wal, then starts a new file.
  • Existing honk.db.corrupt: honk keeps both files and runs without persistence until one is removed.
  • Unavailable, unsafe or reset-locked database: honk warns and runs without persistence. An unsafe database is not a private file owned by the honk user. A reset lock belongs to honk-core admin reset.

For an unsafe path, the persistence_unavailable degradation adds rule in addition to reason, with these values: not_owner, group_or_other_bits, not_directory, not_file, symlink or identity_changed. The log names the path and how to fix it.

A database from a newer honk or another program refuses startup in every mode. Moving it aside would destroy data only that program can read.

Limits

A maintenance tick runs every 60 seconds. honk keeps a Selector choice only for a Selector group in the configuration, and a delay sample only for a configured node. It deletes a row whose group or node is missing at two consecutive ticks, so a reload that briefly drops one keeps its row. Each tick deletes delay samples older than 24 hours and expired DNS rows, and returns up to 1 MiB of freed pages to the filesystem. At most 4,096 DNS rows are kept. After each batch the earliest expiry is evicted first.

If startup opens the state db because --store db, password_auth, store_subscribe or cache_file needs it, these settings clear stored cache state:

Startup setting Tables emptied
enabled: false Selector, delay, Clash-state and DNS
enabled unset Clash-state and DNS
store_dns: false DNS
Native API enabled or Clash API disabled Clash-state

Startup without a state db leaves the file unchanged.

The state db file is capped at 112 MiB. Cache writes keep 24 MiB of it free for configuration revisions and subscription bodies. If a batch would leave more than 88 MiB in use, the writer first deletes DNS rows down to 2,048. If that is not enough, it rolls the batch back. Skipped DNS entries are counted as budget_skipped, not as written. The legacy cache.db import obeys the same budget: a copy that would pass it is not committed, and the next start tries again.

DNS persistence

With store_dns: true, each answer is one dns_answer row holding an HDNS version-2 payload, keyed by the digest of its exact cache key. honk restores a row only while it is unexpired, and only when its key digest, canonical query wire, response wire identity and active DNS policy match. The exact key also preserves the ingress profile, request scope and operation, so an entry is never reused across different DNS contexts. An entry that encodes to more than 4 KiB is not persisted and is counted as oversize.

Upgrading from cache.db

On the first start with a state db and enabled not false, honk imports the legacy cache.db that path names. An absolute path is used as written. A relative path prefers an existing path below global.data_dir, then below /var/share/honk, then relative to the original config directory.

Only keys under this instance's cache_id prefix are read. honk copies per-network Selector choices of Selector groups in the configuration, and delay samples newer than 24 hours of configured nodes. It copies the Clash mode and the Clash GLOBAL selection only when enabled: true, the native API is disabled and external_controller is set in a clash-api build. Rows already in the state db win. Name-only Selector choices from older releases, DNS answers and FakeIP rows are not imported, so persisted DNS answers are refetched.

The import is recorded in the state db per file and cache_id, and it never repeats, even if an older binary recreates the file. Another cache_id can still import its own keys from a kept file.

honk leaves a cache.db in place with a warning when it is a symlink, is not a regular file owned by the honk user, is writable by other users, or cannot be read as a cache.db. The next start tries again. In db mode, the relative-path fallback uses the active revision's original entry directory, even when the current -c points elsewhere and is ignored for startup.

With an empty cache_id, honk then deletes cache.db, its -wal and -shm. Any cache.db.corrupt-* copies stay. With a non-empty cache_id, another instance may share the file, so honk keeps the file and logs one warning. An older binary started afterwards finds no cache.db and starts with empty runtime state.