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