use custom CA pool for DoH

This commit is contained in:
Vladislav Yarmak
2026-01-08 22:53:27 +02:00
parent bef4ab7784
commit cb499db379
+14 -1
View File
@@ -5,8 +5,10 @@ import (
"crypto/x509" "crypto/x509"
"errors" "errors"
"net" "net"
"net/http"
"net/url" "net/url"
"strings" "strings"
"time"
"github.com/ncruces/go-dns" "github.com/ncruces/go-dns"
) )
@@ -50,7 +52,18 @@ begin:
parsed.Scheme = "https" parsed.Scheme = "https"
u = parsed.String() u = parsed.String()
} }
return dns.NewDoHResolver(u, dns.DoHAddresses(net.JoinHostPort(host, port))) return dns.NewDoHResolver(u,
dns.DoHAddresses(net.JoinHostPort(host, port)),
dns.DoHTransport(&http.Transport{
MaxIdleConns: http.DefaultMaxIdleConnsPerHost,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ForceAttemptHTTP2: true,
TLSClientConfig: &tls.Config{
RootCAs: caPool,
},
}),
)
case "tls", "dot": case "tls", "dot":
if port == "" { if port == "" {
port = "853" port = "853"