Browse Source

use default dns resolver to prevent errors in android

Darien Raymond 7 years ago
parent
commit
4104a86b6c
1 changed files with 4 additions and 20 deletions
  1. 4 20
      features/dns/localdns/client.go

+ 4 - 20
features/dns/localdns/client.go

@@ -1,16 +1,12 @@
 package localdns
 package localdns
 
 
 import (
 import (
-	"context"
-
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/features/dns"
 	"v2ray.com/core/features/dns"
 )
 )
 
 
 // Client is an implementation of dns.Client, which queries localhost for DNS.
 // Client is an implementation of dns.Client, which queries localhost for DNS.
-type Client struct {
-	resolver net.Resolver
-}
+type Client struct{}
 
 
 // Type implements common.HasType.
 // Type implements common.HasType.
 func (*Client) Type() interface{} {
 func (*Client) Type() interface{} {
@@ -24,16 +20,8 @@ func (*Client) Start() error { return nil }
 func (*Client) Close() error { return nil }
 func (*Client) Close() error { return nil }
 
 
 // LookupIP implements Client.
 // LookupIP implements Client.
-func (c *Client) LookupIP(host string) ([]net.IP, error) {
-	ipAddr, err := c.resolver.LookupIPAddr(context.Background(), host)
-	if err != nil {
-		return nil, err
-	}
-	ips := make([]net.IP, 0, len(ipAddr))
-	for _, addr := range ipAddr {
-		ips = append(ips, addr.IP)
-	}
-	return ips, nil
+func (*Client) LookupIP(host string) ([]net.IP, error) {
+	return net.LookupIP(host)
 }
 }
 
 
 // LookupIPv4 implements IPv4Lookup.
 // LookupIPv4 implements IPv4Lookup.
@@ -70,9 +58,5 @@ func (c *Client) LookupIPv6(host string) ([]net.IP, error) {
 
 
 // New create a new dns.Client that queries localhost for DNS.
 // New create a new dns.Client that queries localhost for DNS.
 func New() *Client {
 func New() *Client {
-	return &Client{
-		resolver: net.Resolver{
-			PreferGo: true,
-		},
-	}
+	return &Client{}
 }
 }