-
-
Notifications
You must be signed in to change notification settings - Fork 520
/
Copy pathdns.go
51 lines (40 loc) · 786 Bytes
/
dns.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
48
49
50
51
package main
import (
"context"
"fmt"
"net"
"time"
)
func main() {
ns, err := net.LookupNS("google.com")
if err != nil {
panic(err)
}
fmt.Printf("%s\n", ns)
ips, err := net.LookupIP("google.com")
if err != nil {
panic(err)
}
fmt.Println(ips)
mx, err := net.LookupMX("google.com")
if err != nil {
panic(err)
}
fmt.Println(mx)
txt, err := net.LookupTXT("google.com")
if err != nil {
panic(err)
}
fmt.Println(txt)
r := &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
d := net.Dialer{
Timeout: time.Millisecond * time.Duration(10_000),
}
return d.DialContext(ctx, "udp", "1.1.1.1:53")
},
}
ns, _ = r.LookupNS(context.Background(), "google.com")
fmt.Printf("%s", ns)
}