nameserver_quic_test.go 588 B

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