分享一个单协议小实现:Espejismo(Rust 加密隧道,不做协议伪装) #6864
tianrking
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
(作者自荐,技术分享)我实现了一个很小的单协议加密隧道 Espejismo:https://github.com/tianrking/Espejismo
和 Xray 这种多协议平台是反方向:只有一个协议、一个服务端二进制、一个客户端二进制、一个 TOML。不做 TLS / QUIC / HTTP 伪装。
协议层面的几个具体设计
握手(首包是变长掩码信封):
floor(unix_time / step_secs);客户端发当前 slot,服务端容忍相邻 slot帧:HKDF 派生的 XChaCha20-Poly1305;4 字节长度用 per-direction、按帧序号推进的 header-mask 流掩码;每 N 帧发一个加密 KEY_UPDATE 控制帧轮换流量密钥;AEAD 失败直接 fail-fast 丢连接,不做流内重同步。
能力协商:capability bit 0 = TCP CONNECT,bit 1 = UDP ASSOCIATE,bit 8 = yamux,bit 9 = 自研 mux;握手时检查双向 capability 交集,不匹配直接报 mux capability error。
和 Xray 生态的对比
实测数据
协议细节在
docs/PROTOCOL.md。协议实现上有什么明显的问题,欢迎 review。All reactions