-
Notifications
You must be signed in to change notification settings - Fork 28
/
transport_test.go
47 lines (43 loc) · 1.17 KB
/
transport_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package dns_test
import (
"context"
"testing"
"github.com/sagernet/sing-dns"
_ "github.com/sagernet/sing-dns/quic"
"github.com/sagernet/sing/common/logger"
N "github.com/sagernet/sing/common/network"
"github.com/stretchr/testify/require"
)
func TestTransports(t *testing.T) {
t.Parallel()
serverAddressList := []string{
"114.114.114.114",
"tcp://114.114.114.114",
"tls://223.5.5.5",
"https://223.5.5.5/dns-query",
"quic://dns.alidns.com",
"h3://dns.alidns.com/dns-query",
}
for _, serverAddressItem := range serverAddressList {
serverAddress := serverAddressItem
t.Run(serverAddress, func(t *testing.T) {
t.Parallel()
transport, err := dns.CreateTransport(dns.TransportOptions{
Context: context.Background(),
Logger: logger.NOP(),
Address: serverAddress,
Dialer: N.SystemDialer,
})
require.NoError(t, err)
require.NotNil(t, transport)
client := dns.NewClient(dns.ClientOptions{
Logger: logger.NOP(),
})
addresses, err := client.Lookup(context.Background(), transport, "cloudflare.com", dns.QueryOptions{
Strategy: dns.DomainStrategyUseIPv4,
})
require.NoError(t, err)
require.NotEmpty(t, addresses)
})
}
}