1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-29 15:26:29 -04:00
v2fly/features/dns/client.go

37 lines
880 B
Go
Raw Normal View History

2018-10-11 16:34:31 -04:00
package dns
import (
2018-10-11 17:09:15 -04:00
"v2ray.com/core/common/net"
2018-10-11 16:34:31 -04: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 17:57:56 -04:00
2018-10-13 06:09:58 -04:00
// ClientType returns the type of Client interface. Can be used for implementing common.HasType.
2018-10-12 17:57:56 -04:00
func ClientType() interface{} {
return (*Client)(nil)
}
2018-10-21 04:27:13 -04:00
2018-10-22 02:42:10 -04:00
// LocalClient is an implementation of Client, which queries localhost for DNS.
2018-10-21 04:27:13 -04:00
type LocalClient struct{}
2018-10-22 02:42:10 -04:00
// Type implements common.HasType.
2018-10-21 04:27:13 -04:00
func (LocalClient) Type() interface{} {
return ClientType()
}
2018-10-22 02:42:10 -04:00
// Start implements common.Runnable.
2018-10-21 04:27:13 -04:00
func (LocalClient) Start() error { return nil }
2018-10-22 02:42:10 -04:00
// Close implements common.Closable.
2018-10-21 04:27:13 -04:00
func (LocalClient) Close() error { return nil }
2018-10-22 02:42:10 -04:00
// LookupIP implements Client.
2018-10-21 04:27:13 -04:00
func (LocalClient) LookupIP(host string) ([]net.IP, error) {
return net.LookupIP(host)
}