nameserver_local_test.go 610 B

123456789101112131415161718192021222324252627
  1. package dns_test
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/xtls/xray-core/app/dns"
  7. "github.com/xtls/xray-core/common"
  8. "github.com/xtls/xray-core/common/net"
  9. "github.com/xtls/xray-core/features/dns"
  10. )
  11. func TestLocalNameServer(t *testing.T) {
  12. s := NewLocalNameServer(QueryStrategy_USE_IP)
  13. ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
  14. ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{
  15. IPv4Enable: true,
  16. IPv6Enable: true,
  17. FakeEnable: false,
  18. }, false)
  19. cancel()
  20. common.Must(err)
  21. if len(ips) == 0 {
  22. t.Error("expect some ips, but got 0")
  23. }
  24. }