diff --git a/dnscrypt-proxy/main.go b/dnscrypt-proxy/main.go index 55adda39..33cb7636 100644 --- a/dnscrypt-proxy/main.go +++ b/dnscrypt-proxy/main.go @@ -17,16 +17,17 @@ type Proxy struct { questionSizeEstimator QuestionSizeEstimator serversInfo ServersInfo timeout time.Duration + mainProto string } func main() { log.SetFlags(0) stamp, _ := NewServerStampFromLegacy("212.47.228.136:443", "E801:B84E:A606:BFB0:BAC0:CE43:445B:B15E:BA64:B02F:A3C4:AA31:AE10:636A:0790:324D", "2.dnscrypt-cert.fr.dnscrypt.org") - NewProxy("127.0.0.1:5399", "dnscrypt.org-fr", stamp) + NewProxy("127.0.0.1:5399", "dnscrypt.org-fr", stamp, "udp") } -func NewProxy(listenAddrStr string, serverName string, stamp ServerStamp) { - proxy := Proxy{questionSizeEstimator: NewQuestionSizeEstimator(), timeout: TimeoutMax} +func NewProxy(listenAddrStr string, serverName string, stamp ServerStamp, mainProto string) { + proxy := Proxy{questionSizeEstimator: NewQuestionSizeEstimator(), timeout: TimeoutMax, mainProto: mainProto} if _, err := rand.Read(proxy.proxySecretKey[:]); err != nil { log.Fatal(err) } diff --git a/dnscrypt-proxy/serversInfo.go b/dnscrypt-proxy/serversInfo.go index b3089ba7..f6c6a369 100644 --- a/dnscrypt-proxy/serversInfo.go +++ b/dnscrypt-proxy/serversInfo.go @@ -89,12 +89,9 @@ func (serversInfo *ServersInfo) fetchServerInfo(proxy *Proxy, name string, stamp if err != nil || len(serverPk) != ed25519.PublicKeySize { log.Fatal("Invalid public key") } - certInfo, err := FetchCurrentCert(proxy, "udp", serverPk, stamp.serverAddrStr, stamp.providerName) + certInfo, err := FetchCurrentCert(proxy, proxy.mainProto, serverPk, stamp.serverAddrStr, stamp.providerName) if err != nil { - certInfo, err = FetchCurrentCert(proxy, "tcp", serverPk, stamp.serverAddrStr, stamp.providerName) - if err != nil { - return ServerInfo{}, err - } + return ServerInfo{}, err } remoteUDPAddr, err := net.ResolveUDPAddr("udp", stamp.serverAddrStr) if err != nil {