Files
honk/crates/honk-tool
M0re Co1orsandZakk 5b854151c4 fix(ebpf): datapath correctness, long-connection keepalive and commit latency (#148)
* fix(native-ui): embed doona beta.20

* fix(udp): preserve and share QUIC source associations

* refactor(udp): add multi-target transport contract for shared sources

* fix(udp): route shared-source protocols through one generic source arm

* fix(udp): share one SOCKS5 association per client source

* fix(udp): share one Shadowsocks association across destinations

* fix(udp): share one Juicity UDP stream per client source and return real peers

* fix(udp): share one Trojan UDP stream per client source

* fix(udp): share AnyTLS source over non-connect UoT

* test(udp): benchmark production UDP send and receive

* fix(udp): share VLESS UoT v2 and H2MUX over addressed framing

* fix(udp): keep foreign domain names off the per-packet wire

* perf(udp): keep Hy2 address buffer out of the send future

* refactor(udp): select shared sources through the protocol registry

* docs(udp): document shared-source full-cone behavior and correct node defaults

* test(udp): prove shared-source full-cone through the real kernel path

* test(udp): benchmark shared-source overhead against ordinary flows

* build(core): drop duplicate dev-dependencies

* perf(udp): admit source replies with one endpoint lookup

* perf(udp): skip the reply timeout when the client socket is writable

* perf(udp): keep one retirement waiter across source replies

* fix(udp): type native UDP size refusals as local rejections

* fix(config): follow group members to re-derived node ids

* test(udp): check benchmark replies against their destination

* fix(config): keep group members off ambiguous stored node ids

* fix(udp): type interrupted shared frames and split oversized UDP modules

* docs(udp): name the shared AnyTLS uot transport in the ownership map

* fix(subscription): report provider usage and expiry

* test(udp): cover cancelled frame writes on VLESS UoT v2 and H2MUX

* refactor(udp): share the dialed-domain reply rule across UDP transports

* refactor(udp): name the empty-first-datagram rule on SourceTransport

* fix(quic): evict the oldest pending reassembly when the table is full

* fix(udp): warn when a source's foreign reply sockets saturate

* test(ci): run the shared-source sing-box interop matrix weekly

* bench(core): gate the real-I/O bench harness behind udp-bench

* fix(udp): keep an H2MUX window stall before the first chunk packet-local

* fix(udp): admit a datagram when its poisoned frame write starts

* fix(udp): fail a shared source whose uplink admits nothing for 30 s

* fix(udp): fail a stalled source across quiet gaps, not per deadline run

* docs(udp): describe the send attempt every source carrier now holds

* test(config): resync node documentation corpus ranges

* fix(subscription): preserve Mihomo TUIC ALPN defaults

* fix(ebpf): bind flow ownership and fence retirement

* fix(ebpf): preserve stable flow values and live ownership

* fix(udp): preserve fresh route and admission authority

* fix(ebpf): keep retransmitted SYNs on their original request

* test(ebpf): drop ownership cases that repeat a covered branch

* fix(ebpf): count TCP ownership publication failures

* refactor(ebpf): share auxiliary publication and split conntrack by protocol

* refactor(core): own retirement and namespace plumbing in single modules

* test(core): bind kernel cases to functions over shared fixtures

* test(core): make token-zero retirement fixture ownership-sensitive

* fix(nfqueue): keep full error chains in fatal decision reports

* docs: list kernel options required by TCP request ownership

* docs(datapath): state the SYN-flood cost of disabled cookies

* docs(control): name the janitor health owner

* refactor(ebpf): drop the redundant UDP claim flag

* refactor(core): plan expiry hints through the conn planner

* refactor(core): validate socket identity storage through the layout checker

* test(core): share the singleton retirement fixture

* test(core): seed retirement flows through the publisher

* test(core): start pin-error epochs through the retirement fixture

* fix(ebpf): never deny host sockets on identity capture failure

* test(config): resync how-to-start documentation ranges

* fix(group): honor network pins in URLTest retries

* fix(anytls): share one silent-window failure episode

* fix(probes): limit graph caps to leaf expansion

* fix(dns): capture bootstrap TCP fallback transport

* perf(outbound): box resolver futures only for observation

* perf(anytls): compile out inert observation storage

* fix(lifecycle): quiesce NFQUEUE and UDP before detaching hooks

* fix(lifecycle): recheck NFQUEUE health before datapath admission

* fix(lifecycle): wait for the UI download owner past its stop deadline

* fix(core): roll back started owners when native startup fails

* fix(udp): never start a preparation after the plan is decided

* fix(tcp): close accepted socket before retiring redirect state

* fix(native): keep kernel route on pinned TCP DNS flows

* fix(native): record UDP DNS refusals independent of DNS log

* fix(reload): clear automatic pins on no-op activation

* fix(native-api): commit geodata settings off the runtime worker

* fix(native-api): mask listener secrets in DNS responses

* fix(native-api): honor wildcard Accept-Encoding for directory UI

* fix(native-api): count each eBPF object once in memory telemetry

* fix(config): sync the current directory for a bare export filename

* fix(native-api): keep dependency identity across an unchanged reload

* fix(native-api): charge provider JSON allocations to snapshot retention

* fix(download): admit selected Score work before a routed download runs

* fix(subscription): skip cache-off providers in the offline body lookup

* fix(download): resolve forced-group hosts with the request's strict resolver

* fix(download): race resolved addresses for direct downloads

* fix(state): skip disabled Clash-owner rows in the legacy cache import

* fix(ui): open the download archive inside the output directory

* perf(routing): hash-index shared IP matcher interning

* fix(config): keep explicit group option presence in structured loaders

* fix(config): skip entry-shaped children of braced subscription entries

* fix(relay): treat unreachable client errors as client-side

* docs(operations): back up legacy subscription bodies before rollout

* docs(api): document refusal request lines at INFO

* docs(api): condition geodata persistence on owner initialization

* docs(api): use the pinned doona commit epoch

* docs(configuration): qualify mode persistence for native-disabled

* docs(groups): sync zh exact-ID selector exception

* docs(rules): name the actual VM lifecycle coverage

* docs(rules): include native-ui in the release feature recipe

* refactor(alive): extract health runner from probe

* refactor(state): let the cache writer own its flush deadline

* refactor(routing): move domain matching into routing/domain.rs

* refactor(config): move experimental section reader into parser/experimental.rs

* refactor(control): split UDP candidate preparation from connection init

* refactor(control): split UDP reply delivery from endpoint driver

* refactor(native-api): move listener secret masking into its own module

* refactor(config): centralize listener secret value decoding

* refactor(native-api): split managed entries and candidate validation

* refactor(control): centralize TCP selection observation

* refactor(observe): own DNS history in the recorder

* refactor(native-api): split security integration tests

* refactor(native-api): separate event HTTP adapters

* refactor(control): split HTTP prober from probers

* refactor(control): extract reload DNS preparation

* refactor(ebpf): share the batch map snapshot traversal

* fix(download): continue Score work across subscription redirects

* perf(reload): skip unpinned groups when clearing automatic pins

* fix(ebpf): prove accepted TCP children from sock_ops

* test(ebpf): verify the sock_ops callback body in the helper audit

* fix(ebpf): prove a child whose publication TC already marked Closing

* docs(datapath): drop the miscounted SYN retry timetable

* fix(routing): share fact IDs between identical matchers

* refactor(core): report retirement outcomes per request

* fix(core): retire UDP endpoints whose kernel flow was reclaimed

* fix(ebpf): select UDP listeners consistently

* fix(ebpf): rate-limit new flows per LAN source

* fix(ebpf): drop fragments of redirected and blocked datagrams

* perf(nfqueue): run staged UDP commits off the async worker

* perf(nfqueue): activate armed direct UDP without a grace period

* perf(nfqueue): batch staged UDP commits

* feat(ebpf): count redirect and handoff occupancy

* fix(core): drive janitor cadence from auxiliary occupancy

* fix(core): resume janitor scans from a persistent cursor

* fix(core): reclaim unpinned TCP and stateless UDP redirects after 30 s

* perf(core): widen retirement batches

* fix(ebpf): suspend reverse UDP learning under conn pressure

* fix(ebpf): learn local UDP service replies at the socket probe

* fix(ebpf): stop publishing TCP state from reverse-direction SYNs

* fix(ebpf): renew owned expired UDP handoffs

* fix(ebpf): exempt TCP port 53 from WAN egress health drops

* fix(ebpf): gate established TCP only at admission

* fix(core): fail startup when dae0_ingress cannot attach

* fix(ebpf): renew UDP conn from proxied replies

* fix(ebpf): continue the TCX chain on pure pass-through

* refactor(core): stop creating clsact qdiscs

* perf(ebpf): collapse redundant locked conn lookups

* perf(ebpf): avoid duplicate WAN UDP failure snapshots

* perf(ebpf): rate-limit repeated expiry hints per flow

* perf(core): find duplicate retirement fences without a quadratic scan

* fix(core): keep the janitor running when a telemetry read fails

* fix(core): name the pressured map and keep retirement causes in janitor logs

* fix(ebpf): clear stale fragment drops on accepted ID reuse

* fix(ebpf): budget local UDP learning per LAN source

* test(ebpf): slim the regression tests added by this series

* docs(datapath): describe the datapath fixes

* fix(core): finish the kernel handoff of a terminal commit that a reload cancels

* fix(core): reject expired staged commits after releasing the backend lock

* fix(core): stop the commit pump under its task lock

* docs(datapath): scope the port-53 health exemption to LAN ingress and WAN egress

* refactor(ebpf): call the shared outbound health gate directly

---------

Co-authored-by: Zakk <zakk@gentoozh.org>
2026-10-20 09:34:35 +08:00
..

honk-tool

honk-tool is the CLI toolbox for honk, containing diagnostics that don't belong in the honk-core engine binary: subscription availability checks, quick reads of the running engine's eBPF maps, and one-shot health checks.

It is a static musl binary — it runs unprivileged where possible and on a production gateway (VyOS/Debian) as a single copied file.

Build

# Dev (glibc, your workstation)
cargo build --release -p honk-tool

# Static musl for the gateway (needs zig 0.14+, uses the ci/ wrappers)
ZIGCC_TARGET=x86_64-linux-musl \
CC_x86_64_unknown_linux_musl=$PWD/ci/zigcc \
CXX_x86_64_unknown_linux_musl=$PWD/ci/zigcxx \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=$PWD/ci/zigcc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-C link-self-contained=no" \
BINDGEN_EXTRA_CLANG_ARGS="$(ci/zig-bindgen-env x86_64-linux-musl)" \
cargo build --release -p honk-tool --target x86_64-unknown-linux-musl

scp target/x86_64-unknown-linux-musl/release/honk-tool vyos@<gateway>:/tmp/

A gnu build fails to exec on musl-only systems ("No such file or directory" from the loader) — always deploy the musl build to the gateway.

Commands

sub — subscription availability check

honk-tool sub <url|file|-> [--target HOST:PORT] [--url TEST_URL]
              [--timeout SECS] [--concurrency N] [--limit N] [--ua UA]
              [--v4-target IP:PORT] [--v6-target [IP]:PORT]
              [--tls-implementation tls|utls] [--utls-imitate chrome_auto]

Fetches a subscription (base64 / raw-line / Clash YAML, auto-detected) or reads a local share-link file, prints the per-protocol breakdown, then probes every node concurrently:

Use source - for a credential-bearing provider URL: the command reads the complete stdin value, trims surrounding whitespace, and accepts exactly one http/https URL. This keeps the URL out of argv and command listings. Fetch errors and per-node failures omit URLs and endpoint details:

set +x
printf '%s\n' "$SUBSCRIPTION_URL" | honk-tool sub - --tls-implementation utls

--tls-implementation defaults to tls; utls enables the process-wide Chrome ClientHello. --utls-imitate accepts only chrome* profiles and defaults to chrome_auto. Clash client-fingerprint remains unmapped because the fingerprint is process-wide, not a per-node property.

Defaults use cp.cloudflare.com:443 as the test host, 1.1.1.1:443 for v4, and [2606:4700:4700::1111]:443 for v6, so the family probes work even when the resolver returns no AAAA. Override them with --target/--v4-target/--v6-target.

  • server IP families (does the node host resolve to v4/v6?),
  • proxied connectivity to the test host over IPv4 and IPv6 — a full protocol dial through the node (TLS handshake included for TLS protocols),
  • proxied latency via urltest_node (default target: https://www.gstatic.com/generate_204),
  • UDP liveness: a minimal DNS A query and a real QUIC handshake (h3, certificates skipped) through the node's selected packet path. Protocols without a packet handler, nodes whose packet network disables UDP, and a target rejected by VLESS UDP/443 policy report n/a; H2MUX, Xray mux, and fallback encodings are exercised according to the normalized node.

Ends with alive-per-family counts and the median latency.

v6 shows n/a? The family probe had no address of that family and no explicit target. Pass dae-style targets to skip DNS: --v4-target 1.1.1.1:443 --v6-target '[2606:4700:4700::1111]:443'.

VLESS output uses only the display name and this normalized redacted shape:

vless/{plain|tls|reality}/{tcp|ws|grpc}[/vision]/tcp={plain|h2mux|mux-cool}/{udp-fallback=auto|native|xudp|uot-v2|udp=disabled}[/padding=true|false][/mux=TCP:UDP:POLICY]

udp-fallback= remains visible when a mux owns the current UDP target; udp=disabled means packet dialing is forbidden. Xray TCP is the per-carrier TCP logical-child concurrency; UDP is protocol, shared, or a separate pool's per-carrier logical-child concurrency. POLICY is reject, skip, or allow. Invalid and intentionally unsupported entries remain visible with fixed eligibility codes but perform no network work. Local carrier-capacity refusal is an attempted FAIL(...), not n/a, and is neutral to remote endpoint health. Failure codes are resolve, timeout, exchange, handler, and admission; raw errors, proxy endpoints, SNI, UUIDs, REALITY keys, and URL query data are never printed. See the CLI reference for the complete eligibility list and shape semantics.

$ honk-tool sub https://example.com/sub --limit 3
fetched 200 node(s) in 22ms
protocols: anytls×3

🇭🇰 hk.147   anytls   v4   v4: 41ms   v6: 0ms   urltest: 120ms
...
== 3 node(s): v4-proxied 3, v6-proxied 3, urltest-ok 3, median latency 120ms

bpf — quick reads of the running engine's eBPF maps

honk-tool bpf show <map> [--ip ADDR] [--limit N] [--pin-root PATH]
honk-tool bpf stats [--pin-root PATH]

Reads the pinned maps under /sys/fs/bpf directly with raw bpf(2) calls (no aya, no program loading) and decodes the kernel/userspace wire structs. Requires root (or CAP_BPF).

show maps:

name contents
conn-state conntrack entries with outbound/mark/must/state
redirect-track reply-rewrite tracking (outbound, from_wan, ifindex)
domain-routing DNS-learned IP → rule-bitmap entries
routing-handoff pending eBPF → control-plane routing handoffs

stats prints the conn-state overflow counters, the CONN_STATE_OCCUPANCY gauge (cumulative datapath inserts/deletes), and all non-zero per-outbound tx/rx counters.

diagnose — one-shot health check

honk-tool diagnose [--api http://127.0.0.1:9090] [--secret TOKEN] [--pin-root PATH] [--tproxy-mark 0x8000000]

For an authenticated Clash API, supply --secret TOKEN or set HONK_API_SECRET. The flag takes precedence; the token is sent as Authorization: Bearer.

Read-only checks, each printed as [ok] / [FAIL]:

  1. engine process alive (honk-core/dae in /proc),
  2. daens network namespace and dae0 veth present,
  3. daens fwmark policy-routing rule present,
  4. required pinned maps present (CONN_STATE_MAP, REDIRECT_TRACK, ROUTING_HANDOFF_MAP, CONN_STATE_OCCUPANCY),
  5. conn-state occupancy + overflow counters readable,
  6. clash API returns a 2xx status (/version), printing the response body; a non-2xx status prints [FAIL] with the status text.

Standard output ends with diagnose: all checks passed (exit status 0) or diagnose: N issue(s) found (exit status 1, with the count in the error message).

Design notes

  • Depends on honk-config, honk-outbound, honk-ebpf-common, and honk-core with default-features = false (no axum/aya pulled in).
  • The map read path is a ~100-line libc bpf(2) layer instead of aya: aya's typed-map constructors and sys helpers are crate-private, so external tools can't open pinned maps through its public API. Note that BPF_OBJ_GET has its own attr layout (pathname at offset 0) that does not share the map-ops layout.
  • Wire structs (TuplesKey, ConnState, …) carry aya::Pod impls in honk-ebpf-common for anything that does want the typed API.

License

GPL-3.0-only, same as honk.