Skip to content

Commit

Permalink
otc: use default transport (#2363)
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez authored Nov 27, 2024
1 parent 2c42b26 commit 8e5448c
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions providers/dns/otc/otc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"errors"
"fmt"
"net"
"net/http"
"time"

Expand Down Expand Up @@ -55,28 +54,25 @@ type Config struct {

// NewDefaultConfig returns a default configuration for the DNSProvider.
func NewDefaultConfig() *Config {
tr := &http.Transport{}

defaultTransport, ok := http.DefaultTransport.(*http.Transport)
if ok {
tr = defaultTransport.Clone()
}

// Workaround for keep alive bug in otc api
tr.DisableKeepAlives = true

return &Config{
TTL: env.GetOrDefaultInt(EnvTTL, minTTL),
PropagationTimeout: env.GetOrDefaultSecond(EnvPropagationTimeout, dns01.DefaultPropagationTimeout),
PollingInterval: env.GetOrDefaultSecond(EnvPollingInterval, dns01.DefaultPollingInterval),
IdentityEndpoint: env.GetOrDefaultString(EnvIdentityEndpoint, defaultIdentityEndpoint),
SequenceInterval: env.GetOrDefaultSecond(EnvSequenceInterval, dns01.DefaultPropagationTimeout),
HTTPClient: &http.Client{
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 10*time.Second),
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,

// Workaround for keep alive bug in otc api
DisableKeepAlives: true,
},
Timeout: env.GetOrDefaultSecond(EnvHTTPTimeout, 10*time.Second),
Transport: tr,
},
}
}
Expand Down

0 comments on commit 8e5448c

Please sign in to comment.