Register direct transport for unbounded signaling#375
Open
myleshorton wants to merge 4 commits intomainfrom
Open
Register direct transport for unbounded signaling#375myleshorton wants to merge 4 commits intomainfrom
myleshorton wants to merge 4 commits intomainfrom
Conversation
Add lazyDirectTransport, an http.RoundTripper that wraps sing-box's direct outbound dialer. It is registered in the context before the sing-box service is created (so unbounded can retrieve it during construction) and resolved after (once the direct outbound exists). The direct outbound's dialer carries platform-specific socket protection (VpnService.protect on Android, IP_BOUND_IF on iOS/macOS, etc.), ensuring that unbounded's signaling traffic bypasses the VPN tunnel on all platforms. Depends on getlantern/lantern-box#200 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a “lazy” direct http.RoundTripper that can be registered into the sing-box context early (so outbounds like unbounded can capture it during construction) and then resolved after libbox.NewServiceWithContext returns by wiring it to the sing-box direct outbound dialer.
Changes:
- Register a
lazyDirectTransportin the tunnel context before creating the libbox service. - Resolve
lazyDirectTransportafter service creation by looking up thedirectoutbound and building anhttp.Transportthat dials via it. - Add new
vpn/direct_transport.goimplementing the lazy transport.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| vpn/tunnel.go | Registers and resolves the lazy direct transport around NewServiceWithContext. |
| vpn/direct_transport.go | Implements an http.RoundTripper that defers to a resolved inner transport built from the direct outbound dialer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… Resolve, add tests - Copy inner/resolved under read lock, release before I/O (avoids blocking Resolve) - Clone http.DefaultTransport instead of bare http.Transport (preserves timeouts, HTTP/2) - Make Resolve failure fatal in tunnel init (fail fast, not at runtime) - Add unit tests for unresolved, resolved, no-outbound-manager, and concurrent cases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (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
lazyDirectTransport— anhttp.RoundTripperbacked by sing-box'sdirectoutbound dialeradapter.DirectTransportFromContextNewServiceWithContextreturns (when the direct outbound exists)How it works
Platform bypass mechanisms (via direct outbound)
VpnService.protect(fd)IP_BOUND_IF/IPV6_BOUND_IFSO_BINDTOIFINDEXDependencies
ContextWithDirectTransport/DirectTransportFromContextand wires unbounded to use it)go.modhere to pick up the new lantern-box versionTest plan
🤖 Generated with Claude Code