Adds ability for the user to set whether or not proxyless should be used#1509
Adds ability for the user to set whether or not proxyless should be used#1509myleshorton wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request transitions from a proxyAll approach to a more explicit useProxyless configuration mechanism. The change allows dynamic control over whether proxyless dialing should be enabled, providing clearer semantics around when to use direct connections versus proxy connections.
Key changes:
- Replaces
ProxyAllfunctionality withUseProxylessfor clearer intent - Adds dynamic configuration capability through function-based options
- Updates dialer logic to respect both system capabilities and user preferences
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| option.go | Adds WithUseProxyless option to configure proxyless dialing behavior |
| flashlight.go | Integrates useProxyless field and passes it to client initialization |
| dialer/parallel_dialer.go | Updates dialing logic to check both system support and user preference |
| dialer/dialer.go | Replaces ProxyAll with UseProxyless in options struct |
| client/client.go | Adds useProxyless field and integrates it into dialer initialization |
| if !common.SupportsProxyless() || !d.opts.UseProxyless() { | ||
| // If the proxyless transport is not supported, we fall back to the default dialer. |
There was a problem hiding this comment.
The condition logic appears incorrect. The function should fall back to default dialer when proxyless is NOT supported OR when proxyless is NOT enabled. However, the function name UseProxyless suggests it returns true when proxyless should be used, making the negation !d.opts.UseProxyless() potentially confusing. Consider verifying the intended behavior: should this be !d.opts.UseProxyless() (fall back when proxyless is disabled) or d.opts.UseProxyless() == false?
| if !common.SupportsProxyless() || !d.opts.UseProxyless() { | |
| // If the proxyless transport is not supported, we fall back to the default dialer. | |
| if !common.SupportsProxyless() || d.opts.UseProxyless() == false { | |
| // If proxyless transport is not supported or not enabled, fall back to the default dialer. |
| socksWg sync.WaitGroup | ||
|
|
||
| DNSResolutionMapForDirectDialsEventual eventual.Value | ||
| useProxyless func() bool |
There was a problem hiding this comment.
The useProxyless field is added to the Client struct but there's no nil check before using it in initDialers. If useProxyless is nil when passed to UseProxyless, this could cause a panic when the function is called.
This pull request introduces a new
useProxylessfunction to enable or disable proxyless dialing dynamically across the application. The changes primarily involve replacing the previousProxyAllfunctionality withUseProxylessand updating the relevant code to reflect this new approach. Below are the key changes grouped by theme:Client Updates:
useProxylessfield to theClientstruct inclient/client.go, allowing the client to determine whether to use proxyless dialing dynamically.NewClientconstructor to accept theuseProxylessfunction and initialize it in theClientstruct. [1] [2]initDialersmethod to pass theuseProxylessfunction to the dialer options instead of the previousproxyAllfunction.Dialer Updates:
ProxyAllfield in theOptionsstruct withUseProxyless, and updated the corresponding comments to reflect the new functionality indialer/dialer.go.Clonemethod of theOptionsstruct to include the newUseProxylessfield.newParallelPreferProxylessfunction indialer/parallel_dialer.goto check bothcommon.SupportsProxyless()and theUseProxylessfunction before falling back to the default dialer.Flashlight Updates:
useProxylessfield to theFlashlightstruct inflashlight.goto propagate the proxyless functionality.Newfunction inflashlight.goto pass theuseProxylessfunction to the client during initialization.Option Enhancements:
WithUseProxylessoption inoption.goto allow external configuration of theuseProxylessfunction for theFlashlightclient.