Propagate mainProto to xTransport

Fixes #880
This commit is contained in:
Frank Denis 2019-07-10 13:13:28 +02:00
parent ad05fd6f21
commit 0569c75596
2 changed files with 5 additions and 2 deletions

View File

@ -260,6 +260,7 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets
proxy.xTransport.tlsCipherSuite = config.TLSCipherSuite proxy.xTransport.tlsCipherSuite = config.TLSCipherSuite
proxy.xTransport.fallbackResolver = config.FallbackResolver proxy.xTransport.fallbackResolver = config.FallbackResolver
proxy.xTransport.mainProto = proxy.mainProto
if len(config.FallbackResolver) > 0 { if len(config.FallbackResolver) > 0 {
proxy.xTransport.ignoreSystemDNS = config.IgnoreSystemDNS proxy.xTransport.ignoreSystemDNS = config.IgnoreSystemDNS
} }

View File

@ -38,6 +38,7 @@ type XTransport struct {
timeout time.Duration timeout time.Duration
cachedIPs CachedIPs cachedIPs CachedIPs
fallbackResolver string fallbackResolver string
mainProto string
ignoreSystemDNS bool ignoreSystemDNS bool
useIPv4 bool useIPv4 bool
useIPv6 bool useIPv6 bool
@ -56,6 +57,7 @@ func NewXTransport() *XTransport {
keepAlive: DefaultKeepAlive, keepAlive: DefaultKeepAlive,
timeout: DefaultTimeout, timeout: DefaultTimeout,
fallbackResolver: DefaultFallbackResolver, fallbackResolver: DefaultFallbackResolver,
mainProto: "",
ignoreSystemDNS: false, ignoreSystemDNS: false,
useIPv4: true, useIPv4: true,
useIPv6: false, useIPv6: false,
@ -249,8 +251,8 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
} else { } else {
dlog.Noticef("System DNS configuration not usable yet, exceptionally resolving [%s] using fallback resolver [%s]", host, xTransport.fallbackResolver) dlog.Noticef("System DNS configuration not usable yet, exceptionally resolving [%s] using fallback resolver [%s]", host, xTransport.fallbackResolver)
} }
dnsClient := new(dns.Client) dnsClient := dns.Client{Net: xTransport.mainProto}
foundIP, err = xTransport.resolveUsingResolver(dnsClient, host, xTransport.fallbackResolver) foundIP, err = xTransport.resolveUsingResolver(&dnsClient, host, xTransport.fallbackResolver)
} }
if foundIP == nil { if foundIP == nil {
return nil, 0, fmt.Errorf("No IP found for [%s]", host) return nil, 0, fmt.Errorf("No IP found for [%s]", host)