# Protocol Documentation L×Box parses proxy URIs from subscriptions and converts them into [sing-box](https://sing-box.sagernet.org/) outbound (or endpoint) JSON. This document describes every supported protocol, its URI format, parsed parameters, and the resulting sing-box configuration. **Source code (Parser v2, spec 026):** - [`app/lib/services/parser/uri_parsers.dart`](../app/lib/services/parser/uri_parsers.dart) — URI-форматы всех 9 протоколов - [`app/lib/services/parser/transport.dart`](../app/lib/services/parser/transport.dart) — парсинг `TransportSpec`, нативный XHTTP (§097, полный набор параметров §127) - [`app/lib/services/parser/json_parsers.dart`](../app/lib/services/parser/json_parsers.dart) — `parseSingboxEntry`, `parseXrayOutbound` - [`app/lib/services/parser/ini_parser.dart`](../app/lib/services/parser/ini_parser.dart) — WireGuard INI - [`app/lib/services/parser/parse_all.dart`](../app/lib/services/parser/parse_all.dart) — orchestrator - [`app/lib/models/node_spec.dart`](../app/lib/models/node_spec.dart), [`node_spec_emit.dart`](../app/lib/models/node_spec_emit.dart) — sealed `NodeSpec` + `emit()` / `toUri()` --- ## Table of Contents 1. [Subscription HTTP Headers](#0-subscription-http-headers) 2. [VLESS](#1-vless) 3. [VMess](#2-vmess) 4. [Trojan](#3-trojan) 5. [Shadowsocks](#4-shadowsocks) 6. [Hysteria2](#5-hysteria2) 7. [NaïveProxy](#55-naïveproxy) 8. [SSH](#6-ssh) 8. [SOCKS](#7-socks) 9. [WireGuard](#8-wireguard) 10. [AmneziaWG (AWG, AWG2)](#85-amneziawg-awg-awg2) 11. [WireGuard INI Config](#9-wireguard-ini-config) 12. [Amnezia vpn:// Link](#92-amnezia-vpn-link) 13. [TUIC v5](#95-tuic-v5) 14. [JSON Outbound (raw sing-box)](#10-json-outbound) 15. [Xray JSON Array](#11-xray-json-array) 16. [XHTTP transport](#xhttp-transport) --- ## 0. Subscription HTTP Headers When fetching a subscription URL, L×Box reads several **de facto standard** HTTP response headers. These are **not formally standardized** (no RFC), but the convention is universally adopted across V2Ray/Clash/sing-box client ecosystem since ~2019. Backends like [V2Board](https://github.com/v2board/v2board), [Xboard](https://github.com/cedar2025/Xboard), [Marzban](https://github.com/Gozargah/Marzban) emit them out of the box. ### Parsed Headers | Header | Format | Purpose | |--------|--------|---------| | `subscription-userinfo` | `upload=N; download=N; total=N; expire=UNIX` | Traffic quota and expiry | | `profile-title` | plain text or **base64-encoded UTF-8** | Display name for subscription | | `profile-update-interval` | integer hours | Auto-refresh interval hint | | `support-url` | URL (often `https://t.me/...`) | Link to provider support | | `profile-web-page-url` | URL | Provider's website | | `content-disposition` | `attachment; filename="..."` | Fallback for title | ### Example Response ``` HTTP/1.1 200 OK Content-Type: text/plain; charset=utf-8 subscription-userinfo: upload=12345678; download=987654321; total=107374182400; expire=1735689600 profile-title: My VPN Provider profile-update-interval: 24 support-url: https://t.me/myvpn_support profile-web-page-url: https://myvpn.com vless://uuid@server1.example.com:443?... vless://uuid@server2.example.com:443?... ... ``` ### Where They Come From | Client | Role | |--------|------| | [v2rayN](https://github.com/2dust/v2rayN) (2018) | First to parse `subscription-userinfo` | | [Clash](https://github.com/Dreamacro/clash) (2020) | Formalized header list in [Clash Wiki](https://clash.wiki/configuration/subscription-userinfo) | | [Clash.Meta / Mihomo](https://github.com/MetaCubeX/mihomo) | Extended with additional fields | | [subconverter](https://github.com/tindy2013/subconverter) | De facto reference converter — reads/writes all headers | | [Hiddify](https://github.com/hiddify/hiddify-next) | Full set support | ### Traffic Quota Display The `subscription-userinfo` header drives the **traffic quota bar** in subscription detail: ``` Used: 1.05 GB uploaded + 920 MB downloaded = 1.97 GB / 100 GB Expires: 2026-12-31 (8 months remaining) ``` Backend reference: any of V2Board, Xboard, Marzban panels. These are PHP/Go backends that generate subscription responses with correct headers automatically — provider admins don't need to configure them manually. ### Why No RFC This is **cargo cult convention** — works because all clients parse identically. Similar to how `X-Forwarded-For` was de facto standard for ~10 years before [RFC 7239](https://datatracker.ietf.org/doc/html/rfc7239). If a new client introduced its own header, no provider would emit it, so the ecosystem stays consistent through inertia. ### Implementation in L×Box Парсинг в [`app/lib/services/subscription/sources.dart`](../app/lib/services/subscription/sources.dart) (`_metaFromHeaders` + `_parseContentDispositionFilename`). После fetch'а заголовки превращаются в `SubscriptionMeta` и кладутся в `SubscriptionServers.meta`: - `SubscriptionServers.name` ← `profile-title` (с fallback на `content-disposition: filename=...`, v1.3.0+) - `SubscriptionMeta.{totalBytes, uploadBytes, downloadBytes, expireTimestamp}` ← `subscription-userinfo` - `SubscriptionMeta.supportUrl` ← `support-url` - `SubscriptionMeta.webPageUrl` ← `profile-web-page-url` - `SubscriptionServers.updateIntervalHours` ← `profile-update-interval` (используется в [spec 027](./spec/features/027%20subscription%20auto%20update/spec.md)) User-Agent HTTP-запросов: `LxBox Android subscription client` (v1.3.0+; ранее `SubscriptionParserClient`). Displayed в subscription detail → **Source tab** → Headers section. --- ## 1. VLESS ### URI Format ``` vless://UUID@host:port?query_params#label ``` ### Parsed Parameters | Parameter | Query key | Description | |-----------|-----------|-------------| | UUID | (userinfo) | User ID | | Flow | `flow` | XTLS flow control (`xtls-rprx-vision`, `xtls-rprx-vision-udp443`) | | Security | `security` | `tls`, `reality`, or `none` | | SNI | `sni` or `peer` | TLS server name | | Fingerprint | `fp` or `fingerprint` | UTLS fingerprint (defaults to `random`) | | ALPN | `alpn` | Comma-separated ALPN values | | Public key | `pbk` | REALITY public key | | Short ID | `sid` | REALITY short ID (hex, max 16 chars) | | Transport type | `type` | `tcp`, `ws`, `grpc`, `http`, `httpupgrade`, `xhttp`, `raw` | | Path | `path` | WebSocket/HTTP/HTTPUpgrade path | | Host | `host` | WebSocket Host header / HTTP host | | Service name | `serviceName` or `service_name` | gRPC service name | | Header type | `headerType` | When `http` with `type=tcp`/`raw`, creates HTTP transport | | Packet encoding | `packetEncoding` (case-insensitive) | Allow-list: `xudp` / `packetaddr`. xray-style `none` и любой мусор молча дропаются — sing-box `NewOutbound` принимает только эти два значения, любое другое → panic в libbox. | | Insecure | `insecure`, `allowInsecure` | Skip certificate verification | ### sing-box Outbound Mapping ```json { "type": "vless", "tag": "