@@ -0,0 +1,41 @@
1+// Package dns configures Go's DNS resolver for Termux/Android where
2+// Go's pure-Go resolver reads /etc/resolv.conf which points to
3+// non-functional loopback nameservers.
4+// The package uses runtime detection — no build tags required.
14+ if os.Getenv("TERMUX_VERSION") == "" {
18+ net.DefaultResolver = &net.Resolver{
20+ Dial: dialWithFallback([]string{"8.8.8.8:53", "1.1.1.1:53"}),
24+// dialWithFallback returns a resolver Dial func that tries each
25+// nameserver in order, falling through on failure.
26+func dialWithFallback(nameservers []string) func(context.Context, string, string) (net.Conn, error) {
27+ return func(ctx context.Context, network, _ string) (net.Conn, error) {
32+ for _, ns := range nameservers {
33+ conn, err := d.DialContext(ctx, network, ns)