Files
Vole/readme
yiguodev 608a8f255c feat: add client protocols, TLS capabilities, and platform validation (#1)
* chore: download latest official mihomo for interop tests

* test: capture N0 baseline and protocol feasibility probes

* docs: record N0 hybrid REALITY fork verification

* test: verify N0 controlled Hysteria2 auth and streams

Add an isolated Quinn adapter over existing DIRECT and SOCKS5 datagrams, bounded queues, protect rejection probes, and official latest peer fixtures. Record passing auth/TCP checks and the native Hysteria half-close failure separately. N0 remains incomplete; production sources and dependency locks are unchanged.

* test: validate N0 native QUIC hopping and XHTTP H3

Keep the probes isolated from production. Verify one-state Hysteria hopping, protected rebind rejection, Xray H3 entry and existing HY2 regressions. Set only the owned Linux peer MTU to avoid Initial-packet EMSGSIZE; retain native half-close failures as separate gates.

* fix: align XHTTP shutdown with Mihomo connection close

* test: verify N0 supplied-stream transport interfaces

Add isolated TLS, ordinary WebSocket and gRPC probes with owned I/O, bounded buffers and cancellation barriers.

Match Mihomo close behavior: preserve TLS/WS reads, distinguish clean WS underlay EOF from truncation, and close both gRPC directions. Use separate official SOCKS5 peers to avoid fixture loop detection.

Record 12 Debug/Release tests, 42 official Mihomo checks, dependency audits and Apple/Android compile checks. Keep production dependencies, third-party sources and remaining N0 gates unchanged.

* fix: upgrade h2 and retain completed responses after reset

* chore: use the current OneXray rustls fork origin

* chore: adopt published rustls 0.23.45 and official TLS binding

* chore: refresh N1 foundation and spike dependencies

* feat: validate next-protocol field and combination catalogs

* feat: share immutable TLS policies and bounded close semantics

* feat: add shared stream transports and decouple XUDP framing

* feat: add controlled datagram foundations and N1 acceptance harness

* chore: finalize N1 with verified x25519 dependency

* chore: publish N1 against the rustls release branch

* feat: add bounded Trojan request and datagram codecs

* feat: connect Trojan TLS TCP and UDP through the runtime

* feat: support Trojan WebSocket and duplex gRPC transports

* feat: enable Trojan and complete N2 consumer acceptance

* feat(vmess): add bounded AEAD header and body codecs

* fix(vmess): align close acceptance with Mihomo transports

* feat(vmess): add UDP codecs and isolated peer comparisons

* feat(vmess): complete public runtime and N3 acceptance

* docs: bind N3 acceptance and refresh validation guidance

* feat(vless): complete N4 transports, Vision and UDP support

Extract VLESS assembly, add plain/TLS stream transports, HTTPUpgrade, node-owned gRPC pooling, mTLS and classic REALITY, and implement Vision through public TLS record boundaries. Preserve XHTTP and the XUDP default while adding raw and packetaddr.

Complete 145 required groups and 39 field rows against isolated latest official peers, with 160 lifecycle/resource rounds, independent coverage and Apple/Android release builds. Preserve the three explicit WS/REALITY layered close comparisons and historical failures in the acceptance report. No third-party or dependency-lock changes.

* feat(vless): complete N5 XHTTP and sing-mux support

Add H1/H2/H3 request fields, independent download security and pools, bounded packet-up batching, and h2mux/smux/yamux over controlled transports.

Keep Mihomo-aligned close and path semantics, node-owned shutdown barriers, and isolated official-peer fixtures including the approved Caddy mTLS gateway.

Validate 416 required groups, 57 fields, 112 two-leg security checks, 240 lifecycle/resource cycles, independent coverage, and Apple/Android release builds. Record native-peer gaps and leave N6-N10, devices, CI, and release gates separate.

* feat: integrate boring TLS profiles and retire rustls fork

* test(tls): freeze selected fingerprint reference baseline

* docs(tls): record selected-profile library acceptance

* feat(tls): integrate selected client fingerprints and REALITY profiles

* feat(tls): complete selected fingerprint CF5 acceptance

* feat(hysteria2): complete N6 client support and acceptance

Implement Hysteria2 over official Quinn/h3/rustls and shared controlled IO, including TCP/UDP, bandwidth pacing, Salamander, port hopping, upstream snapshots and synchronous Stop.

Keep old-path receives active for the full bounded handover window, preserve independent reader wakeups, and require the exact nested TCP evidence assertions.

Validate one frozen N6 run: 36 required groups, 20 field rows, native Mihomo/Hysteria peers, H3 regression, 40 lifecycle rounds and Apple/Android production builds. Record independent coverage, artifact hashes and native-peer limitations.

* test(tls): record N7 hybrid REALITY prerequisite evidence

Preserve the locked classic-only API failure and distinguish the locally accepted boring hybrid extension from pending VCore S03/D16 integration. Record wrapper feasibility and publication boundaries without changing production configuration or dependencies.

* feat(vless): support explicitly required hybrid REALITY

* feat(crypto): wrap official BLAKE3 binary-context derivation

* feat(vless): implement authenticated Encryption wire transport

* feat(vless): enable authenticated Encryption across public transports

* build(tls): pin the authenticated ShadowTLS ClientHello hook

* feat(vless): add authenticated JLS transport security

Pin the separately approved boring JLS revision and expose strict main/download credentials under schema 24. Preserve native CertificateVerify and Finished, cancellation, and controlled IO ownership. Accept the JLS field slice with 122 isolated cases, 80 lifecycle/resource cycles, and Apple/Android release libraries; keep broader N7 gates separate.

* docs(n7): reconcile current JLS acceptance progress

* chore(vless): retire Restls while retaining JLS

* feat(vless): complete N7 static ECH and security combinations

Add static ECH for VLESS main and XHTTP download legs using existing TLS backends and official Rust HPKE. Keep Invoke v5 and advance the internal schema to revision 27.

Accept the narrowed N7 scope with 43 required groups, 11 fields, 301 isolated native cases, 240 lifecycle/resource rounds, and Apple/Android release builds. Record frozen inputs, 470 container cleanups, explicit upstream comparison gaps, and prior failed runs in docs/acceptance/next-protocols/N7.md.

* chore(protocols): retire WireGuard scope and foundations

* test: complete N9 protocol integration and resource gates

* build: add N10 production artifact evidence gates

* fix: restore Windows snapshot encoding and fail-closed delivery CI

* fix: use native ARM64 LLVM assembly and scoped delivery CI

* build: keep delivery lockfile bytes stable across platforms

* fix: preserve production guard lifecycle and isolate CI feature checks

* build: adopt released boring and registry shadowsocks

* ci: use release-oriented workflow names

* docs: consolidate contracts and streamline test tooling

Merge current protocol and platform contracts, remove milestone reports and obsolete spikes, and share core checks between local development and CI. Preserve all 884 executable case definitions and unique legacy assertions.

Validation: core Debug/Release, feature checks, Clippy, netstack, offline script tests, formatting and documentation links passed locally. Container interop smoke attempts failed during official peer downloads; business paths remain NOT RUN.

* test: replace milestone names with capability-based validation

Rename protocol and fingerprint suites, fixtures, and evidence identifiers by capability. Preserve acceptance cases and golden wire data while documenting reference, wire, and interoperability evidence separately.

* fix: address review findings and stabilize core CI

Flush accepted gRPC/H2 data through the supplied IO before reset, and wait for pending smux writes before FIN. Sanitize AnyTLS peer failures, reject XHTTP userinfo, and remove stale Android delivery artifacts.

Close container log capture even when inventory fails. Keep legacy host suites blocked before resource acquisition.

Separate Shadowsocks adapter codec checks from upstream strict server acceptance. Lock the random empty-request zero-padding failure with deterministic negative and positive fixtures, without changing the dependency or production behavior.

* test: isolate delivery fixture from Windows home lookup

* test: preserve UDP socket semantics during peer teardown

The memory peer treated its counterpart closing an mpsc channel as a local UDP BrokenPipe. That could terminate Quinn endpoint IO without waking a pending wait_idle, despite all four datagrams and CONNECTION_CLOSE having arrived.

Keep a closed peer link silent and late sends best-effort, add a deterministic fixture regression, and preserve the existing data and shutdown deadlines. Debug/Release, Clippy, and 300 consecutive regression iterations pass.

* fix: drain XHTTP uploads before releasing connection drivers

* fix: enforce lazy setup deadlines and safe delivery paths

Check the original deadline before accepting ready gRPC/H2 headers or sing-mux status, without limiting established reads. Reject symlinks and Windows reparse points in every delivery output path before filesystem mutations. Add deterministic memory and temporary-filesystem regressions.

* test: join XHTTP H3 peer tasks during cleanup

Quinn retains closed connections for three probe timeouts, so a delayed handshake can legitimately exceed the fixture's two-second wait_idle budget. Own, abort, and join the passive peer tasks after upload and client shutdown instead. Preserve upload integrity and client close bounds, and cover delayed handshakes in both streaming modes.
2026-09-28 12:50:01 +08:00
..

VCore

English · 简体中文 · Русский

VCore 是独立且不绑定特定宿主应用的 Rust 客户端代理 core。它通过严格 YAML 配置和 Invoke API v5 提供代理图、静态 select 代理组、DNS、规则、GeoData、HTTP/SOCKS5 listener、TUN 数据面与回环 Controller。内部配置 schema revision 为 27;revision 只出现在 version 响应和 buildIdentity 中,不写入 YAML。

能力

  • Outbound:VLESS TCP/WS/gRPC/HTTP/H2/XHTTP、TLS/REALITY 与 Vision、SOCKS5 CONNECT/UDP ASSOCIATE、AnyTLS TCP/UoT、Shadowsocks 2022、Trojan TCP/UDP(TLS/WS/gRPC)、VMess AEAD(TCP/WS/gRPC/HTTP/H2)、Hysteria2 TCP/UDP、带宽、Salamander 与端口跳跃、DIRECT。
  • 代理链:dialer-proxy 组成任意长度的有向无环图;节点 A 指向 B 时,物理路径为 client -> B -> A -> target。
  • 代理组:静态 select 组保留有序成员,可包含具体节点、嵌套组、DIRECT 与 REJECT;当前 session 的选择可通过 Controller 实时修改。dialer-proxy 可引用节点或组;上游组的 DIRECT 连接当前节点预解析的服务器。
  • 路由:顺序执行 DOMAIN、DOMAIN-SUFFIX、DOMAIN-KEYWORD、GEOSITE、GEOIP、IP-CIDR、IP-CIDR6、DST-PORT、NETWORK 和最终 MATCH。
  • DNS:固定 IP 的 UDP/TCP nameserver、显式出口、顺序 policy/failover、typed/opaque cache、singleflight、TUN UDP/TCP 53 劫持。
  • TUN:raw IPv4/IPv6、TCP/UDP、ICMPv4/ICMPv6 Echo 本地响应、HTTP/TLS/QUIC sniffer、每 session 四字段流量统计。
  • Listener:HTTP CONNECT/forward,逐请求认证与选路,支持流式正文、Keep-Alive 和 Upgrade;SOCKS5 CONNECT 与 TCP 授权的 UDP ASSOCIATE。默认本机免认证,局域网共享强制使用一组共用账号密码。
  • GeoData:VCore 管理 dataDir/geodata 下的 geosite.dat 和 geoip.dat,按需求加载并可通过代理链后台更新。
  • 测速:measureDelay 单次接收 1–5 份 node-only 配置,使用最多五个私有 worker,结果保持输入顺序。
  • TLS:独立证书 pin 与四种可选 ClientHello 模板;VLESS JLS保留完整原生 TLS 认证。静态 ECH接受显式的 VLESS 主/下载腿配置,不执行动态 DNS 查询或失败回落。

配置

docs/config.yaml 是唯一完整示例。核心约束:

  • YAML 最大 256 KiB,拒绝未知字段、anchor、alias、自定义 tag 和历史结构。
  • 顶层至少包含一个 proxy,并启用 port、socks-port 或 tun。
  • proxy 与 proxy group 定义名共享一个精确且大小写敏感的命名空间。名称为 1–64 UTF-8 字节,拒绝首尾 Unicode 空白、控制字符、, # / ? & = % \、.、..,并保留 DIRECT、REJECT 与 RULES;内部普通空格、CJK 和 emoji 可用。
  • proxy-groups 只接受 select。成员顺序与重复项均保留;省略 default-selected 时选择第一项,显式值必须是直接成员。节点上游与全部组成员(包括未选成员)必须组成同一张无环图。
  • rules 必填,必须恰好以一个指向已配置 proxy node 或 proxy group 的 MATCH 结束。
  • DIRECT 和 REJECT 是内置 action 与组成员;其他 route target 必须是已配置 proxy node 或 proxy group。RULES 只由 DNS 保留。
  • 配置通过 configYaml / configYamls 内联交付;VCore 不读取宿主配置路径。
  • Controller、TUN fd、Controller 端口/secret 等运行时值由宿主生成,不进入用户保存的 RAW YAML。

生命周期与 ABI

跨平台业务入口:

char *VCoreInvoke(const char *request_json);
void VCoreFree(char *response);

Windows 安装包另提供 revision-3 host bridge,负责全应用 VPN policy、profile、Session Snapshot 和可选 session backend:

char *VCoreWindowsVpnInvoke(const char *request_json);

业务生命周期为单公共实例:

initialize
  -> createInstance
  -> prepare(configYaml)
  -> start
  -> stop
  -> destroyInstance

instanceId 是当前 runtime 内不可复用的 generation token。同实例命令 fail-fast;纯 validateConfig 可并发执行。完整 envelope、method、fd 所有权和 Android protect 契约见 docs/invoke-api.md。

运行时状态通过 session-local loopback Controller 访问:

GET /traffic
GET /group
GET /group/{name}
GET /proxies/{name}
PUT /proxies/{name}
Authorization: Bearer <secret>

GET /traffic 返回一次 TUN up/down/upTotal/downTotal snapshot。代理组端点读取或修改静态 select 组的当前直接成员;成功切换只影响当前 session 后续新建的物理 TCP、UDP 与 DNS transport,不迁移既有连接、UDP association、DNS 状态或 TCP 连接池,也不自动故障转移。Controller 管理代理组时,全部路由必须共用一个 Bearer secret,并且可以不启用 TUN。详见 docs/controller-api.md。

已认证的 Hysteria2 会话在端口跳跃期间保留上游选择;同一 QUIC 会话替换物理 socket 不重新读取组选择,只有新建认证会话才使用新选择。

平台

平台 数据面 状态
iOS / macOS 宿主提供 utun fd;VCore duplicate 后通过 rust-tun 同步 device + Tokio AsyncFd 收发 已实现;Release iOS 真机 footprint 仍是发布门禁
Android VpnService 提供 raw-IP fd;每个 outbound socket 必须先通过 protect callback 已实现;真机矩阵仍需按发布计划执行
Windows Windows.Networking.Vpn AppContainer provider + 每 session full-trust runtime;同包命名管道传输 raw-IP Windows 11 ARM64 开发签名包已通过功能、lifecycle、pressure 与有界 batching 验收
Linux — 不支持,入口 fail closed

Windows 不使用 fd 模拟层。Provider 只拥有 VpnChannel、buffer、routes、物理网络监控、packet gateway 和 fail-closed Stop;完整 VCore runtime、Controller、DNS、rules 与 outbounds 位于 Session Host。packet channel 保持 protocol v1 framing,最多合并 8 个已经就绪的 frame,不等待未来 packet。

资源边界

使用局部队列、缓冲、解析上限、期限与所有者取消,不设置全局业务流准入数量。 共享上限见资源策略,专用预算见协议契约;内存遥测不改变生命周期结果。

文档

示例

验证

cargo fmt --all -- --check
uv run --project scripts --locked vcore-scripts check core --profile debug
cargo clippy --locked --all-features --lib --bins -- -D warnings
cargo test --manifest-path crates/vcore-netstack/Cargo.toml --all-targets
cargo clippy --manifest-path crates/vcore-netstack/Cargo.toml --all-targets -- -D warnings
uv run --project scripts --locked vcore-scripts check c-header
uv run --project scripts --locked vcore-scripts check tls-dependencies
uv run --project scripts --locked python -m unittest discover -s scripts/tests
uv run --project scripts --locked ruff check scripts
uv run --project scripts --locked ruff format --check scripts

平台产物(完整命令和环境变量见 scripts/README.md):

uv run --project scripts --locked vcore-scripts build apple
uv run --project scripts --locked vcore-scripts build android
uv run --project scripts --locked vcore-scripts build windows

当前有效的验证范围与仍延期的物理设备、Windows 发布矩阵见 docs/acceptance.md。

Credits

VCore 的依赖、维护中的 fork、公开 API/协议参考、架构参考与互操作对象包括:

License

VCore 使用 MIT License,见 LICENSE。