Commit Graph
5 Commits
Author SHA1 Message Date
omarandClaude Opus 4.8 65883e20d9 feat(core): fail-safe hardening — live-flag, watchdog, procd fixes
Close the "rules live, engine dead" LAN-blackout class and make an admin
`stop` durable:
- live-flag /var/run/shater.active gates hotplug/cron reconcile, so `stop`
  sticks — a WAN flap can no longer resurrect interception behind a stopped
  engine.
- procd respawn retry=0 (never abandon the engine while rules stand) + guard
  that /usr/bin/xray is executable before installing the data plane.
- shater-cron watchdog: engine dead N ticks with interception live escalates
  per kill_switch (open -> auto-stop/fail-open, closed -> crit log).
- fix procd cron detach: `command "$INIT_SCRIPT" loop` (rc.common dispatch)
  instead of `/bin/sh $INIT_SCRIPT loop`, which detached the loop from procd
  (running:false + respawn churn) — the auto-updater/watchdog ran unsupervised.
- run.json regenerated at start after sysupgrade; cron stamps only on success
  with backoff, and waits for a default route before boot-time fetches.
- sysctl route_localnet/accept_local scoped to lo (was all — WAN anti-spoof
  weakening); applied at install time so no reboot is needed.
- fix stale example filenames; bump shater-core to r19.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LLthkP2S8WAfxu7fcYbPfE
2026-07-13 03:37:26 +03:00
omarandClaude Opus 4.8 05920f83ad fix: eliminate reconcile fork-storm (OOM) + resolve UCI config conflict with xray-core
build / aarch64_cortex-a53 (push) Successful in 3m0s
build / x86_64 (push) Successful in 2m59s
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
omar 71a6f127a1 T1 features: egress, kill-switch, full DNS, stats/API, rulesets, live nodes, sub scheduling, all LuCI pages (4-agent build + integration); real xray -test 'Configuration OK' with full-feature config
build / aarch64_cortex-a53 (push) Successful in 3m2s
build / x86_64 (push) Successful in 3m1s
2026-07-09 10:12:55 +03:00
omar d3af5580fd MVP core: xrayctl (parse+gen validated by real xray -test on OpenWrt), luci-app-shater, shater-core, CI/feed, examples, contract
build / arm_cortex-a7_neon-vfpv4 (push) Has been cancelled
build / mipsel_24kc (push) Has been cancelled
build / x86_64 (push) Has been cancelled
build / aarch64_cortex-a53 (push) Has been cancelled
- xrayctl Go daemon: share-link parser (vless/vmess/trojan/ss + reality/xhttp/ws/grpc), UCI->model, config generator, sub fetch+fingerprint+reconcile, apply/nft/routing, status/explain; go build/vet/test green
- fix: routing rule with no matcher -> inject tcp,udp catch-all (xray 'no effective fields'); regression test added; 'Configuration OK' on real xray 25.1.30
- luci-app-shater: JS views (overview/nodes/subs/rules/settings) + ucode ubus backend + acl (verified)
- shater-core: procd init + hotplug + sysctl + inert default config (sh -n clean)
- CI: gh-action-sdk matrix (x86_64/aarch64_cortex-a53/+2), signed feed; BUILD.md; dist/
- examples: full+minimal /etc/config/xray, share-link fixtures
- CONTRACT.md: UCI schema + xrayctl CLI/ubus interface
2026-07-09 00:40:53 +03:00
omar 2f021c1a1a Design blueprint: architecture, feature catalog, data model, ops, roadmap (docs 00-07) 2026-07-08 23:49:28 +03:00