shater // xray control-plane
OpenWrt · xray-core · TPROXY · design blueprint

One transparent proxy engine,
fully under your control.

A portable OpenWrt plugin that turns subscriptions, nodes, multi-hop chains and per-device rules into one declarative model — with rock-solid routing, per-consumer analytics, and a dashboard. Passwall-class capability, without the lag.

8model objects
1xray process
0userspace hops in path
2build targets (OpenWrt+ImmortalWrt)
control plane data plane dns egress / exit MVPT1T2T3
01

System architecture

Two planes, cleanly split. The control plane (a Go daemon xrayctl + LuCI UI over ubus) renders configuration and reconciles state. The data plane is a single xray process plus kernel machinery — nothing heavy sits in the packet path.

Presentation
LuCI app (JS)
nodes · rules · dashboard · explain/trace
ubus / rpcd
ucode backend object xray.* + ACL
Control plane — xrayctl (Go)
UCI model
/etc/config/shater → 8 objects
sub fetch + parse
libXray share-links · HAPP headers
config generator
build xray JSON + nft + ip-rules
reconciler
atomic apply · validate · rollback
telemetry
xray API · nft counters · logs
Data plane — kernel + one xray
xray-core
tproxy in · balancers · observatory
nftables (fw4)
own table · tproxy · marks · counters
dnsmasq + DoH/FakeIP
hijack · split · nftset
ip rule / route
policy routing · egress bind
procd
supervise · reload · respawn
Config flows down, telemetry flows up. xrayctl owns a dedicated nft table, a reserved fwmark range and its own routing tables — it never edits fw4's table, so a firewall reload can't break it, and every apply is a single atomic transaction.
02

Data model — 8 objects

Everything the plugin does is expressed by composing these. No feature sprawl — just relationships between eight primitives, edited in UCI, rendered to xray + nftables.

1 Node

  • vless/vmess/trojan/ss/socks/http
  • reality · xhttp · vision · ws · grpc
  • stable fingerprint identity
from → Subscription | manual

2 Group

  • set of Nodes (a subscription)
  • balancer: leastPing/random/failover
  • observatory health
contains → Node[]

3 Chain

  • ordered hops L1→L2→L3
  • hop = Group or fixed Node
  • inverted proxySettings
hops → Group | Node

4 Egress

  • interface (eth/wifi/sim)
  • tunnel (wg/awg)
  • chain/group · direct · block
bound by → Rule | Chain

5 Inbound

  • TPROXY per LAN (multi-LAN)
  • tcp + udp · explicit subnets
  • + local socks/http (T1)
feeds → Rule engine

6 Rule

  • src: cidr/host/mac/iface
  • dst: domain/list/ip/list/geo/port
  • → target + egress + kill-mode
refs → List · Chain · Group · Node · Egress

7 Profile

  • conditional overrides
  • trigger: active WAN / probe / time
  • scenes: Home/Travel/Night
overrides → Rule · Egress · DNS

8 List / Ruleset

  • domain-list / ip-cidr-list
  • inline / file / URL (auto-update)
  • plain · clash-provider · geosite
used by → Rule · DNS
03

Traffic flow

A LAN packet's journey, and exactly where the decisions happen. Sniffing recovers SNI/Host so domain rules work on transparent traffic. Every hop is annotated with its mark/table.

LAN client
192.168.11.14
→
nft tproxy
iif br-lan · tcp+udp
mark 0xT → :12345
→
xray inbound
dokodemo :12345
sniff SNI/Host/QUIC
→
rule match
src/dst/list/geo
first-match
→
target
Chain L1→L2→L3
| Group | Node
→
egress
awgOut / eth / wifi
mark 0x11 → table
→
Internet
exit IP
Loop guard & fast-path. xray's own egress carries sockopt.mark so the firewall lets it escape re-interception; RFC1918 / the server IP are bypassed; flow-offload stays on for direct traffic (kernel fast-path) and off only for proxied flows. That's why it doesn't lag.
04

DNS — configurable & leak-proof

Clients can't bypass it; resolution matches routing. Named resolvers, per-domain and per-client routing, and a switchable transparent (nftset) ↔ zero-leak (FakeIP) strategy.

client :53
→
hijack (DNAT)
force to router
block DoT/DoH bypass
→
dnsmasq
noresolv · cache
→ 127.0.0.1
→
DNS router
match domain/list/geo/client
→
resolvers
ISP/local · DoH · FakeIP
detour via outbound
split
direct domains → ISP · proxied → proxy-side resolver (resolved == routed)
domain-list → nftset
feeds routing sets; IPv6 mirrored
FakeIP T1
198.18.x · fakeip-domain-list / real-ip-list
05

Node lifecycle & identity

A subscription refresh must never silently break a pinned rule. Nodes carry a stable fingerprint; reconcile diffs by it; vanished pins fall back by policy.

subscription
URL + HAPP headers
HWID fixed/auto
→
parse
libXray share-links
→
fingerprint
hash(addr,port,id,net,sec,sni…)
→
reconcile
new → add
present → keep
missing → stale
→
selection
Group (dynamic)
or pinned Node
stale window
kept N refreshes → removed; never silent delete
pinned & missing → fallback
group balancer / direct / block (your choice)
manual nodes
stable by own id · never auto-removed · paste \n / file / link
06

Reliability — the “железно” contract

The top requirement: routing tables never break, you never lock yourself out. Every change is validated, applied atomically, and auto-reverts if it can't be confirmed.

edit UCI→ build state→ validate
xray -test · nft -c
→ stage→ atomic apply
nft -f · swap
→ commit-confirm
window
→ committed ✓
validate fails →abort · keep old • no confirm in N s →auto-rollback → last-good
own resources
reserved marks · own table · own routing tables — fw4 untouched
idempotent reconcile
desired vs actual · no duplicate pile-up
hotplug persist
re-apply ip-rules on ifup/ifdown & boot
mgmt bypass
SSH/LuCI/LAN always reachable · kill-switch per policy (default fail-closed)
07

Per-consumer analytics

Who ate how much — per device, per proxy, per domain, live and historical. The kernel counts; the daemon aggregates. Zero cost in the packet path.

Kernel (in-path, free)
nft dynamic counter set
per source-IP up/down bytes
(saddr × mark) counters
client × proxy attribution
Userspace (aggregate)
xray Stats API
per-outbound totals (verify)
access-log parse T2
per-client × domain/SNI
RRD / nlbwmon
history & retention
Dashboard
consumer leaderboard
top talkers · device names
per-proxy bytes
which node ate what
live Sankey flow
client→rule→chain→egress→exit
connection inspector T2
live conns · kill
08

Roadmap — we build all of it

Ship a rock-solid core first, then layer the dream features. Each tier is shippable and tested in QEMU before the next.

MVPcore
  • Subscriptions + manual import paste/\n/file
  • TPROXY multi-LAN · tcp+udp
  • Balancer + observatory prune
  • Rules: src/dst/domain-list/ip-list
  • DNS: DoH + hijack + split (+FakeIP switch)
  • Atomic apply · rollback · kill-switch
  • LuCI: nodes(ping)/subs/status
  • Build OpenWrt+ImmortalWrt · feed
T1differentiators
  • Multi-hop chains (L1→L2→L3)
  • Per-client policy · egress select
  • explain / trace
  • Consumer leaderboard · node SLA
  • Profiles / scenes
  • Config history + diff + rollback
  • One-click test-all → rank
  • Telegram / webhook alerts
T2power
  • Per-domain stats · connection inspector
  • Device quotas · schedules
  • FakeIP · geo-map · ad-block
  • WAN-mode profiles · awg-wrap
  • Auto route optimization
  • QR import/export
T3moonshots
  • Fleet: one UI → many routers
  • Per-destination latency routing
  • Config converters (passwall/clash)
  • sing-box engine adapter
  • REST/gRPC API · TG bot