mirror of
https://github.com/fumiama/terasu.git
synced 2026-06-05 01:00:23 +08:00
feat: drop ipv6 test due to server down
This commit is contained in:
@@ -16,7 +16,7 @@ func LookupHost(ctx context.Context, host string) (addrs []string, err error) {
|
||||
if len(addrs) == 0 {
|
||||
addrs, err = DefaultResolver.LookupHost(ctx, host)
|
||||
if err != nil {
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
addrs, err = IPv6Servers.lookupHostDoH(ctx, host)
|
||||
} else {
|
||||
addrs, err = IPv4Servers.lookupHostDoH(ctx, host)
|
||||
|
||||
@@ -273,7 +273,7 @@ var IPv4Servers = DNSList{
|
||||
var DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, nw, _ string) (net.Conn, error) {
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
return IPv6Servers.DialContext(ctx, nil, terasu.DefaultFirstFragmentLen)
|
||||
}
|
||||
return IPv4Servers.DialContext(ctx, nil, terasu.DefaultFirstFragmentLen)
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestResolver(t *testing.T) {
|
||||
t.Log("IsIPv6Available:", ip.IsIPv6Available.Get())
|
||||
t.Log("IsIPv6Available:", ip.IsIPv6Available)
|
||||
addrs, err := DefaultResolver.LookupHost(context.TODO(), "huggingface.co")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -25,9 +25,9 @@ func TestResolver(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResolverFallback(t *testing.T) {
|
||||
t.Log("IsIPv6Available:", ip.IsIPv6Available.Get())
|
||||
t.Log("IsIPv6Available:", ip.IsIPv6Available)
|
||||
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
addrs, err := IPv6Servers.lookupHostDoH(context.TODO(), "huggingface.co")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -48,7 +48,7 @@ func TestResolverFallback(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDNS(t *testing.T) {
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
IPv6Servers.test()
|
||||
}
|
||||
IPv4Servers.test()
|
||||
@@ -76,7 +76,7 @@ func TestBadDNS(t *testing.T) {
|
||||
IPv6Servers.m = dotv6serversbak
|
||||
IPv4Servers.m = dotv4serversbak
|
||||
}()
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
IPv6Servers = DNSList{
|
||||
m: map[string][]*dnsstat{},
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ func lookupdoh(ctx context.Context, server, u string) (jr dohjsonresponse, err e
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
jr, err = lookupdohwithtype(ctx, server, u, recordTypeA)
|
||||
}
|
||||
return
|
||||
@@ -157,7 +157,7 @@ func lookupdohwithtype(ctx context.Context, server, u string, typ recordType) (j
|
||||
}
|
||||
|
||||
func preferreddohtype() recordType {
|
||||
if ip.IsIPv6Available.Get() {
|
||||
if ip.IsIPv6Available {
|
||||
return recordTypeAAAA
|
||||
}
|
||||
return recordTypeA
|
||||
|
||||
Reference in New Issue
Block a user