Skip to content

Commit

Permalink
pointer cleanup;
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfinn committed Nov 26, 2023
1 parent 6ad3a0f commit ac86466
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func buildFromConfig(config *httpClientConfig) (*http.Client, profiles.ClientPro
dialer = newDirectDialer(config.timeout, config.localAddr, config.dialer)

if config.proxyUrl != "" {
proxyDialer, err := newConnectDialer(config.proxyUrl, config.timeout, config.localAddr, &config.dialer)
proxyDialer, err := newConnectDialer(config.proxyUrl, config.timeout, config.localAddr, config.dialer)
if err != nil {
return nil, profiles.ClientProfile{}, err
}
Expand All @@ -130,10 +130,10 @@ func buildFromConfig(config *httpClientConfig) (*http.Client, profiles.ClientPro
redirectFunc = defaultRedirectFunc
} else {
redirectFunc = nil
}

if config.customRedirectFunc != nil {
redirectFunc = config.customRedirectFunc
if config.customRedirectFunc != nil {
redirectFunc = config.customRedirectFunc
}
}

clientProfile := config.clientProfile
Expand Down Expand Up @@ -221,7 +221,7 @@ func (c *httpClient) applyProxy() error {

if c.config.proxyUrl != "" {
c.logger.Debug("proxy url %s supplied - using proxy connect dialer", c.config.proxyUrl)
proxyDialer, err := newConnectDialer(c.config.proxyUrl, c.config.timeout, c.config.localAddr, &c.config.dialer)
proxyDialer, err := newConnectDialer(c.config.proxyUrl, c.config.timeout, c.config.localAddr, c.config.dialer)
if err != nil {
c.logger.Error("failed to create proxy connect dialer: %s", err.Error())
return err
Expand Down
6 changes: 3 additions & 3 deletions client_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type httpClientConfig struct {
localAddr *net.TCPAddr
// Establish a connection to origin server via ipv4 only
disableIPV6 bool
dialer net.Dialer
dialer net.Dialer
}

// WithProxyUrl configures a HTTP client to use the specified proxy URL.
Expand Down Expand Up @@ -102,9 +102,9 @@ func WithTimeoutMilliseconds(timeout int) HttpClientOption {
}

// WithDialer configures an HTTP client to use the specified dialer. This allows the use of a custom DNS resolver
func WithDialer(dialer *net.Dialer) HttpClientOption {
func WithDialer(dialer net.Dialer) HttpClientOption {
return func(config *httpClientConfig) {
config.dialer = *dialer
config.dialer = dialer
}
}

Expand Down
4 changes: 2 additions & 2 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type connectDialer struct {
// newConnectDialer creates a dialer to issue CONNECT requests and tunnel traffic via HTTP/S proxy.
// proxyUrlStr must provide Scheme and Host, may provide credentials and port.
// Example: https://username:[email protected]:443
func newConnectDialer(proxyUrlStr string, timeout time.Duration, localAddr *net.TCPAddr, configDialer *net.Dialer) (proxy.ContextDialer, error) {
func newConnectDialer(proxyUrlStr string, timeout time.Duration, localAddr *net.TCPAddr, configDialer net.Dialer) (proxy.ContextDialer, error) {
proxyUrl, err := url.Parse(proxyUrlStr)
if err != nil {
return nil, err
Expand Down Expand Up @@ -127,7 +127,7 @@ func newConnectDialer(proxyUrlStr string, timeout time.Duration, localAddr *net.

dialer := &connectDialer{
ProxyUrl: *proxyUrl,
Dialer: *_dialer,
Dialer: _dialer,
Timeout: timeout,
DefaultHeader: make(http.Header),
EnableH2ConnReuse: true,
Expand Down

0 comments on commit ac86466

Please sign in to comment.