1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 01:40:44 +00:00
v2fly/features/dns/client.go

37 lines
880 B
Go
Raw Normal View History

2018-10-11 20:34:31 +00:00
package dns
import (
2018-10-11 21:09:15 +00:00
"v2ray.com/core/common/net"
2018-10-11 20:34:31 +00:00
"v2ray.com/core/features"
)
// Client is a V2Ray feature for querying DNS information.
type Client interface {
features.Feature
LookupIP(host string) ([]net.IP, error)
}
2018-10-12 21:57:56 +00:00
2018-10-13 10:09:58 +00:00
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
2018-10-12 21:57:56 +00:00
func ClientType() interface{} {
return (*Client)(nil)
}
2018-10-21 08:27:13 +00:00
2018-10-22 06:42:10 +00:00
// LocalClient is an implementation of Client, which queries localhost for DNS.
2018-10-21 08:27:13 +00:00
type LocalClient struct{}
2018-10-22 06:42:10 +00:00
// Type implements common.HasType.
2018-10-21 08:27:13 +00:00
func (LocalClient) Type() interface{} {
return ClientType()
}
2018-10-22 06:42:10 +00:00
// Start implements common.Runnable.
2018-10-21 08:27:13 +00:00
func (LocalClient) Start() error { return nil }
2018-10-22 06:42:10 +00:00
// Close implements common.Closable.
2018-10-21 08:27:13 +00:00
func (LocalClient) Close() error { return nil }
2018-10-22 06:42:10 +00:00
// LookupIP implements Client.
2018-10-21 08:27:13 +00:00
func (LocalClient) LookupIP(host string) ([]net.IP, error) {
return net.LookupIP(host)
}