mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #435] [CLOSED] feat(proxy): tunnel sandbox TCP connections through the gateway #436
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#436
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/435
Author: @guozy18
Created: 10/25/2026
Status: ❌ Closed
Base:
main← Head:sync/sandbox-http-connect📝 Commits (3)
6794f40feat: support HTTP CONNECT tunneling to sandboxes in proxybdc1db0feat: relay HTTP CONNECT data-plane tunnels through the gateway8935236feat: route gateway CONNECT requests via authority-aware host route📊 Changes
9 files changed (+1216 additions, -8 deletions)
View changed files
📝
docs/src/internals/proxy-design.md(+49 -1)📝
services/README.md(+15 -1)➕
services/gateway/internal/connect.go(+297 -0)➕
services/gateway/internal/connect_test.go(+440 -0)📝
services/gateway/internal/host_route.go(+40 -0)📝
services/gateway/internal/host_route_test.go(+90 -0)📝
services/gateway/internal/metrics.go(+13 -1)📝
services/gateway/internal/server.go(+8 -3)📝
src/api/proxy.rs(+264 -2)📄 Description
What
Support raw TCP access to sandbox ports with HTTP/1.1 CONNECT, directly through a node or through the gateway. Clients can select a sandbox with the existing routing headers or the configured
{port}-{sandboxID}.{domain}authority.Why
The sandbox proxy currently handles HTTP and WebSocket traffic but cannot establish a TCP tunnel. A gateway also cannot relay a successful CONNECT with its ordinary
ReverseProxy, which bridges 101 upgrades rather than CONNECT's 200 response.Related issue
No linked issue.
Scope and non-goals
One end-to-end proxy capability: node tunnel establishment, gateway relay, authority-aware routing, tests and documentation. Existing HTTP/WebSocket routing and forwarded-header behavior are preserved. This does not introduce an arbitrary-destination forward proxy.
Design and behavior changes
client CONNECT -> gateway route/auth classification -> scheduler Lookup -> node authorization and runtime lookup/auto-resume -> guest TCP portCompatibility and operations
http://node endpoints only.Validation
make fmt(equivalentcargo fmt --all -- --check)make clippy(explicit package/all-target/all-feature command below)make test-unitmake -C services testmaketarget (no generated changes)Commands and results on isolated Linux, from this branch alone on
424b852:Real scheduler + gateway + non-root node + KVM guest: cold create/assignment; header and authority CONNECT to envd; private-traffic and secure-envd authentication; API key cannot replace a private-traffic token; 1 MiB binary echo with coalesced early bytes and client half-close; closed port and unknown sandbox errors; unauthorized access leaves a sandbox paused; authorized CONNECT auto-resumes the guest and its echo process; auto-resume-disabled returns 410; deletion rejects new access. All passed; task sandboxes and processes were cleaned up.
Skipped checks: the aggregate
make test-unitand unrelated storage suites were not run; relevant Rust tests, all Go packages with race detection, and the actual gateway-to-KVM flow were run. No throughput benchmark was performed.Risks and reviewer notes
Established tunnels have no new idle timeout or lifecycle cancellation signal. An idle tunnel is not actively terminated by pause/delete; the KVM check observed no EOF within two seconds, then closed the client explicitly. New connections still enforce current sandbox state and authorization.
Review the token-preserving request replay, buffered readers and half-close/error cleanup in
services/gateway/internal/connect.go, and node establishment insrc/api/proxy.rs.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.