|
|
@@ -1,6 +1,8 @@
|
|
1
|
1
|
package network
|
|
2
|
2
|
|
|
3
|
3
|
import (
|
|
|
4
|
+ "fmt"
|
|
|
5
|
+ "net"
|
|
4
|
6
|
"net/http"
|
|
5
|
7
|
"sync"
|
|
6
|
8
|
"time"
|
|
|
@@ -83,8 +85,13 @@ func (d *dnsResolver) LookupAAAA(hostname string) []string {
|
|
83
|
85
|
return ips
|
|
84
|
86
|
}
|
|
85
|
87
|
|
|
86
|
|
-func newDNSResolver(hostname string, httpClient *http.Client) *dnsResolver {
|
|
87
|
|
- return &dnsResolver{
|
|
|
88
|
+func newDNSResolver(hostname string, httpClient *http.Client) (ret *dnsResolver) {
|
|
|
89
|
+ if net.ParseIP(hostname).To4() == nil {
|
|
|
90
|
+ // the hostname is an IPv6 address
|
|
|
91
|
+ hostname = fmt.Sprintf("[%s]", hostname)
|
|
|
92
|
+ }
|
|
|
93
|
+
|
|
|
94
|
+ ret = &dnsResolver{
|
|
88
|
95
|
resolver: doh.Resolver{
|
|
89
|
96
|
Host: hostname,
|
|
90
|
97
|
Class: doh.IN,
|
|
|
@@ -92,4 +99,6 @@ func newDNSResolver(hostname string, httpClient *http.Client) *dnsResolver {
|
|
92
|
99
|
},
|
|
93
|
100
|
cache: map[string]dnsResolverCacheEntry{},
|
|
94
|
101
|
}
|
|
|
102
|
+
|
|
|
103
|
+ return
|
|
95
|
104
|
}
|