1
0
forked from wrenn/wrenn

WIP: Add sandbox proxy catch-all to control plane

Add SandboxProxyWrapper that intercepts requests with Host headers
matching {port}-{sandbox_id}.{domain} and proxies them through the
owning host agent's /proxy endpoint.

Authentication is via X-API-Key only (no JWT). The API key's team must
own the sandbox. Export EnsureScheme from lifecycle package for reuse.

Request flow: SDK -> Caddy -> CP catch-all -> Host Agent -> sandbox VM.

This is an intermediate state — needs further work for the full code
interpreter feature.
This commit is contained in:
2026-03-26 02:12:10 +06:00
parent f4675ebfc0
commit 4be65b0abb
3 changed files with 158 additions and 4 deletions

View File

@ -45,7 +45,7 @@ func (p *HostClientPool) Get(hostID, address string) hostagentv1connect.HostAgen
if c, ok = p.clients[hostID]; ok {
return c
}
c = hostagentv1connect.NewHostAgentServiceClient(p.httpClient, ensureScheme(address))
c = hostagentv1connect.NewHostAgentServiceClient(p.httpClient, EnsureScheme(address))
p.clients[hostID] = c
return c
}
@ -68,8 +68,8 @@ func (p *HostClientPool) Evict(hostID string) {
p.mu.Unlock()
}
// ensureScheme adds "http://" if the address has no scheme.
func ensureScheme(addr string) string {
// EnsureScheme adds "http://" if the address has no scheme.
func EnsureScheme(addr string) string {
if strings.HasPrefix(addr, "http://") || strings.HasPrefix(addr, "https://") {
return addr
}