feat: OPENSHELL_DIRECT_TCP_ENDPOINTS for per-endpoint TCP bypass#1
Merged
kosaku-sim merged 1 commit intofix/sandbox-dns-udp-acceptfrom Apr 21, 2026
Merged
Conversation
Adds a new env var parallel to OPENSHELL_DIRECT_TCP_HOSTS that accepts host:port pairs (comma-separated). Each pair installs iptables rules: - sandbox netns OUTPUT: ACCEPT to dest IP / dport - host POSTROUTING: MASQUERADE for the same dest/port - host FORWARD: ACCEPT for the same dest/port - child_env NO_PROXY: host portion added so HTTP clients also bypass Unlike DIRECT_TCP_HOSTS (broad TCP 443 ACCEPT), this is per-endpoint — required for: - non-HTTPS protocols the egress proxy cannot CONNECT-tunnel (postgres 5432, redis 6379 wire protocols) - ports the proxy explicitly blocks with ECONNRESET (5432, 6379, 15432, 16379 observed) - raw-TCP clients that ignore HTTP_PROXY env Host component may be an IPv4 literal or hostname; hostnames are resolved at pod startup via the pod netns resolver. IPv6 addresses are dropped (sandbox iptables rules are IPv4-only). Use case: sandbox reaching services on the pod host (postgres, redis, mailhog) via AUTODEV_HOST_IP without a port-forward daemon inside the sandbox. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds a new env var
OPENSHELL_DIRECT_TCP_ENDPOINTS(parallel toOPENSHELL_DIRECT_TCP_HOSTS) that accepts comma-separatedhost:portpairs, each installing per-endpoint iptables ACCEPT + MASQUERADE + FORWARD rules to bypass the egress proxy.Motivation
The existing
OPENSHELL_DIRECT_TCP_HOSTSinstalls a broad TCP 443 ACCEPT. This is sufficient for HTTPS services bypassing the proxy CA, but does not cover:access: fullHTTP_PROXYenv (e.g.pg,ioredis, smtp clients)Use case: sandbox reaching postgres/redis/mailhog on the pod host (via
AUTODEV_HOST_IP) without a port-forward daemon inside the sandbox.Changes
netns.rs:parse_direct_tcp_endpoints()— parsehost:portpairs with validationresolve_endpoint_ipv4s()— IPv4 literal or hostname resolution (IPv6 dropped)child_env.rs:build_no_proxy()also includes host portion of each endpoint (so rustls/curl bypass proxy for those hosts too)Verification
Built on Graviton (aarch64), binary deployed to the cluster container at
/opt/openshell/bin/openshell-sandbox, sandbox CRD env set to:Pod recreated. Probe from inside the sandbox:
10.0.1.215:5432(postgres)SELECT version()OK10.0.1.215:6379(redis)10.0.1.215:1025(smtp)10.0.1.215:8025(mailhog UI)Test plan
cargo test -p openshell-sandbox(unit tests for parsing + NO_PROXY)