Conversation
2c62f65 to
31694e1
Compare
There was a problem hiding this comment.
Pull request overview
This pull request adds support for HAProxy PROXY protocol (v1 and v2) and X-Forwarded-For header parsing to help Tentacle resolve the actual origin address when connections come through a proxy.
Changes:
- Added comprehensive PROXY protocol v1/v2 parser module with full test coverage
- Integrated proxy protocol parsing into TCP connection handling
- Added X-Forwarded-For and X-Forwarded-Port header extraction for WebSocket connections
- Introduced
trusted_proxiesconfiguration (defaults to loopback addresses) to control when proxy headers are parsed - Updated Rust toolchain to 1.92.0 and modernized code using
div_ceil
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tentacle/src/transports/proxy_protocol.rs | New module implementing HAProxy PROXY protocol v1/v2 parsing with comprehensive unit tests |
| tentacle/src/transports/tcp_base_listen.rs | Integrated proxy protocol and X-Forwarded-For parsing into connection handling based on trusted proxy list |
| tentacle/src/transports/tcp.rs | Added trusted_proxies field to TcpTransport |
| tentacle/src/transports/mod.rs | Added proxy_protocol module export |
| tentacle/src/service/config.rs | Added trusted_proxies configuration with default localhost values |
| tentacle/src/service.rs | Passes trusted_proxies through to MultiTransport; minor clippy fixes |
| tentacle/src/builder.rs | Added trusted_proxies() builder method with documentation |
| tentacle/tests/test_proxy_protocol.rs | Comprehensive integration tests covering TCP PROXY protocol and WebSocket X-Forwarded-For scenarios |
| tentacle/src/channel/unbound.rs | Added clippy::unnecessary_unwrap allowance for complex drop logic |
| tentacle/src/channel/bound.rs | Added clippy::unnecessary_unwrap allowance for complex drop logic |
| secio/src/dh_compat/openssl_impl.rs | Modernized ceiling division using div_ceil method |
| rust-toolchain | Updated Rust version from 1.85.0 to 1.92.0 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4779b85 to
1d76120
Compare
eval-exec
approved these changes
Feb 6, 2026
eval-exec
reviewed
Feb 6, 2026
1d76120 to
ea67814
Compare
sunchengzhu
added a commit
to sunchengzhu/ckb-proxy-protocol-test
that referenced
this pull request
Feb 10, 2026
根因: 两个因素叠加导致 WS 节点重启后永久无法重连 1. peer_store 的 base_addr() 会剥离 /ws 后缀 存入: /ip4/x.x.x.x/tcp/8231/ws/p2p/... 取出: /ip4/x.x.x.x/tcp/8231/p2p/...(丢失 /ws) 重连时 find_type() 判定为 TCP 传输 用原始 TCP 连接 HAProxy HTTP 端口 -> 永久失败 2. HAProxy HTTP 模式断开传播较慢 TCP 模式: 收到 FIN -> 立即关闭后端 -> Node B 清理 session HTTP 模式: WebSocket 隧道清理有延迟 -> 旧 session 残留 新连接到达时 PeerIdExists -> 拒绝 TCP PP 节点不受影响: base_addr() 不剥离 TCP 地址的任何部分 HAProxy TCP 模式断开传播即时 修复: - 启动前清理 WS 节点的 peer_store 强制使用带 /ws 的 bootnode - 跨机场景增加 3 秒延迟 等待服务端旧 session 清理 参考: nervosnetwork/ckb#5105, nervosnetwork/tentacle#422
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.
Feature
X-Forwarded-For/X-Forwarded-Porton WebSocketBoth can help Tentacle in resolving the actual origin address after a proxy.
Test
Nginx
Nginx only supports proxy protocol v1
nginx conf:
Run Docker with:
$ docker run --rm -d --name nginx-proxy-test \ --network host \ -v $(pwd)/nginx-proxy-test.conf:/etc/nginx/nginx.conf:ro \ nginx:alpineHaproxy
haproxy conf
Run Docker with:
$ docker run --rm -d --name haproxy-proxy-test --network host \ -v $(pwd)/haproxy-proxy-test.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro \ haproxy:alpinetentacle
Write two Tentacle programs: