github.com/v2fly/v2ray-core/v4@v4.45.2/transport/internet/system_dns_android.go (about)

     1  //go:build android
     2  // +build android
     3  
     4  package internet
     5  
     6  import (
     7  	"context"
     8  	"net"
     9  )
    10  
    11  const SystemDNS = "8.8.8.8:53"
    12  
    13  /* DNSResolverFunc
    14     This is a temporary API and is subject to removal at any time.
    15  */
    16  type DNSResolverFunc func() *net.Resolver
    17  
    18  /* NewDNSResolver
    19     This is a temporary API and is subject to removal at any time.
    20  */
    21  var NewDNSResolver DNSResolverFunc = func() *net.Resolver {
    22  	return &net.Resolver{
    23  		PreferGo: true,
    24  		Dial: func(ctx context.Context, network, _ string) (net.Conn, error) {
    25  			var dialer net.Dialer
    26  			return dialer.DialContext(ctx, network, SystemDNS)
    27  		},
    28  	}
    29  }
    30  
    31  func init() {
    32  	net.DefaultResolver = NewDNSResolver()
    33  }