feat: add WebSocket TCP port forwarding for sandbox containers#523
Open
Timandes wants to merge 2 commits intoalibaba:masterfrom
Open
feat: add WebSocket TCP port forwarding for sandbox containers#523Timandes wants to merge 2 commits intoalibaba:masterfrom
Timandes wants to merge 2 commits intoalibaba:masterfrom
Conversation
- Add /sandboxes/{id}/portforward WebSocket endpoint in proxy layer
- Add /portforward WebSocket endpoint in rocklet for internal TCP proxy
- Support port range 1024-65535, excluding port 22 (SSH)
- Implement two-layer architecture: external proxy -> rocklet -> TCP port
- Add comprehensive logging with target_port in all messages
- Handle both FastAPI WebSocket and websockets library APIs
- Add unit tests for port validation, URL building, and route handling
- Capture close frame (code, reason) when rocklet closes connection - Forward close frame to client instead of silently dropping - Properly wait for cancelled tasks to complete - Improve logging for connection close events
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.
Complete GH Issue #520 :
实现方式相比Issue #520 做了一点调整:
通过rocklet转发TCP over WebSocket;外层代理层仅负责处理WebSocket转发。
启动沙箱的脚本可以参考:
测试程序可以使用:
https://github.com/Timandes/ROCK-TCP-to-WS-Forwarder