client.go 880 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dns
  2. import (
  3. "v2ray.com/core/common/net"
  4. "v2ray.com/core/features"
  5. )
  6. // Client is a V2Ray feature for querying DNS information.
  7. type Client interface {
  8. features.Feature
  9. LookupIP(host string) ([]net.IP, error)
  10. }
  11. // ClientType returns the type of Client interface. Can be used for implementing common.HasType.
  12. func ClientType() interface{} {
  13. return (*Client)(nil)
  14. }
  15. // LocalClient is an implementation of Client, which queries localhost for DNS.
  16. type LocalClient struct{}
  17. // Type implements common.HasType.
  18. func (LocalClient) Type() interface{} {
  19. return ClientType()
  20. }
  21. // Start implements common.Runnable.
  22. func (LocalClient) Start() error { return nil }
  23. // Close implements common.Closable.
  24. func (LocalClient) Close() error { return nil }
  25. // LookupIP implements Client.
  26. func (LocalClient) LookupIP(host string) ([]net.IP, error) {
  27. return net.LookupIP(host)
  28. }