Commit Graph
40 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 f1e4f16a9f fix(profiles): pick the active uplink via ip route get (metric/policy-aware)
build / aarch64_cortex-a53 (push) Successful in 3m29s
build / x86_64 (push) Successful in 3m17s
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>
2026-07-09 17:16:16 +03:00
omarandClaude Opus 4.8 6c01d8db41 feat(profiles): WAN-mode / conditional-override profiles [T2] — the real §7 feature
build / aarch64_cortex-a53 (push) Successful in 3m11s
build / x86_64 (push) Has been cancelled
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>
2026-07-09 17:11:19 +03:00
omarandClaude Opus 4.8 21ee972df1 feat(luci): bulk-actions, live-connections, QR export, client-side filters [T1/T2]
build / aarch64_cortex-a53 (push) Successful in 3m3s
build / x86_64 (push) Successful in 3m2s
- nodeops.go: node enable|disable|delete|group (UCI mutation by name; group-assign
  dedups) + node qr (qrencode -t SVG, soft dependency with graceful error).
- conns.go: ConnsJSON from conntrack -L or /proc/net/nf_conntrack, bounded/sorted,
  best-effort outbound label (selected node vs direct). status URI field for QR.
- main.go: node enable/disable/delete/group/qr + `conns` dispatch.
- LuCI nodes.js: per-row selection checkboxes + select-all, bulk action bar
  (enable/disable/delete/assign-to-group/test), client-side filter bar
  (name/proto/alive/country via flag-emoji), per-row QR/Link modal.
- live.js (new): poll-based conntrack flow table; menu entry + acl.
- shater.uc: conns/node_qr(read) + node_enable/node_delete/node_assign_group(write)
  ubus methods + acl.
- tests: conns_test.go (parseConntrack both formats, isPrivateOrLocal).

Verified live on the 512M VM: enable/disable toggles UCI; group-assign dedups
("bulk1 bulk2"); delete removes; qr errors gracefully (qrencode absent); conns
reads /proc/net/nf_conntrack; nodes carries uri; all 5 ubus methods registered.
Playwright: Nodes page renders with 0 console errors, 12 menu items.

Also re-verified the full LAN-client E2E after all 7 features: netns client
192.168.1.60/.61 -> tproxy -> xray -> exit 104.156.233.234 (!= WAN 45.131.214.140),
c_rule_lan_proxy counter 26 pkts, both clients in the nft clients set, 184/254
nodes alive. The control-plane changes did not break the data-plane. r15.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 16:23:06 +03:00
omarandClaude Opus 4.8 c8fe02677f feat(sub): Clash/Xray/sing-box formats + name/proto/country filters + dedup + userinfo [T1/T2]
build / aarch64_cortex-a53 (push) Successful in 3m3s
build / x86_64 (push) Successful in 3m10s
Subscription bodies can now be Clash/Mihomo YAML, Xray JSON, or sing-box JSON —
all converge to share-link URIs (the cache stays link-based, so fingerprint/
reconcile/generate are unchanged). stdlib-only: the Clash parser is a focused
subset parser for the proxies: list (flow-style + shallow block-style with one
nesting level for ws/grpc/reality opts), not a general YAML engine.

- subformat.go: DetectSubFormat (override -> content-type -> byte sniff) +
  ParseSubBody dispatch + value helpers + streamQuery/synthLink/ssLink.
- subformat_parsers.go: parseClashProxies (indentation-preserving item collector
  + flow/block YAML node parser), parseXrayOutbounds, parseSingboxOutbounds.
- subfilter.go: FilterSpec + subApplyFilters (name include/exclude regex, proto
  whitelist, country via flag-emoji->ISO or token, dedup by fingerprint).
- sub.go: FetchSubscriptionFull passes Content-Type + Format to ParseSubBody;
  SubUpdate filters before reconcile; ImportNodes accepts pasted Clash/JSON;
  SubUserinfoView + SubInfoJSON (days_left/pct_used/expiring/exhausted).
- model/uci: Subscription.{Format,Include,Exclude,FilterProto,FilterCountry,
  Dedup,ExpireAlertDays} + Group.{FilterProto,FilterCountry,Dedup}; generate.go
  resolveGroupMembers applies group-level proto/country filter + optional dedup.
- main.go: `sub info`. LuCI: subscriptions.js format+filter fields; sub_info ubus + acl.
- tests: subformat_test.go (clash flow/block/skip-unknown, xray, singbox, detect,
  exclude/proto/country/dedup filters, flag->ISO).

Verified live on the 512M VM: Clash import (3 nodes, flow+block); Clash
subscription over uhttpd -> 2 nodes, xray -test OK (valid reality key); exclude
(?i)RU dropped the RU node; sub info works. r14.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 16:05:00 +03:00
omarandClaude Opus 4.8 b8cb0c4537 feat(ops): backup/restore, config profiles, schema migration, xray-compat [MVP/T1/T2]
build / aarch64_cortex-a53 (push) Successful in 3m4s
build / x86_64 (push) Successful in 3m1s
- backup.go: `backup` (tar.gz of /etc/config/shater + sub caches + manifest, to
  stdout or --file); `restore` validates the STAGED config with xray -test BEFORE
  swapping, snapshots the current config as .pre-restore, swaps atomically,
  migrates forward, and applies with commit-confirm (bad restore can't brick mgmt).
  untarInto rejects path traversal (Zip-Slip guard).
- profile.go: named config snapshots under /etc/xray/profiles/<name>.tar.gz;
  save|list|switch|delete; switch reuses the restore safety path + records active.
- migrate.go: ordered idempotent UCI schema migrations (CurrentSchemaVersion=1;
  v0→v1 folds legacy globals.kill→kill_switch); refuses a newer schema; injectable
  uciRunner for hermetic tests. ensureGlobals() creates the named globals section
  when absent so option writes never fail.
- compat.go: detect xray version vs the feature set the config uses (reality/
  vision/xhttp/observatory/fakeip) with a semver check; surfaced in status too.
- model/uci: Globals.SchemaVersion + ActiveProfile. main.go: 5 new commands.
- shater-core: migrate before reconcile (init.d/shater) + on upgrade (uci-defaults);
  config ships schema_version '1'.
- LuCI: profiles.js rewritten into Backup/Restore + Config profiles + xray
  compatibility cards; shater.uc +7 ubus methods + acl; menu retitled.
- tests: ops_test.go (backup round-trip, traversal reject, restore reject
  non-backup/newer-schema, migrate transform/idempotent/refuse-newer, semverGE,
  requiredFeatures, profile save/list/delete, sanitizeProfile).

Verified live on the 512M VM: backup→change→restore reverts loglevel (rc0,
mgmt survives); migrate 0→1 folds kill→kill_switch; profile switch tracks active;
compat reports 25.1.30 ok; all 7 ubus methods registered + return valid JSON. r13.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 15:54:36 +03:00
omarandClaude Opus 4.8 3449ff32fc feat(routing): preset packs [T1] + schedule rules [T3]
build / aarch64_cortex-a53 (push) Successful in 3m4s
build / x86_64 (push) Successful in 3m3s
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>
2026-07-09 15:41:36 +03:00
omarandClaude Opus 4.8 a08aac62e6 feat(inbounds): local SOCKS/HTTP + dokodemo inbounds [T1/T2]
build / aarch64_cortex-a53 (push) Successful in 3m11s
build / x86_64 (push) Successful in 3m4s
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>
2026-07-09 15:33:08 +03:00
omarandClaude Opus 4.8 ad272af260 feat(nodes): WireGuard / AmneziaWG outbound via wireguard:// scheme [T2]
build / aarch64_cortex-a53 (push) Successful in 3m31s
build / x86_64 (push) Has been cancelled
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>
2026-07-09 15:27:22 +03:00
omarandClaude Opus 4.8 ee7df9f3a1 feat(nodes): per-node mux/XUDP + sockopt (TCP FastOpen/keepalive, mark) [T1]
build / aarch64_cortex-a53 (push) Successful in 3m1s
build / x86_64 (push) Has been cancelled
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>
2026-07-09 15:22:39 +03:00
omarandClaude Opus 4.8 146ae252cc feat(geodata): make geoip.dat/geosite.dat optional + on-demand download
build / aarch64_cortex-a53 (push) Successful in 2m59s
build / x86_64 (push) Successful in 3m0s
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>
2026-07-09 15:11:11 +03:00
omarandClaude Opus 4.8 ef1c563293 docs(status): full 05-feature-catalog verification matrix; bump to r7
build / aarch64_cortex-a53 (push) Successful in 3m0s
build / x86_64 (push) Successful in 4m4s
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>
2026-07-09 14:27:07 +03:00
omarandClaude Opus 4.8 46dc9bfa34 fix(balancer): random/roundRobin strategies also need the Observatory
xray 25.1.30 resolves EVERY multi-member balancer's health checker from the
Observatory, so `random` and `roundRobin` groups failed `xray -test` with "not all
dependencies are resolved" — the Observatory was only emitted for
leastPing/leastLoad/failover. genUsesObservatory now returns true for random and
roundRobin too; `single` (no balancer) still skips it.

Verified live: all six strategies (leastping/random/roundrobin/failover/leastload/
single) now pass `xray -test`; the balancer strategy object + observatory presence
are correct for each.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 14:11:52 +03:00
omarandClaude Opus 4.8 530d6d467b docs(proofs): record configurable reachability checks (observatory + http/chain probes)
build / aarch64_cortex-a53 (push) Successful in 3m1s
build / x86_64 (push) Successful in 3m7s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 13:58:38 +03:00
omarandClaude Opus 4.8 73f6c7a3c5 fix(probe): let globals.probe_url actually win; bump packages to r6
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>
2026-07-09 13:58:09 +03:00
omarandClaude Opus 4.8 961dfe4d76 feat(probe): configurable reachability checks — observatory settings + on-demand HTTP/chain probes
Answers "how is a node 'reachable' decided, and can I configure it?".

* Observatory (the node "alive"/latency in Overview & Nodes) is xray fetching a
  probe URL THROUGH each node every interval. That URL + interval are now global
  settings (globals.probe_url / probe_interval, exposed on the Settings page) used
  as the default; a group can still override. Default stays gstatic/generate_204.

* On-demand Node "Test" is now method-selectable, TCP stays the default:
  - tcp  (fast): raw endpoint connect (unchanged behaviour).
  - http: a REAL proxy-path GET/HEAD through the node — spins an ephemeral xray
    (local SOCKS inbound routed through the node), does the request over a tiny
    stdlib SOCKS5 client, and reports status + latency + exit IP. No new deps.
  `xrayctl node test NAME --method http [--url U] [--http-method GET|HEAD]`.

* Chain reachability ("проверку связки"): `xrayctl chain test NAME` probes the WHOLE
  multi-hop chain end-to-end (reusing the real chain machinery incl. its internal
  socks-hop routing) and reports reachable/latency/exit IP. Exposed on the Chains
  page (select a chain -> Test chain).

ubus: node_test gains method/url/http_method; new chain_test (acl updated).

Verified live: node http probe DE-vless-8 -> 200 exit 91.107.150.14; chain
DE-vless-8->NL-ss-4 -> 200 379ms exit 193.29.139.249 (matches the tproxy E2E); UI
selector, chain Test button, and Settings fields all work via Playwright.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 13:54:22 +03:00
omarandClaude Opus 4.8 be323ad2b6 chore: bump packages to r5; record panel-polish proofs (Nodes/Overview/Egress)
build / aarch64_cortex-a53 (push) Successful in 3m1s
build / x86_64 (push) Successful in 3m1s
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>
2026-07-09 13:26:01 +03:00
omarandClaude Opus 4.8 89de2556a2 feat(egress): wire the interface/tunnel exit-binding data-plane end-to-end
egress.go emitted a SO_BINDTODEVICE+SO_MARK freedom outbound for interface/tunnel
egresses, but its documented "apply.go SHOULD add the policy routing" half was never
implemented, and it bound to the UCI name (wan) rather than the L3 device (eth1), so
a rule bound to an interface egress did not actually leave via it.

Now:
  * egress.go resolves the egress interface to its L3 device (ifaceDevice) for
    sockopt.interface, so SO_BINDTODEVICE binds the real device.
  * apply.go installs the policy-routing half: for each interface/tunnel egress i,
    `ip rule fwmark <egEgressMark> lookup <egEgressTable>` + a default route in that
    table out the device — `via <gw>` for gateway'd WANs, plain `dev` for p2p
    tunnels (wg/awg) — plus an nft prerouting `meta mark <egmark> accept` bypass.
    Wired into applyRouting; torn down in apTeardown.

Verified live: a rule bound to egress=interface(wan) routes there (explain shows the
egress), the outbound carries "interface":"eth1", table 8208 gets
`default via 10.0.2.2 dev eth1`, and the LAN client exits through it to the internet.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 13:20:57 +03:00
omarandClaude Opus 4.8 c412ae1afe feat(luci): fix Nodes latency/Test + redesign Overview dashboard
Nodes page: the Latency column read n.latency but the API emits latency_ms, so it
always showed "-" ("no ping"). Now reads latency_ms (0 => "not probed" => "-"),
sorts by it, and the Test button does a real on-demand TCP probe: node_test returns
{probe:[{name,alive,latency_ms}]} straight from `xrayctl node test`, the row shows
the RTT with a ✓, and a toast reports alive/latency. NodeTest now probes
concurrently (bounded 32) so "Test all" over 250+ nodes finishes in seconds instead
of many minutes of serial 5s dials.

Overview: replaced the all-250-rows-of-0B dump with a real dashboard — KPI cards
(engine up/enabled/api, live nodes X/Y, download/upload rate+total, active clients,
active node), curated tables (only nodes/clients that carried traffic, with share
bars), client-side rate from poll deltas, theme-aware styling. Now also calls the
nodes method for the alive count/active node.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 13:14:05 +03:00
omarandClaude Opus 4.8 196ec39c8b docs(proofs): record CI green on x86_64 + aarch64_cortex-a53 for final HEAD
build / aarch64_cortex-a53 (push) Successful in 3m0s
build / x86_64 (push) Successful in 2m59s
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:35:28 +03:00
omarandClaude Opus 4.8 e7b71d7415 docs(status): v1 acceptance on live 512M OpenWrt VM — all items verified
build / aarch64_cortex-a53 (push) Successful in 4m11s
build / x86_64 (push) Successful in 2m59s
Records the full v1 acceptance matrix (install/upgrade from feed, keystone E2E,
subscriptions, observatory, multi-hop chain, per-client, explain, DNS split,
reliability/rollback, stats, LuCI, CI both arches) with the critical bugs found &
fixed (fork-storm/OOM, xray-core config clash, procd file-watch/reload, busybox
xrayRunning, DNS anti-leak) and the honest known-simplifications. Evidence in PROOFS.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:27:29 +03:00
omarandClaude Opus 4.8 51f2c129ca chore: bump xrayctl+shater-core to r4; record DNS/chain/per-client/rollback/upgrade proofs
build / aarch64_cortex-a53 (push) Successful in 2m59s
build / x86_64 (push) Has been cancelled
PKG_RELEASE 3->4 for the DNS-guard + engine-reload fixes. PROOFS.md updated with the
live-VM evidence for: DNS :53 hijack + DoT block, 2-hop chain exit, per-client A/B
split, observatory alive (186/254), rollback/commit-confirm, and opkg feed upgrade
r3->r4.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:20:53 +03:00
omarandClaude Opus 4.8 9e0c81a5b2 feat(dns): LAN :53 hijack + DoT block; fix: apply/rollback actually reload xray
DNS anti-leak (MVP feature-catalog §8) in RenderNft's `inet shater` table:
  * dnsnat chain (nat/prerouting): redirect LAN :53 (tcp+udp) to the router's own
    resolver, so no client can bypass it with a hard-coded upstream; router-destined
    DNS is left alone (fib local).
  * prerouting: reject DoT/DoQ :853 BEFORE the tproxy catch-all (otherwise tproxy
    swallows it and no later hook sees it), and keep :53 out of tproxy so dnsnat can
    redirect it (the catch-all would divert :53 into xray, which can't answer it).
  Verified: client querying 8.8.8.8 is answered by the router (example.com ->
  172.66.147.243); :853 is refused while :443 connects.

Engine reload fix: procd's passive file-watch does NOT fire on this build (neither
rename nor in-place write triggers it), so `xrayctl apply` never restarted the
running engine — the config change was written but ignored. reloadXray now SIGTERMs
the xray process; procd respawns it against the run.json on disk, WITHOUT running
start_service -> shater_reconcile (which would regenerate run.json from UCI and
clobber a Rollback). Init respawn tuned to `10 2 5` so these operator-driven
restarts (engine ran >10s) are never counted as a crash loop. writeJSON stays
atomic (tmp+rename) for partial-write safety.

Verified live (512M): apply of a config change reloads xray (new pid, new routing);
`xrayctl rollback` restores the good run.json and the engine runs it; client A stays
proxied (exit 104.156.233.234) with load ~0.04 and 186/254 nodes alive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 12:18:50 +03:00
omarandClaude Opus 4.8 6c3bb2adc5 fix: rollback/commit-confirm no longer self-clobbers; reliable xray liveness check
Two bugs made `xrayctl rollback` (and commit-confirm auto-rollback) a no-op:

1) reloadXray() ran `/etc/init.d/shater start` unconditionally, which re-runs
   start_service -> shater_reconcile -> Reconcile(), regenerating run.json from
   UCI. After Rollback() restored run.json from last-good, that reconcile
   immediately overwrote it with the current (bad) UCI. Now reloadXray() is a
   no-op when xray is already supervised — procd's file-watch on run.json (which
   the caller just wrote) restarts the engine — and only `start`s a stopped one.

2) xrayRunning() used `pgrep -x xray`, which matches nothing on busybox even when
   xray is running (comm=="xray"), so the guard above would never trigger.
   Switched to `pidof xray` (exact program name; never matches xrayctl).

Verified live (512M VM): apply group:main -> apply block -> `xrayctl rollback`
restores the group:main run.json and it holds (no reconcile clobber); commit-
confirm `apply --confirm N` arms /var/run/xray/pending-apply, `confirm` clears it,
and with no confirm the detached auto-rollback restores last-good after N seconds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 11:54:04 +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 58f2a6ed3d docs: goal complete — CI green (x86_64 + aarch64_cortex-a53), installed from repo, verified on OpenWrt VM
build / aarch64_cortex-a53 (push) Successful in 3m2s
build / x86_64 (push) Successful in 3m0s
2026-07-09 03:27:40 +03:00
omar 78cb5683be ci: upload-artifact@v3 (v4 unsupported on Gitea Actions/GHES)
build / aarch64_cortex-a53 (push) Successful in 3m7s
build / x86_64 (push) Successful in 3m0s
All 3 packages now build green in CI (xrayctl via SDK, shater-core+luci as data
.ipk); the only failing step was actions/upload-artifact@v4 -> GHESNotSupportedError.
Downgrade to @v3 which Gitea's act_runner supports.
2026-07-09 03:20:10 +03:00
omar b51a138410 ci: lean build — xrayctl via SDK, shater-core+luci as data .ipk; fix pack path
build / aarch64_cortex-a53 (push) Failing after 3m0s
build / x86_64 (push) Failing after 3m0s
- build-sdk.sh: build ONLY xrayctl (its deps are light) — no kernel/kmod rebuild
  (shater-core's kmod-nft-tproxy dep was dragging in a full kernel build)
- pack-core.sh: shater-core data .ipk (Depends/conffiles/uci-defaults per Makefile)
- pack-luci.sh: fix $OUT to an ABSOLUTE path (relative path after 'cd $W' made tar
  write to the wrong dir -> 'Cannot open ... No such file')
- workflow: add Pack shater-core step
- all pack scripts dry-run green locally (valid .ipk structure + index)
2026-07-09 03:12:41 +03:00
omar 6108d5d5fb ci: share workspace into nested SDK container via --volumes-from
build / aarch64_cortex-a53 (push) Failing after 4m5s
build / x86_64 (push) Failing after 4m5s
bare -v $PWD failed (act_runner DinD: $PWD is a host path that doesn't exist)
-> 'No such file /repo/ci/build-sdk.sh'. Use --volumes-from $(hostname) so the
job's workspace volume is mounted in the SDK container; build-sdk.sh now reads
$REPO=$GITHUB_WORKSPACE and guards against an unmounted repo.
2026-07-09 02:59:34 +03:00
omar da1182dead ci: custom SDK build (clean feed) — gh-action-sdk indexed 0 packages from repo-root feed
build / aarch64_cortex-a53 (push) Failing after 31s
build / x86_64 (push) Failing after 49s
- ci/build-sdk.sh: run openwrt/sdk image with a CLEAN single-package feed; compile
  xrayctl (Go) + shater-core (in-tree, files only, no dep rebuild)
- ci/pack-luci.sh: luci-app-shater as data .ipk via tar (no luci-base compile)
- ci/make-index.sh: opkg Packages index + SHA256 (+ usign sign if KEY_BUILD set)
- workflow: docker-run the SDK per arch (x86_64, aarch64_cortex-a53), upload feed
  This mirrors the recipe verified locally that produced all 3 installable .ipk.
2026-07-09 02:55:18 +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
omar 08a26bbb7b apply: resolve UCI interface -> L3 device for tproxy iifname (lan -> br-lan)
build / aarch64_cortex-a53 (push) Failing after 4m42s
build / arm_cortex-a7_neon-vfpv4 (push) Failing after 2m9s
build / mipsel_24kc (push) Failing after 2m10s
build / x86_64 (push) Failing after 2m20s
nft iifname must match the real device, not the UCI interface name; bridges/VLANs
have device != name, so 'iifname lan' intercepted nothing. Added ifaceDevice()
(ubus network.interface status l3_device, uci network.<n>.device fallback).
Verified live on VM: tproxy rule now 'iifname br-lan' (matches agent E's proven
interception). Bump xrayctl PKG_RELEASE=2.
2026-07-09 02:19:38 +03:00
omar 66913cabd4 packaging: make all 3 packages build in SDK; fix luci nodes view
build / aarch64_cortex-a53 (push) Failing after 1m59s
build / mipsel_24kc (push) Has been cancelled
build / x86_64 (push) Has been cancelled
build / arm_cortex-a7_neon-vfpv4 (push) Has been cancelled
- xrayctl/Makefile: include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk (was relative ../../ which breaks for a src-link feed); Build/Prepare copies local Go sources into PKG_BUILD_DIR ROOT (golang-package.mk symlinks the root as the module) via captured $(XRAYCTL_DIR); trim DEPENDS to +ca-bundle (xray-core/kmods belong to shater-core, avoids rebuilding xray-core)
- luci-app-shater/Makefile: include $(TOPDIR)/feeds/luci/luci.mk
- nodes.js: expect { '': {} } (was { nodes: [] } which returned the bare array while render read data.nodes -> always empty); verified live via Playwright (node r1 now shown)
- VERIFIED end-to-end on OpenWrt VM: built xrayctl_.ipk (SDK), shater-core_.ipk, luci-app-shater_.ipk; opkg feed (file://) + opkg update + install + upgrade r2; ubus xray status/nodes live; LuCI overview+nodes render
2026-07-09 02:13:25 +03:00
omar 6433de209a docs: contract clarifications (name identity, resolver_fallback, dst_domain forms, fakeip pool, chain layers, src/port formats), STATUS.md with verification evidence, README index + status
build / aarch64_cortex-a53 (push) Failing after 2m22s
build / arm_cortex-a7_neon-vfpv4 (push) Failing after 2m35s
build / mipsel_24kc (push) Failing after 3m12s
build / x86_64 (push) Failing after 2m45s
2026-07-09 00:58:49 +03:00
omar 17f09915ee generate: fix single-member group balancer-tag mismatch (real xray: 'balancer not found')
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
- track balancer tags explicitly (balTag set) instead of a fragile g_/bal_ prefix heuristic
- groupTag map: resolveTarget returns exactly what emitGroup produced (balancer OR single-member outbound)
- setTargetTag is now a builder method keyed on balTag
- verified end-to-end on OpenWrt VM: both 'gen --links' and 'gen' (full UCI path) -> real xray 25.1.30 -> 'Configuration OK'
2026-07-09 00:47:52 +03:00
omar f336da4877 Add .gitattributes: force LF everywhere (CRLF breaks OpenWrt scripts/Makefiles)
build / aarch64_cortex-a53 (push) Failing after 3m49s
build / mipsel_24kc (push) Has been cancelled
build / x86_64 (push) Has been cancelled
build / arm_cortex-a7_neon-vfpv4 (push) Has been cancelled
2026-07-09 00:41:24 +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 d3d8cc6be4 Fix mermaid: quote labels, drop slashes and list-prefixes (Gitea render), remove stray fence 2026-07-09 00:11:37 +03:00
omar 2f021c1a1a Design blueprint: architecture, feature catalog, data model, ops, roadmap (docs 00-07) 2026-07-08 23:49:28 +03:00