REALITY protocol: Add ChaCha20-Poly1305 auth mode#2208
Conversation
This commit comes with other optimizations with current REALITY client implementation: 1. Reuse existing sessionId slice instead of allocating a new one. 2. Adjust sessionId processing order to eliminate bounds checks. 3. Cache the offset of `peerCertificates` to avoid reflection overhead.
|
感谢 PR,Session ID 那段如果没有 new 一个 |
|
加上一个 point 到该切片的指针, |
|
我的那个 commit 是看着 WireShark 写的,改后没测过,麻烦大家测一下 f09c391 的 REALITY 是否正常
|
|
我又想了一下,这个对置零的优化其实不太好,因为它依赖于“SessionId 不是 Raw 的引用”,没写这个注释的话,别人看代码会一头雾水。并且它取决于 uTLS 的行为,不受我们控制,是一种隐式的 unsafe,应当避免。所以还是原来的写法更清晰、安全。 |
|
并且这个由于是客户端实现,linkname 应当改为针对 uTLS(且不用单独放一个文件),方便其它 Go 客户端参考 我会删掉 f09c391 ,麻烦开两个 PR,一个 Add Chacha20-Poly1305 auth mode,一个专门优化 reflect(包括 XTLS 那里) |
The slice variable does not store a pointer to slice header but slice header struct itself. This is a temporary variable and not being referred anywhere else, so it is expected to be allocated on stack, which is cheap enough. |
是的,堆上的话是我说的情况,不是说切片变量不是结构体,我的意思是程序总要存它的首内存地址,栈上的话则你说的是合理的 |
This comes with other optimizations with current REALITY client implementation:
peerCertificatesto avoid reflection overhead.