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
defaultIface() now asks the kernel authoritatively which interface it would egress
a public destination through (`ip route get 8.8.8.8`/`1.1.1.1`) instead of parsing
`ip route show default` by metric. This is correct for multi-WAN / mwan3 / policy-
routing setups where the active uplink is chosen by metric AND ip rules — the query
carries no fwmark so it reflects the real WAN egress, not the tproxy loopback table.
Falls back to the lowest-metric default route if `ip route get` is unavailable.
Clarifies the two orderings: which INTERFACE is active = kernel route metric; which
PROFILE applies = profile priority among those whose conditions all hold.
Verified live: `ip route get 8.8.8.8` -> eth1; a profile matching dum0 with HIGHER
priority stays inactive (its iface condition fails) while the eth1 profile (lower
priority, condition holds) is active — priority never overrides an unmet condition.
- profile_wanmode.go: defaultIface -> ip route get + devFromRouteGet +
lowestMetricDefaultIface fallback.
- test: TestDevFromRouteGet. r17.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Profiles page was a stub for the actual catalog §7 feature (WAN-mode / failover
conditional overrides); this implements it. A `config profile` defines conditions
(active default-route interface, a connectivity probe up/down, a time window — all
AND'd) and overrides (force-enable/disable named rules, override the default
catch-all target/egress). The highest-priority profile whose conditions all hold is
active; its overrides are applied at gen/reconcile time and the cron re-applies when
the active profile flips.
- model.go/uci.go: Profile struct + `config profile` parse.
- profile_wanmode.go: defaultIface() (ip route), profileProbeUp() (HTTP), condition
eval, activeWanProfile() (priority + AND conditions; no-condition profile never
auto-activates), ProfileStatusJSON. strSet helper.
- generate.go: builder.activeProfile set in buildConfigInternal; buildRoutingRules
applies enable/disable-by-name + injects a default-target catch-all when active.
- schedule.go: scheduleSignature includes the active profile name, so shater-cron
reconciles on a profile transition (iface/probe/time boundary).
- main.go: `xrayctl wanmode`. shater.uc `wanmode` ubus + acl.
- profiles.js: rewritten to host WAN-mode Profiles (config profile GridSection) +
active-profile banner + Config snapshots + Backup/Restore + xray compatibility.
- tests: profile_wanmode_test.go (iface/schedule/AND conditions, priority selection,
no-condition never active, override enable/disable, default-target injection,
inactive-no-override).
Verified live on the 512M VM: `wanmode` reports active sim-mode (iface eth1);
force-enabled a disabled rule (profileonly.example appears); flipping the iface
condition deactivates it; schedule condition active at 22:30 / inactive at 12:00;
xray -test OK. Playwright: Profiles page renders the WAN-mode form + active banner +
snapshots + backup + compat with 0 console errors. r16.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Preset packs: `config preset` toggles (block-ads / ru-bypass / private) inject
synthetic rules ahead of user rules (by low Order, first-match). They flow
through the same geoStrip pipeline, so geo-only packs degrade gracefully.
Empty-matcher guard (fixes a block-everything trap): a rule that HAD dst matchers
but lost them ALL to the geo-strip and has no other selector is now DROPPED — not
promoted to a tcp,udp catch-all. So a geo-only block-ads with no geodata fails
open (ads unblocked) instead of blackholing the LAN.
Schedule rules: xray has no time match, so buildRoutingRules consults
ruleActiveNow(timeNow()) and skips out-of-window rules — a plain gen/reconcile at
any instant emits the correct ruleset. `xrayctl schedule due` (shater-cron hook)
reconciles only at window boundaries. Wrap-around windows + day-of-week + optional
tz supported; malformed windows fail open.
- model.go: Preset + Rule.Sched* fields; uci.go parses config preset + sched_*.
- preset.go, schedule.go (new); generate.go: preset injection + schedule gate +
empty-matcher guard; main.go: `schedule due`. timeNow seam (SHATER_FAKE_NOW).
- shater-cron: reconcile on schedule boundary; uci-defaults seeds the 3 presets.
- rules.js: Preset packs panel + per-rule schedule fields.
- tests: schedule_test.go, preset_test.go (windows/wrap/dow/fail-open, preset
inject/override/drop, scheduled-rule inclusion).
Verified live on the 512M VM: block-ads→geosite rule, private→10.0.0.0/8 direct;
geodata-absent drops block-ads (0 matches, no block-all); example.com scheduled
rule absent@12:00 present@22:30; schedule due fires at boundary; xray -test OK. r12.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a Type discriminator to `config inbound` (tproxy|socks|http|dokodemo);
absent Type => tproxy, so existing configs are byte-identical. Local socks/http
listeners and the dokodemo-wrap listener get no sockopt/tproxy and are covered by
the same routing rules (no dedicated inboundTag), so their traffic follows user
policy.
Critical fix: RenderNft/nftEnabledInboundDevs/nftPrimaryInbound now filter on
isTproxyInbound() — previously EVERY enabled inbound injected a LAN tproxy divert,
so a local socks listener would have wrongly diverted LAN traffic to its port.
- model.go: Inbound.{Type,Listen,Port,Auth,User,Pass,TargetAddr,TargetPort,
TargetNetwork} + inboundType()/isTproxyInbound(); uci.go parses them.
- generate.go: buildInbounds dispatches by type (emitTproxyInbound/
emitLocalProxyInbound/emitDokodemoInbound); sniff default off for dokodemo.
- apply.go + nftstats.go: only tproxy inbounds participate in the nft plane.
- settings.js: type selector + dependent listener/auth/target fields.
- tests: inbound_local_test.go (socks/http/dokodemo emit, password auth, legacy
tproxy default, TestNftIgnoresNonTproxyInbounds).
Verified live on the 512M VM: socks inbound {protocol:socks,port:1080,udp:true}
→ xray -test OK; nft does NOT contain port 1080; listener up on 127.0.0.1:1080;
mgmt-bypass chain intact. r11.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Nodes are URI-only, so WireGuard is a new share-link scheme handled in
ParseShareLink — the generator, fingerprint, probe, chain, group and egress
paths all keep working unchanged (no model.go/generate.go control-flow edits).
- sharelink.go: wireguard://|wg:// dispatch → parseWireguard (emits xray
"wireguard" outbound; no streamSettings so withMark owns the loop-guard mark).
- wireguard.go (new): wgConfig, parseWGConf (wg-quick/AmneziaWG INI), wgConfigToURI,
wgAWGSupported flag (default off — mainline xray 25.1.30 lacks AWG obfuscation),
helpers splitCSV/atoiOr/splitEndpoint/parseReserved/toAny3.
- sub.go: schemePrefixes adds wireguard/wg; ImportNodes converts a pasted .conf to
a wireguard:// URI; extractIdentity fingerprints WG by peer endpoint+publicKey.
- main.go: wireguard selftest fixture. nodes.js: URI placeholder/help mentions WG.
- tests: wireguard_test.go (parse/defaults/missing, .conf round-trip, mark,
fingerprint uniqueness, generate, import).
Verified live on the 512M VM: xray 25.1.30 ACCEPTS the wireguard outbound
(xray -test OK); endpoint 203.0.113.10:51820, sockopt.mark==255. r10.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds optional per-node multiplexing and socket options, applied after
ParseShareLink at all three outbound build sites (group members, standalone
node targets, chain hops) and BEFORE withMark so the loop-guard escape mark
(255) is always re-asserted last and wins — a per-node mark that is neither 0
nor 255 is refused (would break the nft escape rule → routing loop).
- model.go: Node.{Mux,MuxConcurrency,XUDPConcurrency,XUDPProxyUDP443,Mark,
TCPFastOpen,TCPKeepAliveIdle}; uci.go parses them. All zero-value = off, so
existing nodes emit byte-identical outbounds.
- generate.go: applyNodeOpts() emits outbound-level `mux` (XUDP keys only for
vless/vmess) + streamSettings.sockopt tcp knobs; skips mux under XTLS Vision.
- nodes.js: modalonly mux/XUDP/sockopt fields (depends on mux).
- tests: node_opts_test.go (mux emitted/off, XUDP gating, vision skip,
loop-guard mark wins, tcp knobs).
Verified live on the 512M VM: mux node emits {enabled,concurrency:8,
xudpConcurrency:16,xudpProxyUDP443:reject}; sockopt.mark==255 preserved;
xray -test OK. r9.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ~25 MB geo data files are no longer a hard dependency (critical on
small-flash routers). The plugin works without them; the generator strips
geosite:/geoip: matchers from routing rules and the dns object when the data
is absent so the config stays valid and deterministic. Users download them on
demand — only when there is disk to spare — and remove them to reclaim flash.
- xrayctl/geodata.go: `geodata status|download|remove`; free-space check via
`df -k`; opkg/apk install of v2ray-geoip/v2ray-geosite + asset-dir symlinks;
errors reported in-band (JSON `error`) for the UI.
- generate.go/dns.go: builder.geoOK = geoAssetPresent(); geoOK threaded into
dnsRender; geoStrip() drops geo matchers when absent.
- LuCI: geodata panel on the Lists page (presence, sizes, free/need, Download/
Remove buttons gated on free space); ubus geodata_status/download/remove + acl.
- tests: TestGeoStrip, TestDNSRenderGeoOptional, TestBuildConfigStripsGeoWhenAbsent.
Verified live on the 512M VM: status reports present+sizes+free; xray 25.1.30
starts without geodata (lazy-load); ubus wiring returns correct JSON. r8.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Records live-VM proof for EVERY MVP/T1 catalog item (nodes/subs/HAPP/hwid, all six
balancer strategies, chains, full rule matcher set incl. MAC/iface/geosite/geoip,
egress iface/tunnel/proxy, lists, DNS DoH/FakeIP/nftset/hijack/DoT-block/IPv6,
reliability commit-confirm/rollback/watchdog/kill-switch/hotplug, per-client &
per-rule stats, LuCI CRUD via Playwright, CI both arches, feed install+upgrade).
Two bugs found & fixed during the sweep (balancer observatory; group probe_url
override). PKG_RELEASE -> 7.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The group parser defaulted probe_url/probe_interval to gstatic/60s via optOr, so
EVERY group carried a non-empty ProbeURL that overrode the new global observatory
setting in newBuilder — the Settings "Health-check URL" never took effect. Groups
now start empty and only override when explicitly set; the built-in default lives in
newBuilder. Verified: setting globals.probe_url -> the generated observatory block
uses it (cloudflare/30s), xray -test OK.
Also bumps PKG_RELEASE 5->6 across the packages for the probe/observatory feature.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PKG_RELEASE 4->5 for the Nodes Test fix, Overview dashboard redesign, and egress
exit-interface data-plane. PROOFS.md updated with the live-VM evidence; verified via
opkg upgrade r4->r5 and Playwright over all 11 pages.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
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.