Fix mermaid: quote labels, drop slashes and list-prefixes (Gitea render), remove stray fence

This commit is contained in:
omar committed 2026-07-09 00:11:37 +03:00
1 parent 2f021c1a1a
commit d3d8cc6be4
1 file changed
+62 -63
+62 -63
View File
@@ -7,83 +7,83 @@
```mermaid
flowchart TB
subgraph PRES[Presentation]
LUCI[LuCI app - JS]
UBUS[ubus / rpcd]
subgraph PRES["Presentation"]
LUCI["LuCI app (JS)"]
UBUS["ubus, rpcd"]
end
subgraph CTRL[Control plane - xrayctl - Go]
UCIM[UCI model /etc/config/xray]
FETCH[sub fetch + parse - libXray]
GEN[config generator - xray JSON + nft + ip-rules]
REC[reconciler - atomic apply / rollback]
TEL[telemetry - xray API / nft counters / logs]
subgraph CTRL["Control plane — xrayctl (Go)"]
UCIM["UCI model — etc-config-xray"]
FETCH["sub fetch + parse (libXray)"]
GEN["config generator — xray JSON, nft, ip-rules"]
REC["reconciler — atomic apply, rollback"]
TEL["telemetry — xray API, nft counters, logs"]
end
subgraph DATA[Data plane - kernel + one xray]
XRAY[xray-core - tproxy in / balancers / observatory]
NFT[nftables fw4 - own table / tproxy / marks / counters]
DNSM[dnsmasq + DoH / FakeIP]
ROUTE[ip rule / route - policy routing / egress bind]
PROCD[procd - supervise / respawn]
subgraph DATA["Data plane — kernel + one xray"]
XRAY["xray-core — tproxy in, balancers, observatory"]
NFT["nftables fw4 — own table, tproxy, marks, counters"]
DNSM["dnsmasq + DoH, FakeIP"]
ROUTE["ip rule, route — policy routing"]
PROCD["procd — supervise, respawn"]
end
LUCI <--> UBUS
UBUS <--> CTRL
CTRL -->|render + atomic apply| DATA
DATA -->|telemetry| TEL
CTRL -->|"render + atomic apply"| DATA
DATA -->|"telemetry"| TEL
```
## 2. Модель данных — 8 объектов
```mermaid
flowchart LR
SUB[Subscription - URL + HAPP headers] --> NODE[1. Node]
MAN[manual - paste / \n / file] --> NODE
NODE --> GRP[2. Group +balancer]
GRP --> CH[3. Chain L1..Ln]
SUB["Subscription — URL + HAPP headers"] --> NODE["1 — Node"]
MAN["manual — paste, file, link"] --> NODE
NODE --> GRP["2 — Group +balancer"]
GRP --> CH["3 — Chain L1..Ln"]
NODE --> CH
INB[5. Inbound - multi-LAN tproxy] --> RULE[6. Rule]
INB["5 — Inbound (multi-LAN tproxy)"] --> RULE["6 — Rule"]
RULE --> CH
RULE --> GRP
RULE --> NODE
RULE --> EG[4. Egress]
LIST[8. List / Ruleset] --> RULE
LIST --> DNS[DNS]
PROF[7. Profile - WAN-mode] -.override.-> RULE
EG --> OUT[iface / tunnel / chain / direct / block]
RULE --> EG["4 — Egress"]
LIST["8 — List, Ruleset"] --> RULE
LIST --> DNS["DNS"]
PROF["7 — Profile (WAN-mode)"] -.->|"override"| RULE
EG --> OUT["iface, tunnel, chain, direct, block"]
```
## 3. Путь трафика
```mermaid
flowchart LR
C[LAN client] -->|nft tproxy - mark to :12345| IN[xray inbound - dokodemo :12345 - sniff SNI/Host]
IN --> R{rule match - src / dst / list / geo}
R --> T[target - Chain L1-L2-L3 / Group / Node]
T -->|mark 0x11 to table| E[egress - awgOut / eth / wifi]
E --> NET[Internet - exit IP]
C["LAN client"] -->|"nft tproxy, mark to :12345"| IN["xray inbound — dokodemo :12345, sniff SNI+Host"]
IN --> R{"rule match — src, dst, list, geo"}
R --> T["target — Chain L1-L2-L3, Group, Node"]
T -->|"mark 0x11 to table"| E["egress — awgOut, eth, wifi"]
E --> NET["Internet — exit IP"]
```
Loop-guard: `sockopt.mark` на egress xray + bypass RFC1918/сервера; flow-offload остаётся ON для direct.
Loop-guard: `sockopt.mark` на egress xray + bypass RFC1918 и сервера; flow-offload остаётся ON для direct.
## 4. DNS (настраиваемый, без утечек)
```mermaid
flowchart LR
C[client :53] -->|hijack DNAT| DM[dnsmasq - noresolv / cache]
DM --> DR{DNS router - domain / list / geo / client}
DR --> R1[ISP / local]
DR --> R2[DoH - detour via outbound]
DR --> R3[FakeIP 198.18.x]
DR --> SET[(domain to nftset - для роутинга)]
C["client :53"] -->|"hijack DNAT"| DM["dnsmasq — noresolv, cache"]
DM --> DR{"DNS router — domain, list, geo, client"}
DR --> R1["ISP, local"]
DR --> R2["DoH — detour via outbound"]
DR --> R3["FakeIP 198.18.x"]
DR --> SET[("domain to nftset — для роутинга")]
```
## 5. Жизненный цикл ноды и идентичность
```mermaid
flowchart LR
S[subscription - HAPP HWID fixed/auto] --> P[parse - libXray]
P --> FP[fingerprint - hash addr/port/id/net/sec/sni]
FP --> RC{reconcile}
RC -->|new| ADD[add]
RC -->|present| KEEP[keep]
RC -->|missing| ST[stale N refreshes then remove]
ADD --> SEL[selection - Group dynamic / pinned Node]
S["subscription — HAPP HWID fixed or auto"] --> P["parse (libXray)"]
P --> FP["fingerprint — hash addr, port, id, net, sec, sni"]
FP --> RC{"reconcile"}
RC -->|"new"| ADD["add"]
RC -->|"present"| KEEP["keep"]
RC -->|"missing"| ST["stale N refreshes then remove"]
ADD --> SEL["selection — Group dynamic or pinned Node"]
KEEP --> SEL
SEL -->|pinned & missing| FB[fallback - group / direct / block]
SEL -->|"pinned and missing"| FB["fallback — group, direct, block"]
```
Обновление подписки: **интервал на каждую подписку** + вручную + при бутe; после апдейта → этот reconcile.
@@ -92,10 +92,10 @@ flowchart LR
stateDiagram-v2
[*] --> Edit
Edit --> Build
Build --> Validate: xray -test / nft -c
Build --> Validate: xray-test, nft-c
Validate --> KeepOld: fail
Validate --> Stage: ok
Stage --> Apply: atomic nft -f + swap
Stage --> Apply: atomic nft-f + swap
Apply --> ConfirmWindow
ConfirmWindow --> Committed: confirmed
ConfirmWindow --> Rollback: timeout N s
@@ -104,33 +104,32 @@ stateDiagram-v2
Committed --> [*]
LastGood --> [*]
```
Свои метки/таблицы (fw4 не трогаем) · идемпотентный reconcile · hotplug-персист · mgmt-bypass всегда.
Свои метки, таблицы (fw4 не трогаем) · идемпотентный reconcile · hotplug-персист · mgmt-bypass всегда.
## 7. Per-consumer статистика (ядро считает, демон агрегирует)
```mermaid
flowchart LR
subgraph K[Kernel - in-path, free]
C1[nft dynamic counter set - per saddr]
C2[saddr x mark counters - client x proxy]
subgraph K["Kernel — in-path, free"]
C1["nft dynamic counter set — per saddr"]
C2["saddr x mark counters — client x proxy"]
end
subgraph U[Userspace - aggregate]
X[xray Stats API - per-outbound]
L[access-log parse - T2 per-domain]
RRD[RRD / nlbwmon - history]
subgraph U["Userspace — aggregate"]
X["xray Stats API — per-outbound"]
L["access-log parse — T2 per-domain"]
RRD["RRD, nlbwmon — history"]
end
C1 --> AGG[xrayctl aggregator]
C1 --> AGG["xrayctl aggregator"]
C2 --> AGG
X --> AGG
L --> AGG
RRD --> AGG
AGG -->|ubus| DASH[Dashboard - leaderboard / per-proxy / Sankey / conn-inspector]
AGG -->|"ubus"| DASH["Dashboard — leaderboard, per-proxy, Sankey, conn-inspector"]
```
## 8. Роадмап
| Тир | Содержание |
|-----|-----------|
| **MVP** | подписки+manual импорт · TPROXY multi-LAN · balancer+observatory · rules(src/dst/domain-list/ip-list) · DNS(DoH+hijack+split,±FakeIP) · atomic apply+rollback+kill-switch · LuCI(nodes/subs/status) · build OpenWrt+ImmortalWrt+feed |
| **T1** | multi-hop chains · per-client policy+egress-select · explain/trace · consumer leaderboard+SLA · profiles/scenes · config-history+rollback · one-click test-all · Telegram-алерты |
| **MVP** | подписки+manual импорт · TPROXY multi-LAN · balancer+observatory · rules (src, dst, domain-list, ip-list) · DNS (DoH+hijack+split, ±FakeIP) · atomic apply+rollback+kill-switch · LuCI (nodes, subs, status) · build OpenWrt+ImmortalWrt+feed |
| **T1** | multi-hop chains · per-client policy + egress-select · explain, trace · consumer leaderboard + SLA · profiles, scenes · config-history + rollback · one-click test-all · Telegram-алерты |
| **T2** | per-domain stats · connection inspector · device quotas · schedules · FakeIP · geo-map · WAN-mode profiles · awg-wrap · auto route-optimization · QR |
| **T3** | fleet (много роутеров) · per-destination latency-routing · config-конвертеры · sing-box адаптер · REST/gRPC API · TG-бот |
</content>
| **T3** | fleet (много роутеров) · per-destination latency-routing · config-конвертеры · sing-box адаптер · REST, gRPC API · TG-бот |