nameserver_quic_test.go 707 B

123456789101112131415161718192021222324252627282930
  1. package dns_test
  2. import (
  3. "context"
  4. "net/url"
  5. "testing"
  6. "time"
  7. . "github.com/v2fly/v2ray-core/v4/app/dns"
  8. "github.com/v2fly/v2ray-core/v4/common"
  9. "github.com/v2fly/v2ray-core/v4/common/net"
  10. dns_feature "github.com/v2fly/v2ray-core/v4/features/dns"
  11. )
  12. func TestQUICNameServer(t *testing.T) {
  13. url, err := url.Parse("quic://dns.adguard.com")
  14. common.Must(err)
  15. s, err := NewQUICNameServer(url)
  16. common.Must(err)
  17. ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
  18. ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{
  19. IPv4Enable: true,
  20. IPv6Enable: true,
  21. })
  22. cancel()
  23. common.Must(err)
  24. if len(ips) == 0 {
  25. t.Error("expect some ips, but got 0")
  26. }
  27. }