mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 20:04:02 +03:00
fix ipv6 doh-ip
This commit is contained in:
+11
-2
@@ -1,6 +1,8 @@
|
|||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -83,8 +85,13 @@ func (d *dnsResolver) LookupAAAA(hostname string) []string {
|
|||||||
return ips
|
return ips
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDNSResolver(hostname string, httpClient *http.Client) *dnsResolver {
|
func newDNSResolver(hostname string, httpClient *http.Client) (ret *dnsResolver) {
|
||||||
return &dnsResolver{
|
if net.ParseIP(hostname).To4() == nil {
|
||||||
|
// the hostname is an IPv6 address
|
||||||
|
hostname = fmt.Sprintf("[%s]", hostname)
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = &dnsResolver{
|
||||||
resolver: doh.Resolver{
|
resolver: doh.Resolver{
|
||||||
Host: hostname,
|
Host: hostname,
|
||||||
Class: doh.IN,
|
Class: doh.IN,
|
||||||
@@ -92,4 +99,6 @@ func newDNSResolver(hostname string, httpClient *http.Client) *dnsResolver {
|
|||||||
},
|
},
|
||||||
cache: map[string]dnsResolverCacheEntry{},
|
cache: map[string]dnsResolverCacheEntry{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user