Use IsFqdn and Fqdn helper functions more (#892)
This commit is contained in:
parent
b9e1e7529b
commit
09499bd07f
|
@ -176,9 +176,7 @@ func IsDomainName(s string) (labels int, ok bool) {
|
||||||
return 0, false
|
return 0, false
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasSuffix(s, ".") {
|
s = Fqdn(s)
|
||||||
s += "."
|
|
||||||
}
|
|
||||||
|
|
||||||
// Each dot ends a segment of the name. Except for escaped dots (\.), which
|
// Each dot ends a segment of the name. Except for escaped dots (\.), which
|
||||||
// are normal dots.
|
// are normal dots.
|
||||||
|
|
|
@ -16,7 +16,7 @@ func SplitDomainName(s string) (labels []string) {
|
||||||
fqdnEnd := 0 // offset of the final '.' or the length of the name
|
fqdnEnd := 0 // offset of the final '.' or the length of the name
|
||||||
idx := Split(s)
|
idx := Split(s)
|
||||||
begin := 0
|
begin := 0
|
||||||
if s[len(s)-1] == '.' {
|
if IsFqdn(s) {
|
||||||
fqdnEnd = len(s) - 1
|
fqdnEnd = len(s) - 1
|
||||||
} else {
|
} else {
|
||||||
fqdnEnd = len(s)
|
fqdnEnd = len(s)
|
||||||
|
|
2
msg.go
2
msg.go
|
@ -244,7 +244,7 @@ func packDomainName(s string, msg []byte, off int, compression compressionMap, c
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not fully qualified, error out.
|
// If not fully qualified, error out.
|
||||||
if s[ls-1] != '.' {
|
if !IsFqdn(s) {
|
||||||
return len(msg), ErrFqdn
|
return len(msg), ErrFqdn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue