forked from urnetwork/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnet_http_doh_test.go
More file actions
41 lines (33 loc) · 763 Bytes
/
net_http_doh_test.go
File metadata and controls
41 lines (33 loc) · 763 Bytes
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
package connect
import (
"context"
"fmt"
"net/netip"
"time"
"testing"
"github.com/go-playground/assert/v2"
)
func TestDohQuery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
settings := DefaultDohSettings()
testIp1, err := netip.ParseAddr("1.1.1.1")
assert.Equal(t, err, nil)
testIp2, err := netip.ParseAddr("10.10.10.10")
assert.Equal(t, err, nil)
for range 10 {
ips := DohQuery(ctx, 4, "A", settings, "test1.bringyour.com")
if len(ips) == 0 {
// timeout, try again
fmt.Printf("[doh]timeout. Will wait 1s and try again ...\n")
select {
case <-time.After(1 * time.Second):
continue
}
}
assert.Equal(t, ips, map[netip.Addr]bool{
testIp1: true,
testIp2: true,
})
}
}