feat(ports): wire portsAttributes into forwarding decisions#248
Conversation
Add RequireLocalPort and ElevateIfNeeded to PortForwardAttribute struct and propagate them through the container-side resolver. Implement requireLocalPort check in the watcher (skips forwarding when the local port is unavailable), elevateIfNeeded warning in the host-side forwarder for privileged ports, differentiated log levels for onAutoForward (silent=debug, notify/openBrowser=info), and protocol metadata in forwarder log output.
The requireLocalPort check in watcher.go called IsAvailable inside the container where the port is already in LISTEN state, making it always fail. The correct enforcement point is the host-side forwarder which already implements this correctly. Also removes the tautological test that never exercised the actual watcher logic.
✅ Deploy Preview for devsydev canceled.
|
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Verifies that when requireLocalPort=true and the host port is already occupied, port forwarding is skipped rather than falling back to another port.
Reference AutoForwardIgnore and AutoForwardSilent from the config package instead of redeclaring string literals.
Summary
Wires all 5 devcontainer
portsAttributesfields into runtime behavior per the devcontainer spec:ignoreskips forwarding entirely;silent/empty logs at debug level;notify/openBrowserlogs at info levelThe
requireLocalPortcheck was intentionally removed from the container-side watcher (pkg/netstat/watcher.go) because it cannot meaningfully test host port availability from inside the container. Enforcement happens exclusively in the host-side forwarder (pkg/tunnel/forwarder.go).Files changed:
cmd/agent/container/credentials_server.go— propagate all 5 fields through the container-side port resolverpkg/netstat/watcher.go— pass attributes to forwarding decisions, remove broken container-side requireLocalPort checkpkg/netstat/watcher_test.go— add tests for attribute propagationpkg/tunnel/forwarder.go— enforce requireLocalPort, elevateIfNeeded, onAutoForward, label, and protocol at the forwarding layer