实现完整 gRPC 客户端、服务端与 Xray 互操作#41
Draft
MiChongs wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与目标
本变更为 WutherCore 增加完整的 Xray gRPC(gun)传输支持,覆盖真实客户端、真实服务端、
Tun/TunMulti流式 RPC、TLS/REALITY、安全校验、配置注册和现有代理协议承载。实现使用 tonic 与 prost,不以自定义占位帧、普通 HTTP/2 请求或仅配置映射代替 gRPC 协议。Xray 26.7.11 已提示 gRPC 传输属于兼容性功能并建议新部署迁移到 XHTTP,但现有节点、订阅和服务端仍需要完整互操作,因此本实现保留严格、可测试、失败关闭的全功能支持。
分支与提交关系
codex/transport-grpc-fullcodex/protocol-xhttp-fullbfb441f1a3f5b5996f336184edcc9bdb8de5ec95本 PR 以 XHTTP 分支为基线,是因为 gRPC 复用该分支提供的统一 TLS/ECH/REALITY 传输抽象。这样可以避免在 gRPC 提交中重复复制基础设施,并确保 PR 差异严格只有一个 gRPC 实现提交。XHTTP 合并后,本分支可直接改基到
main。核心协议实现
core-grpccrate,使用tonic、prost、hyper、tower和 Tokio 实现实际 gRPC 数据面。Hunk与MultiHunk,并用固定金丝雀测试验证字段编号和重复字段编码。/{service}/Tun、/{service}/TunMulti,兼容空服务名、旧式默认方法和 Xray 自定义路径规则。Tun与TunMulti,支持单连接服务、关闭通知和活动连接回收。流、背压与关闭语义
AsyncRead/AsyncWrite的双向字节流,供现有代理协议直接承载。flush会等待消息被 tonic 发送侧实际消费,避免只写入本地队列就提前返回。TunMulti的聚合与向量写入不会超过编码后限制。客户端与现有协议承载
multiMode、serviceName、authority、userAgent、自定义请求头、空闲超时、健康检查超时和初始窗口等 Xray 字段。服务端与入站支持
listen.grpc入站配置,可启动 VLESS-over-gRPC 服务端。Tun与TunMulti、TCP、UDP、VLESS mux、用户 UUID 校验和统一路由运行时。h2,不允许安全配置静默降级。配置字段与兼容性
serviceName、multiMode、authority、userAgent、idleTimeout、healthCheckTimeout、permitWithoutStream、初始连接/流窗口、请求头以及资源限制。Cargo.lock已包含 tonic、prost 及其传递依赖的固定版本,构建不依赖 CI 临时解析。安全与资源治理
验证结果
cargo test -p core-grpc:18 项通过。cargo test -p core-config grpc:7 项通过。cargo test -p core-inbound grpc --lib:4 项通过。cargo test -p core-outbound grpc --lib:11 项通过。cargo test -p wuther-core:16 项通过。cargo check --workspace --all-targets:通过。cargo fmt --all -- --check:通过。git diff --check codex/protocol-xhttp-full...HEAD:通过。50231ea)互操作:7 项全部通过。官方互操作覆盖:
Tun与TunMulti。Tun与TunMulti。审阅说明
本 PR 保持草稿状态。建议先审阅
core-grpc的 wire format、流背压与关闭语义,再审阅配置映射、协议注册和入站启动接线。