Files
free-turn-proxy-orig/client/internal/dnsdial/cli.go
T
samosvalishe 4e5690cd04 feat: перенести DoH-резолвер, добавить флаг -dns
Заменяет bschaatsbergen/dnsdialer (только UDP) на внутренний пакет dnsdial.
Добавляет поддержку DNS-over-HTTPS и режим auto (проба UDP/53 → залипающий
fallback на DoH при сбое).

Новый флаг: -dns udp|doh|auto (по умолчанию: auto)
2026-05-11 23:46:27 +03:00

35 lines
848 B
Go

package dnsdial
import (
"net"
"sync"
)
var (
dohResolverOnce sync.Once
dohResolverInstance *DohResolver
)
func sharedDohResolver() *DohResolver {
dohResolverOnce.Do(func() {
dohResolverInstance = NewDohResolver(nil)
})
return dohResolverInstance
}
// AppDialer returns the net.Dialer used by tls-client and other HTTP callers.
// DNS transport is selected by mode (udp | doh | auto).
func AppDialer(mode string) net.Dialer {
return buildDialer(mode, sharedDohResolver())
}
// InstallGlobalResolver wires net.DefaultResolver to the same DNS transport
// as AppDialer, so third-party libs that build their own http.Client without
// our Dialer still use DoH / auto-fallback instead of the OS resolver.
func InstallGlobalResolver(mode string) {
d := AppDialer(mode)
if d.Resolver != nil {
net.DefaultResolver = d.Resolver
}
}