mirror of
https://github.com/golang/go
synced 2024-11-22 21:50:03 -07:00
fixes
Change-Id: Iddb64848b66578cb68bfa1f724f5b56bfe903316
This commit is contained in:
parent
e9b536d095
commit
7e8ec44078
@ -501,7 +501,7 @@ func (conf *dnsConfig) nameList(name string) []string {
|
||||
// Build list of search choices.
|
||||
names := make([]string, 0, 1+len(conf.search))
|
||||
// If name has enough dots, try unsuffixed first.
|
||||
if !avoidDNS(name) && hasNdots {
|
||||
if hasNdots && !avoidDNS(name) {
|
||||
names = append(names, name)
|
||||
}
|
||||
// Try suffixes that are not too long (see isDomainName).
|
||||
@ -512,7 +512,7 @@ func (conf *dnsConfig) nameList(name string) []string {
|
||||
}
|
||||
}
|
||||
// Try unsuffixed, if not tried first above.
|
||||
if !avoidDNS(name) && !hasNdots {
|
||||
if !hasNdots && !avoidDNS(name) {
|
||||
names = append(names, name)
|
||||
}
|
||||
return names
|
||||
|
@ -16,14 +16,13 @@ import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"slices"
|
||||
|
||||
"golang.org/x/net/dns/dnsmessage"
|
||||
)
|
||||
|
||||
@ -197,12 +196,12 @@ func TestNameListAvoidDNS(t *testing.T) {
|
||||
c := &dnsConfig{search: []string{"go.dev.", "onion."}}
|
||||
got := c.nameList("www")
|
||||
if !slices.Equal(got, []string{"www.", "www.go.dev."}) {
|
||||
t.Fatalf("nameList(\"www\") = %v, want \"www\", \"www.go.dev\"", got)
|
||||
t.Fatalf(`nameList("www") = %v, want "www.", "www.go.dev."`, got)
|
||||
}
|
||||
|
||||
got = c.nameList("www.onion")
|
||||
if !slices.Equal(got, []string{"www.onion.go.dev."}) {
|
||||
t.Fatalf("nameList(\"www.onion\") = %v, want \"www.onion.go.dev\"", got)
|
||||
t.Fatalf(`nameList("www.onion") = %v, want "www.onion.go.dev."`, got)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user