From fbe91ee58b565cae7d5cb1ecac41df86597d4ff1 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 7 Apr 2018 22:33:11 +0200 Subject: [PATCH] No need to initialize xTransport before we have all the parameters --- dnscrypt-proxy/config.go | 2 ++ dnscrypt-proxy/main.go | 2 -- dnscrypt-proxy/xtransport.go | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index 6ce058fe..b733e522 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -207,6 +207,8 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error { proxy.logMaxSize = config.LogMaxSize proxy.logMaxAge = config.LogMaxAge proxy.logMaxBackups = config.LogMaxBackups + + proxy.xTransport = NewXTransport() proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets proxy.xTransport.tlsCipherSuite = config.TLSCipherSuite proxy.xTransport.fallbackResolver = config.FallbackResolver diff --git a/dnscrypt-proxy/main.go b/dnscrypt-proxy/main.go index c5987e71..cd0bac98 100644 --- a/dnscrypt-proxy/main.go +++ b/dnscrypt-proxy/main.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "sync" - "time" "github.com/facebookgo/pidfile" "github.com/jedisct1/dlog" @@ -44,7 +43,6 @@ func main() { dlog.Debug(err) } app.proxy = NewProxy() - app.proxy.xTransport = NewXTransport(30*time.Second, true, false) if err := ConfigLoad(&app.proxy, svcFlag); err != nil { dlog.Fatal(err) diff --git a/dnscrypt-proxy/xtransport.go b/dnscrypt-proxy/xtransport.go index 534b97c4..f72071b8 100644 --- a/dnscrypt-proxy/xtransport.go +++ b/dnscrypt-proxy/xtransport.go @@ -43,20 +43,20 @@ type XTransport struct { } var DefaultKeepAlive = 5 * time.Second +var DefaultTimeout = 30 * time.Second -func NewXTransport(timeout time.Duration, useIPv4 bool, useIPv6 bool) *XTransport { +func NewXTransport() *XTransport { xTransport := XTransport{ cachedIPs: CachedIPs{cache: make(map[string]string)}, keepAlive: DefaultKeepAlive, - timeout: timeout, + timeout: DefaultTimeout, fallbackResolver: DefaultFallbackResolver, ignoreSystemDNS: false, - useIPv4: useIPv4, - useIPv6: useIPv6, + useIPv4: true, + useIPv6: false, tlsDisableSessionTickets: false, tlsCipherSuite: nil, } - xTransport.rebuildTransport() return &xTransport }