Commit Graph
3 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 080cbc594d ci: move packages to repo root so gh-action-sdk feed finds them
build / aarch64_cortex-a53 (push) Failing after 2m11s
build / arm_cortex-a7_neon-vfpv4 (push) Failing after 2m19s
build / mipsel_24kc (push) Failing after 1m51s
build / x86_64 (push) Failing after 3m49s
CI failed: 'No feed for package xrayctl found' / 'No rule to make target
package/xrayctl/download' — gh-action-sdk indexes packages at the feed (repo)
ROOT, not a nested package/ dir. Moved xrayctl/, luci-app-shater/, shater-core/
to root; fixed workflow comment and doc paths.
2026-07-09 02:36:22 +03:00