Files
shater/ACCEPTANCE.md
T
omarandClaude Opus 4.8 05920f83ad
build / aarch64_cortex-a53 (push) Successful in 3m0s
build / x86_64 (push) Successful in 2m59s
fix: eliminate reconcile fork-storm (OOM) + resolve UCI config conflict with xray-core
Two release-blocking defects found via live 512M OpenWrt VM testing.

1) Fork-storm / OOM (critical). Reconcile() -> reloadXray() ->
   "/etc/init.d/shater reload" -> reload_service -> shater_reconcile ->
   `xrayctl reconcile` -> Reconcile() was an infinite mutual recursion; each
   level blocked on CombinedOutput and spawned a process (854x reconcile +
   853x reload observed), exhausting RAM and pinning both vCPUs -> OOM-killer.
   - Reconcile() no longer calls reloadXray(); procd's file-watch on run.json
     restarts xray. Reconcile runs inside the init lifecycle, so calling the
     init back is the recursion.
   - reloadXray() now runs `/etc/init.d/shater start` (not `reload`); it is only
     invoked from Apply()/Rollback() (LuCI/ubus/CLI), never the init lifecycle.
   - init reload_service() simplified to start/stop (dropped the double reconcile).
   Verified: `xrayctl apply` 0.39s (was >185s hang); 93 procs / load 0.00 stable
   with an active 254-node config on 512M; xray binds :10853 API + :12345 tproxy.

2) UCI config namespace clash. shater shipped /etc/config/xray, which collides
   with the xray-core dependency's own /etc/config/xray (opkg dropped ours to
   /etc/config/xray-opkg, so the schema never took effect). Renamed the UCI
   namespace xray -> shater everywhere (Go uci export/commit, all 11 LuCI views +
   acl, init scripts, hotplug, Makefile conffiles, examples). Runtime paths
   (/etc/xray/run.json, /usr/share/xray), the xray-core package, and the ubus
   object name are intentionally unchanged.

Also: ci/pack-xrayctl.sh (local ipk packer) with a postinst chmod so the binary
is executable regardless of host-tar mode handling; PKG_RELEASE bumped to r3.

Verified end-to-end on a fresh 512M OpenWrt 24.10.3 VM: feed install
(opkg install luci-app-shater pulls xrayctl+shater-core), real LAN client
(netns in br-lan) proxied through a live subscription node -> exit IP changed
(104.156.233.234 vs 45.131.214.140 direct); per-client nft counters + xray
stats API populated. See PROOFS.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 11:36:48 +03:00

17 KiB

ACCEPTANCE — per-feature gap analysis vs. T1 scope

Read-only audit (2026-07-09) of xrayctl/*.go + luci-app-shater/** against 05-feature-catalog.md (T1 items), CONTRACT.md, STATUS.md.

Status legend: DONE (rendered into xray/nft/routing output and reachable) · PARTIAL (works for a subset / one plane only) · STUB (parsed/modelled but NOT rendered into any output) · MISSING (no code path at all).

Evidence is file:line or func. "Rendered" = ends up in the xray JSON, the inet shater nft table, or ip rule/route — not merely stored in the Model.


1. Subscriptions

Capability Status Evidence To complete
Per-sub update interval STUB uci.go:57 parses update_interval; nothing schedules it. main.go:cmdSub fetches only on demand. No procd-timer/cron emitted anywhere. Generate a per-sub timer (procd service_triggers/cron) keyed on update_interval; wire sub update NAME to it.
HAPP headers (UA/hwid/os/model/custom) DONE sub.go:141 applyHappHeaders, sub.go:168 resolveHWID (auto uuid persisted to /etc/xray/state/<name>.hwid), custom Headers loop sub.go:159. —
hwid auto / fixed DONE sub.go:168-183: auto → generate+persist; fixed passthrough; empty → none. —
Fetch-via-proxy STUB uci.go:58 parses fetch_via; sub.go:119 FetchSubscription always uses a plain http.Client — FetchVia is never read. Build an HTTP client whose transport dials through the local socks/tproxy path when fetch_via=proxy.
Cache + use-cache-on-fail PARTIAL sub.go:298 LoadSubCache, main.go:157 on fetch error continues (keeps old cache). No explicit "serve stale on fail" beyond not overwriting. Fine for MVP; add an explicit last-good-timestamp / staleness surfaced to UI.
Import from string / \n / file PARTIAL sub.go:197 ParseSubscriptionBody (base64 or \n list); generate.go:116 BuildConfigFromLinks + main.go:cmdGen --links FILE. BUT this only feeds gen — it does not persist nodes into UCI/cache, and there is no UI to paste/import. Add an import CLI verb that writes config node/cache, and a LuCI import box.
Import from clipboard (T1) MISSING No UI node/import view exists (menu has no such page). Add paste-from-buffer control on a Nodes/Import page.
Fingerprint reconcile (stale/fallback) DONE sub.go:48 Fingerprint (8-byte sha256 over conn fields), sub.go:239 ReconcileSub (match by FP, keep pins, maxStaleRefreshes=3 aging). —
userinfo (traffic limit / expiry) (T1) MISSING FetchSubscription discards response headers; no subscription-userinfo parse. Parse the Subscription-Userinfo header + surface to dashboard/alert.
Filters by proto/country, dedup (T1) PARTIAL dedup by FP sub.go:254; regex include/exclude on name only (generate.go:257 resolveGroupMembers). No proto/country/geo filter. Add proto/country filter fields to group resolution.

2. Groups / Balancers + Observatory

Capability Status Evidence To complete
leastPing / random / roundRobin DONE generate.go:622 xrayStrategy; balancer emitted generate.go:243. —
single (fixed / lone member) DONE generate.go:240 — routes straight to member, no balancer. —
failover (priority order) STUB generate.go:628: failover is aliased to xray leastLoad — this is not a priority-ordered failover. Emit real failover (ordered member list / strategy:leastLoad with costs, or observatory-driven priority).
Observatory config emitted PARTIAL generate.go:103-108 emits observatory{subjectSelector,probeURL,probeInterval} only when a leastping/failover group exists. OK; but see below — results never surfaced.
Live ping / alive surfaced in UI MISSING status.go:38 NodesJSON sets Alive=false, LatencyMS=0 always; observatory results (xray API) are never read. node_test (status.go:70) does a plain TCP connect to the endpoint, not a through-node real-delay. Read xray Observatory/StatsService over the API port and merge into nodes.
Group CRUD from UI MISSING No groups.js (menu.d has overview/nodes/subscriptions/rules/settings only). Groups exist only by hand-editing /etc/config/shater. Add a Groups LuCI page (strategy, source, members, include/exclude, probe).

3. Multi-hop chains L1→L2→L3

Capability Status Evidence To complete
Backend chain generation PARTIAL/DONE generate.go:341 emitChain — inverted proxySettings via internal localhost socks pairs per layer; exit tag via chainExitTag (generate.go:504). Logic looks correct but is not exercised by any bundled test/fixture (selftest only builds from links). Add a chain fixture to selftest/regression + real xray -test on a 3-hop chain.
Chain as rule target DONE generate.go:493 resolveTarget case chain. —
Chain as egress MISSING Egress plane not rendered at all (see §5). —
Build/edit chains from UI MISSING No chains page; Chain model has no UI. Add a Chains LuCI page (ordered hop list referencing groups/nodes).

4. Rules

Capability Status Evidence To complete
src CIDR / host /32 DONE generate.go:436 → xray source. —
src MAC / iface / zone STUB (buggy) generate.go:436 dumps all r.Src verbatim into xray source via cidrsOnly (which only trims blanks, generate.go:653 — misnamed, does not filter to CIDRs). A MAC, iface:x, or zone:x value goes into xray source, which accepts IP/CIDR only → invalid/ignored, never translated to nft. Split src by kind: CIDR/host → xray source; MAC/iface/zone → nft meta match in RenderNft.
dst domain / suffix / keyword / geosite DONE generate.go:438,446 → xray domain (geosite passthrough needs geodata). ship/manage geosite.dat.
dst domain-list (ruleset) PARTIAL inline entries via generate.go:583 expandRuleset; only inline source works (see §6). —
dst ip / geoip / ip-list PARTIAL generate.go:449 → xray ip; geoip passthrough; ip-list inline only. geodata + url/file lists.
dst port / range / list DONE generate.go:452 passes DstPort string through. —
proto tcp/udp DONE generate.go:455 normalizeProto. —
target chain/group/node/direct/block DONE generate.go:477 resolveTarget + setTargetTag generate.go:598. —
egress-binding STUB uci.go:119 parses rule.egress; model.go:139 Rule.Egress; never read in buildRoutingRules. Model.Egresses is never used in BuildConfig. STATUS.md line 32 admits this. Render egress: interface→sockopt.mark + policy route to that iface; proxy→chain/group tag.
kill-mode (per-rule) STUB uci.go:120 parses rule.kill; never rendered. Global kill_switch=closed also never forced (STATUS.md line 35). When effective kill=closed, emit a trailing outboundTag:block catch-all / fail-closed route.
per-client policy UI MISSING Only raw Rules grid; no device→target convenience UI. Add per-client policy view atop rules (src=host → target).
explain / trace PARTIAL status.go:120 ExplainJSON (CLI + rules.js widget). geosite/geoip return false (status.go:238 — no geodata); egress/kill echoed from model but egress isn't actually applied. Load geodata for offline match; reflect real egress once rendered.

5. Egress selection (iface / tunnel / chain / direct)

STUB. uci.go:89 egress section is parsed into Model.Egresses (model.go:107), but BuildConfig never touches m.Egresses and buildRoutingRules never reads r.Egress. No interface/tunnel binding reaches policy routing or xray sockopt. No egress LuCI page. To complete: render egress name→(a) type=interface: outbound streamSettings.sockopt.mark + an ip rule/table to that device; (b) type=proxy: resolve target to a chain/group tag; (c) direct/block. Add a page.

6. Lists / Rulesets

Source Status Evidence To complete
inline PARTIAL generate.go:583 expandRuleset returns rs.Entries inline into a rule's domain/ip arrays. Works for xray routing only. —
file MISSING uci.go:103 parses path; never read/loaded. Load file into entries at gen time.
url (auto-update) (T1) MISSING url/update_interval/format parsed (uci.go:101-104); no fetch, no timer, no cache. Fetch+cache+timer like subscriptions; format adapters.
format adapters (plain/clash/geosite) MISSING Format field ignored; only raw entries used. Implement plain/clash-provider/geosite adapters.
Rendered to nftset (domain-list→dnsmasq nftset, ip-list→nft set) MISSING RenderNft (apply.go:211) has no sets; dnsmasq config not generated. Rulesets only inlined into xray routing. Emit nft sets + dnsmasq nftset= lines for DNS-consistent routing.
Lists LuCI page MISSING No ruleset view. Add one.

7. DNS

Capability Status Evidence To complete
Named resolvers (DoH/DoT/plain/local/FakeIP) STUB settings.js:98 UI + uci.go:122 parse. But generate.go:537 buildDNS only emits a flat servers list of r.Address — type (doh/dot/local), detour, and FakeIP pool are all ignored. FakeIP only sets queryStrategy:UseIP (generate.go:548). Emit per-server xray dns objects with address/detour/domains; real FakeIP pool.
per-domain / per-client DNS routing STUB dns_rule parsed into Model.DNSRules (uci.go:129); buildDNS never reads m.DNSRules. STATUS.md line 33 admits it. Render dns_rules into xray dns.servers[].domains + client-source scoping.
hijack :53 + block client DoT/DoH MISSING No dnsmasq redirect and no nft rule blocking 853/DoH in RenderNft. Add nft redirect of LAN :53→router and drop/redirect DoT/known-DoH.
split-DNS (resolved==routed) MISSING No nftset population; direct vs proxied resolver split not emitted. Tie DNS answers to nftset used by routing.
nftset for routing MISSING dns_mode=nftset is the default but RenderNft emits no sets and no dnsmasq nftset=. Generate nft sets + dnsmasq integration.
IPv6 mirror PARTIAL applyRouting does -4/-6 (apply.go:257); nft has ip6 mgmt bypass. DNS side has no v6 handling. v6 DNS servers/sets.

8. Reliability / Ops

Capability Status Evidence To complete
Atomic apply DONE apply.go:35 writeJSON (tmp+rename); apply.go:177 nft -c then -f; test-before-swap apply.go:70. —
commit-confirm PARTIAL apply.go:95 arms; armAutoRollback (apply.go:276) is a detached sh -c "sleep N; … rollback". Survives, but crude and unsupervised. Use a procd/atd-style supervised timer; record intended timeout in status.
rollback PARTIAL (incomplete) apply.go:113 Rollback restores run.json + reloads xray only — it does not revert the inet shater nft table or ip rule/route. A bad nft/routing apply is not undone. Snapshot+restore nft table and routing in rollback too.
hotplug-persist PARTIAL/unverified Reconcile (apply.go:127) is the intended hook; the hotplug script lives in the shater-core package (not in the audited tree). Confirm hotplug calls xrayctl reconcile; not verifiable here.
watchdog MISSING No watchdog loop in xrayctl; Reconcile exists but nothing periodically calls it. Add a procd respawn/watchdog that pings xray + reconciles.
kill-switch (fail-closed/open) STUB Globals.KillSwitch/Rule.Kill parsed; never rendered. Default closed is not enforced (traffic falls through to direct — generate.go:68 freedom is the baseline default). Effectively fail-open regardless of setting. Emit trailing block rule when effective policy is closed.
mgmt-bypass DONE (basic) apply.go:227-229 unconditional RFC1918 + loopback + multicast + loop-mark bypass in nft prerouting. Consider explicit SSH/LuCI port carve-outs for edge cases.

9. Stats

Capability Status Evidence To complete
per-node (xray Stats API) STUB Dashboard renders a per-node table (overview.js:124), but generated config has no api/stats/policy blocks (BuildConfig keys generate.go:92), so xray exposes no counters. StatsJSON (status.go:105) never queries xray. Table is always empty. Emit api{services:[StatsService]}+stats{}+policy + a local API inbound; query it in StatsJSON.
per-client (nft counters) STUB RenderNft has only two aggregate counter tokens on the tproxy accept lines (apply.go:236,240) — no per-saddr set/map. StatsJSON dumps raw nft -j list table with no per-client breakdown. UI leaderboard (overview.js:136) stays empty. Add an nft per-source counter map and parse it.
per-rule STUB No per-rule counters emitted; UI table (overview.js:143) empty. Tag rules with nft counters or xray per-rule stats.
Dashboard PARTIAL overview.js renders status cards + 3 stat tables and polls every 5s, but all traffic/throughput/uptime fields are absent from StatusJSON (status.go:16 has no throughput/uptime/active-node), so cards show -. Populate status with live throughput/active node/uptime.

10. LuCI pages — CRUD / live data / apply

Existing pages (menu.d): overview, nodes, subscriptions, rules, settings.

Page CRUD Live data Saves→UCI / applies Notes
Overview n/a ✅ polls status+stats Apply/Confirm/Reload buttons call ubus (overview.js:11-13) Data mostly empty (see §9). Apply button OK.
Nodes read-only ✅ nodes, node_test no add/remove nodes.js — Test + "Select" (Select just redirects to Rules, nodes.js:96). No manual-node add.
Subscriptions ✅ full grid CRUD Update-now buttons (subscriptions.js:89) ✅ form.Map on xray Solid. Save commits UCI; apply separate.
Rules ✅ full grid CRUD + explain widget explain live ✅ form.Map Good; but egress/kill fields don't render into output (§4).
Settings ✅ globals+inbounds+resolvers+dns_rules — ✅ form.Map resolvers/dns_rules are cosmetic until §7 renders them.

Missing pages: Groups, Chains, Egress, Lists/Rulesets, standalone Resolvers/DNS-rules (currently only in Settings), Profiles, Nodes-add/Import, per-client policy, Stats/graphs history.

rpc/acl/ucode consistency: ✅ All frontend rpc.declare methods (status, stats, apply, confirm, reload, nodes, node_test, sub_update, explain) exist in shater.uc (return {xray:{…}}) and are all granted in acl.d/luci-app-shater.json. No mismatches found.

11. Profiles / WAN-mode (T2 — listed for completeness)

MISSING. No Profile type in model.go, no profile case in uci.go, no UI. CONTRACT.md §profile is entirely unimplemented.


Notable bugs / dead code found

  1. cidrsOnly is misnamed (generate.go:653) — it only trims empties; MAC/ iface/zone src values leak into xray source (invalid). §4.
  2. Rollback is partial (apply.go:113) — reverts xray but not nft/routing.
  3. Model.Egresses dead — parsed, never consumed by any generator. §5.
  4. DNSRules, resolver type/detour, ruleset url/file/format, per-sub update_interval, fetch_via, rule.kill/egress are all parsed-but-never- rendered — the UCI schema promises far more than the generator emits.
  5. Kill-switch semantics inverted from intent — default closed behaves fail-open because the baseline outbound is freedom/direct and no block catch-all is emitted.
  6. Observatory emitted but never read back — nodes always report alive:false.
  7. node_test measures endpoint TCP reachability, not through-proxy delay — misleading "latency"/"alive" for a proxy node.

Prioritized TODO (most foundational first)

  1. Render egress binding + kill-switch (§4/§5/§8) — these are core routing semantics already in the schema/UI but producing no output; fixes the biggest "configured but silently ignored" class. Add block catch-all for fail-closed.
  2. Fix src matching (§4 bug 1) — route MAC/iface/zone to nft; keep only real CIDRs in xray source. Prevents invalid configs.
  3. DNS rendering (§7) — per-resolver objects, dns_rules, nftset + dnsmasq hijack/split; without this "resolved==routed" and leak-prevention don't hold.
  4. Rulesets: file + url sources + nft sets (§6) — needed by rules/DNS above.
  5. Complete rollback to snapshot/restore nft + routing (§8 bug 2), and move commit-confirm/watchdog onto a supervised timer.
  6. Stats plumbing (§9) — enable xray Stats API + per-client nft counter map; fill Overview status (throughput/active-node/uptime). UI already exists.
  7. Observatory read-back + real node latency (§2) — surface live ping/alive.
  8. Missing LuCI pages: Groups, Chains, Egress, Lists, Nodes-add/Import, per-client policy. (Backend for chains/groups already exists; UI is the gap.)
  9. Subscription scheduling (§1) — per-sub timers; fetch_via=proxy; userinfo (quota/expiry) parse + alert.
  10. failover strategy real priority order (§2); geodata management for geosite/geoip in both generate and explain.
  11. Profiles / WAN-mode (T2) — model + generator + UI from scratch.