diff --git a/bundled-addons/vpn/DESIGN.md b/bundled-addons/vpn/DESIGN.md new file mode 100644 index 00000000..36204901 --- /dev/null +++ b/bundled-addons/vpn/DESIGN.md @@ -0,0 +1,159 @@ +# VPN extension — design notes + +Client is done in v0.1.0. This file covers **what the client expects the +server side to look like**, so the two halves can be built independently +without either side inventing a contract the other did not agree to. + +## Model, in one line + +3x-UI + xray-core on our VPS provides a VLESS+Reality inbound; the client +runs sing-box locally and speaks that inbound; a small key-issuer service +on our gateway mints per-user client entries in the 3x-UI panel on demand. +This is the SoloBot / YAK VPN pattern with the payment stack, the referral +program and the Telegram-bot UI stripped out — everything Silent Mode does +not care about — and with the client wired to Theseus's session proxy +instead of a system-wide tunnel. + +Anchors: +- `D:\Dev\VPN\vpn_bot` — the original bot the code and inbound layout are + adapted from. `client.py` (its `py3xui` calls) is the reference for our + key-issuer. +- `D:\Dev\VPN\VPN module` — the YAK web frontend the payment-less flow + descends from. + +## Server side (VPS) + +1. **Install 3x-UI** as a Docker container or systemd service. One VLESS + inbound, Reality mode, port 443, `flow=xtls-rprx-vision`, one Reality + short-id per operator server. +2. **Provision at least one inbound per exit country** (`nl-1`, `de-1`, …) + and record its `inbound_id` in the key-issuer's config. Multiserver is + phase-two; v1 ships one exit. +3. **Key-issuer** — small FastAPI service (or Node in Argus, matching our + stack) that: + - Reads 3x-UI's local API on `127.0.0.1:2053`. + - Exposes one POST endpoint the extension calls (below). + - Talks to Aegis-side wallet signatures when a request claims to be paid. + +### `POST /api/vpn/new-client` + +Request body: +```json +{ + "identity": "bch:
" | "anon:<128-bit random>", + "tier": "free" | "paid", + "duration_days": 1, // free tier ignores this; paid honours it + "signature": "…" // wallet signature over the JSON, iff tier=paid +} +``` + +Response: +```json +{ + "vless": "vless://…", + "expires_at": 1727000000, + "quota_bytes": 524288000 // 500 MB for free tier per day +} +``` + +Rules: +- `anon:` requests get one key per source IP per 24h, hard-capped at + 500 MB / 30 minutes of active use (enforced in the xray inbound's + `total` and `expiry`). One key at a time — reissuing supersedes. +- `bch:` requests without a signature get the same free-tier treatment. +- `bch:` requests with a valid signature and a `tier=paid` claim get a + key sized to what their signed message says. `duration_days` and the + price paid live in the signed message. Payment verification is a + separate concern (see next section). + +### Paid tier + +BCH-native, no Stripe. Options in decreasing order of Silent Mode-fit: + +1. **BCH invoice covenant on Aegis** — the extension posts to + `/api/vpn/invoice` which returns an address + memo. User pays from + Aegis. Gateway watches the address, unlocks the corresponding key + when the tx clears. Same on-chain-watcher pattern the marketplace + already uses in Argus. +2. **Sirius Studio hosted key sale** — a page under `theseus.x/vpn/buy` + that runs an offer covenant (like the name-sale covenants shipped + 2026-09-17); paying it produces a signed receipt the extension shows + to `/api/vpn/new-client`. Consistent with the name-marketplace flow. + +Either way, no card processor, no email, no account. A signed receipt + +a fresh `bch:` identity is the whole login. + +## Binary hosting + +sing-box binaries live at: + +``` +bns/theseus.x/vpn-binaries/win32-x64/sing-box-Paste a vless:// URL from Silent Mode or another operator. The URL stays on this device
+ — it's used to build a sing-box config on the fly and never leaves the machine.
—
+ Enginesing-box
+ Binary—
+ SOCKS5—
+