nameserver_local_test.go 536 B

1234567891011121314151617181920212223242526
  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/features/dns"
  9. )
  10. func TestLocalNameServer(t *testing.T) {
  11. s := NewLocalNameServer()
  12. ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
  13. ips, _, err := s.QueryIP(ctx, "google.com", dns.IPOption{
  14. IPv4Enable: true,
  15. IPv6Enable: true,
  16. FakeEnable: false,
  17. })
  18. cancel()
  19. common.Must(err)
  20. if len(ips) == 0 {
  21. t.Error("expect some ips, but got 0")
  22. }
  23. }