From 4104a86b6c4af65fdd4e318829d6e48e1f4e07d0 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Wed, 5 Dec 2018 15:48:40 +0100 Subject: [PATCH] use default dns resolver to prevent errors in android --- features/dns/localdns/client.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/features/dns/localdns/client.go b/features/dns/localdns/client.go index ed486bf7..fcd955bb 100644 --- a/features/dns/localdns/client.go +++ b/features/dns/localdns/client.go @@ -1,16 +1,12 @@ package localdns import ( - "context" - "v2ray.com/core/common/net" "v2ray.com/core/features/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. func (*Client) Type() interface{} { @@ -24,16 +20,8 @@ func (*Client) Start() error { return nil } func (*Client) Close() error { return nil } // 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. @@ -70,9 +58,5 @@ func (c *Client) LookupIPv6(host string) ([]net.IP, error) { // New create a new dns.Client that queries localhost for DNS. func New() *Client { - return &Client{ - resolver: net.Resolver{ - PreferGo: true, - }, - } + return &Client{} }