Files
shater/examples
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
..

examples/ — sample configs & parser fixtures

Realistic, heavily-annotated fixtures for the shater xray control-plane (xrayctl). They double as (a) manual test fixtures and (b) onboarding docs. Every option name is cross-checked against ../CONTRACT.md; any field the contract left ambiguous is flagged in Contract gaps / interpretations below.

Files

File What it is
etc-config-shater.full Complete /etc/config/shater exercising every section type in the contract: globals, multi-LAN inbound, two subscription (HAPP auto-hwid + fixed-hwid with extra headers), manual node, subscription- and manual-sourced group, a 3-hop chain, egress of all four types (interface/proxy/direct/block), ruleset (domain-from-url + inline ipcidr), rule (per-client /32, MAC, domain-list, geosite, egress binding, kill modes), resolver (doh+detour / local / fakeip / default) with dns_rule, and a WAN-mode profile. Generalizes the real BPi-R3 Mini setup (see ../01-mini_router-audit.md).
etc-config-shater.minimal Smallest useful config: one subscription, one group, one tproxy inbound, one default rule → group. For quick starts.
sublinks.txt Mixed share-link list (one per line) covering vless+reality+vision(tcp), vless+xhttp+tls, vless+ws+tls, vmess+ws, trojan+grpc, and shadowsocks (aes-256-gcm + 2022-blake3). Structurally valid, fake values. Parser fixture.
README.md This file.

How to use

Render a config to xray JSON (no apply), validate, then apply:

# On the router, install one of the sample configs:
cp examples/etc-config-shater.minimal /etc/config/shater
xrayctl test          # gen + `xray -test`
xrayctl apply         # gen -> test -> atomic swap (xray + nft + routing)
# or, with auto-rollback if you don't confirm within globals.confirm_timeout:
xrayctl apply --confirm 120 && xrayctl confirm

# Full-feature reference config:
cp examples/etc-config-shater.full /etc/config/shater && xrayctl test

Parse the share-link fixture (does not touch device state):

xrayctl gen --links examples/sublinks.txt      # parse -> node objects / JSON
xrayctl selftest                               # smoke-tests parsers on fixtures

Consistency notes

  • All option names and section types match CONTRACT.md exactly.
  • Cross-object references use the contract's target grammar (chain:<name> / group:<name> / node:<name> / direct / block) and refer to other sections by their name option (see gap #1).
  • sublinks.txt values are deliberately fake (fake UUIDs/keys/hosts) but syntactically valid so parsing succeeds; the reality pbk, the vmess base64 payload, and both shadowsocks userinfo encodings are all well-formed.

Contract gaps / interpretations

Points where CONTRACT.md is silent or ambiguous and I had to make a call. Listed so the lead can tighten the spec.

  1. Section addressing vs UCI anonymous sections. All sections except globals/default are written anonymous (no explicit section id), yet the contract references them by name (group:sub0, egress=via-awg, and profile.set = rule.pc-triple.egress=...). I assumed the name option is the identity and must be unique per section type. The spec should state this (and how profile.set addresses a rule: by name, not UCI index).

  2. globals.resolver_fallback. Mentioned only in prose (CONTRACT line ~146: "config resolver 'default' + option resolver_fallback в globals"), but NOT in the globals option block. I added it with a resolver name as its value (system-local). Confirm placement + that the value is a resolver name.

  3. config resolver 'default'. The default resolver is a section literally named default. I gave it no name option (the section id is the name). Ambiguous whether default should also carry option name 'default'.

  4. dst_domain sub-forms. Contract lists "домен|suffix|keyword|geosite:x" but only defines the geosite: prefix. There is no stated syntax for suffix vs keyword vs exact matches. I used plain domains and geosite: only, and avoided inventing prefixes. Spec should define these (e.g. xray-style domain: / full: / keyword: / regexp:).

  5. rule.src MAC and iface:/zone: forms. MAC format unspecified — I used lowercase colon form aa:bb:cc:dd:ee:ff. iface:<name> — I mapped it to an inbound's network/interface name (iface:guest); unclear if it means a UCI network interface, a device, or an inbound name. Clarify the namespace.

  6. dst_port range syntax. "port|range|список" — comma-list is obvious (80,443), but the range delimiter is undefined (dash 1000-2000 vs colon 1000:2000). I used comma-lists only to stay unambiguous.

  7. resolver type=fakeip has no pool field. The resolver schema only has address + detour. For type=fakeip I put the pool CIDR in address (198.18.0.0/15, per feature-catalog §8). A dedicated pool option (and fakeip-domain/real-ip lists) may be warranted.

  8. resolver type=local address. No format given. I used dnsmasq notation 127.0.0.1#53. Could equally be empty (implied local) — clarify.

  9. group.strategy=single selection. For a subscription-sourced group, single needs to say which node is fixed, but no pin/node option is defined for that case. Not used in the examples; flag for the spec.

  10. Chain layers from one subscription. The contract's chain example uses group:sub0/sub1/sub2, but each group binds to exactly one subscription. Producing three distinct layers from a single sub (the real "inverted chain") presumably needs three groups over the same sub with different include/exclude filters — the mechanism isn't stated. My chain 'triple' hops across a sub group, a manual group, and a fixed node to sidestep this; document the intended multi-layer-from-one-sub pattern.

  11. inbound.network multiplicity. "UCI-интерфейс(ы)" implies multiple, but it's an option (single value), not a list. I assumed space-separated values in one option; a list network might be cleaner. Clarify.