LD-FDPI/linuxFDPI/docs/ARCHITECTURE.md
2026-11-23 03:45:09 +03:00

83 lines
2.4 KiB
Markdown

# Architecture
## Process model
```text
User session
┌──────────────────────────────┐
│ React (WebKitGTK) │
│ invoke Tauri commands │
└──────────────┬───────────────┘
│
┌──────────────▼───────────────┐
│ ld-fdpi (Rust, user) │
│ config · SpoofDPI lifecycle │
│ GNOME proxy · helper client │
└───────┬─────────────┬─────────┘
│ │ Unix socket
│ │
┌───────▼──────┐ ┌────▼─────────────┐
│ spoofdpi │ │ ld-fdpi-helper │
│ local proxy │ │ root/systemd │
└──────────────┘ │ nftables/awg │
└──────────────────┘
```
The GUI is never started with `sudo`. The helper is the only privileged
component and exposes a small JSON allowlist over
`/run/ld-fdpi/helper.sock`.
## Platform facade
Windows-specific code is not part of this crate. Linux managers are separate
modules so later phases can replace them:
```text
config.rs persisted JSON
proxy.rs GNOME gsettings (KDE in Phase 2)
helper.rs Unix socket client
spoofdpi.rs sidecar lifecycle
main.rs Tauri commands + state
```
## FDPI flow
```text
start_fdpi
-> port free
-> spawn spoofdpi
-> wait for local TCP
-> save GNOME proxy state
-> set GNOME HTTP/HTTPS proxy
-> store child
```
Stop reverses it and always restores the previous proxy, including on error.
## Privileged helper
- `SO_PEERCRED` peer validation.
- Allowed UID root or member of `ld-fdpi` group.
- One JSON object per line.
- No shell interpolation.
- Commands are fixed strings; unknown commands return an error.
Implemented helper commands:
```text
status
quic_on / quic_off (Phase 2; currently explicit not-implemented)
vpn_up / vpn_down (Phase 3; currently explicit not-implemented)
```
## Packaging
Tauri bundles:
```text
deb
appimage
```
Helper and systemd unit are installed by `scripts/install.sh`; this is a
development installer, not the final package layout.