mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
use default dns resolver to prevent errors in android
This commit is contained in:
parent
82d562d1f0
commit
4104a86b6c
@ -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 {
|
type Client struct{}
|
||||||
resolver net.Resolver
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) {
|
func (*Client) LookupIP(host string) ([]net.IP, error) {
|
||||||
ipAddr, err := c.resolver.LookupIPAddr(context.Background(), host)
|
return net.LookupIP(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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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{
|
return &Client{}
|
||||||
resolver: net.Resolver{
|
|
||||||
PreferGo: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user