From 74c1f4a00dec9ad8d74d50deab1f094036701de7 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 20 Oct 2019 21:45:19 +0200 Subject: [PATCH] Use the relay for cert retrieval over TCP, tooo But don't use a relay if a proxy has been specified already --- dnscrypt-proxy/dnscrypt_certs.go | 7 ++++++- dnscrypt-proxy/proxy.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dnscrypt-proxy/dnscrypt_certs.go b/dnscrypt-proxy/dnscrypt_certs.go index fe22ece0..a30c2955 100644 --- a/dnscrypt-proxy/dnscrypt_certs.go +++ b/dnscrypt-proxy/dnscrypt_certs.go @@ -248,11 +248,16 @@ func _dnsExchange(proxy *Proxy, proto string, query *dns.Msg, serverAddress stri if err != nil { return nil, 0, err } + upstreamAddr := tcpAddr + if relayUDPAddr != nil { + proxy.prepareForRelay(tcpAddr.IP, tcpAddr.Port, &binQuery) + upstreamAddr = relayTCPAddr + } now := time.Now() var pc net.Conn proxyDialer := proxy.xTransport.proxyDialer if proxyDialer == nil { - pc, err = net.DialTCP("tcp", nil, tcpAddr) + pc, err = net.DialTCP("tcp", nil, upstreamAddr) } else { pc, err = (*proxyDialer).Dial("tcp", tcpAddr.String()) } diff --git a/dnscrypt-proxy/proxy.go b/dnscrypt-proxy/proxy.go index a447455c..43df95f2 100644 --- a/dnscrypt-proxy/proxy.go +++ b/dnscrypt-proxy/proxy.go @@ -325,7 +325,7 @@ func (proxy *Proxy) exchangeWithTCPServer(serverInfo *ServerInfo, sharedKey *[32 if proxyDialer == nil { pc, err = net.DialTCP("tcp", nil, upstreamAddr) } else { - pc, err = (*proxyDialer).Dial("tcp", upstreamAddr.String()) + pc, err = (*proxyDialer).Dial("tcp", serverInfo.TCPAddr.String()) } if err != nil { return nil, err