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>
4.2 KiB
shater
OpenWrt-плагин управления XRAY — как passwall2, только чище, быстрее и без лагов. Переносимый: подписки → ноды → цепочки → правила → выбор egress, с прозрачным роутингом, железной надёжностью, per-consumer статистикой и удобным UI.
Статус: MVP собран, проверен на тестовом OpenWrt, CI зелёный, ставится из репозитория.
Ключевые решения
- Движок: только xray-core — НЕ форкаем;
xrayctl= отдельный control-plane демон (Go). sing-box — потом адаптером. - Генератор: Go
xrayctl(парсинг share-links через libXray, валидацияxray -test). - MVP: надёжный одиночный transparent-proxy (TPROXY, мульти-LAN); цепочки/per-client — фаза 2.
- Сборка: OpenWrt + ImmortalWrt/BananaWRT, 24.10(ipk)+25.x(apk), мультиарк, CI + подписанный фид.
- Тест-стенд: Docker/QEMU (QEMU для netfilter/tproxy, WSL2 для сборки).
Документы
| # | Файл | О чём |
|---|---|---|
| 00 | 00-summary-and-plan.md | Сводка, locked-решения, план по фазам, риски |
| 01 | 01-mini_router-audit.md | Аудит боевого роутера (эталон того, что автоматизируем) |
| 02 | 02-xray-plugin-design.md | Дизайн, структура пакета, фазы |
| 03 | 03-features-and-model.md | Модель (8 объектов), правила, egress, идентичность нод |
| 04 | 04-ops-reliability-build-stats.md | Надёжность («железно»), сборка, статистика |
| 05 | 05-feature-catalog.md | Полный каталог фич (12 доменов, теги MVP/T1/T2/T3) |
| 06 | 06-north-star-imba.md | Амбициозные «мечты»: дашборд, per-client, автоматизация |
| 07 | 07-architecture.md | Все схемы (Mermaid): архитектура, flow, lifecycle, SM |
Визуальная версия схем (артефакт): см. architecture.html (тот же контент, наглядно).
Модель в одну строку
Node → Group(+balancer) → Chain(L1..Ln) → Egress · Rule(src/dst/list/geo → target+egress) ·
Inbound(multi-LAN tproxy) · Profile(WAN-mode) · List(domain/ip, auto-update).
Код, контракт, сборка
| Файл/дир | О чём |
|---|---|
| CONTRACT.md | UCI-схема /etc/config/shater + интерфейс xrayctl (CLI+ubus) |
| STATUS.md | Что собрано и чем проверено (доказательная база) |
| BUILD.md | Сборка .ipk (SDK/CI) + установка на роутер |
xrayctl/ |
Go control-plane (парсер, генератор, apply) |
shater-core/ |
Системный пакет (procd/hotplug/sysctl/дефолт-конфиг) |
luci-app-shater/ |
LuCI-приложение (JS-views + ubus-бэкенд) |
examples/ |
Примеры /etc/config/shater + share-link фикстуры |
.github/workflows/build.yml, dist/ |
CI (gh-action-sdk) + фид |
Статус
Дизайн + MVP-ядро готовы и проверены (см. STATUS.md): генератор конфига
проходит реальный xray -test (Configuration OK) и на links-, и на UCI-пути; data-plane
(nft tproxy + policy routing) доказан на реальном ядре с реальным LAN-клиентом; shater-core.ipk
собран в SDK. Дальше — live xrayctl apply, полная CI-сборка, затем T1 (цепочки в UI, per-client, статистика).