Force the root label to have 0 labels
This commit is contained in:
parent
b7004384f8
commit
827e4a476f
|
@ -13,12 +13,6 @@ things that need to be fixed.
|
|||
-edns NSID is another
|
||||
* Add tsig check in 'q'?
|
||||
|
||||
## BUGS
|
||||
|
||||
* ListenAndServe has trouble with v6:
|
||||
Failed to setup the udp6 server: listen udp6 <nil>:8053: address already in use
|
||||
Failed to setup the tcp6 server: listen tcp6 <nil>:8053: address already in use
|
||||
|
||||
## Examples to add
|
||||
|
||||
* Nameserver, with a small zone, 1 KSK and online signing;
|
||||
|
|
|
@ -27,8 +27,8 @@ func TestCompareLabels(t *testing.T) {
|
|||
t.Logf("%s with %s should be %d", s1, s5, 1)
|
||||
t.Fail()
|
||||
}
|
||||
if CompareLabels(".", ".") != 1 {
|
||||
t.Logf("%s with %s should be %d", ".", ".", 1)
|
||||
if CompareLabels(".", ".") != 0 {
|
||||
t.Logf("%s with %s should be %d", ".", ".", 0)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
@ -55,9 +55,8 @@ func TestSplitLabels(t *testing.T) {
|
|||
t.Logf("Labels should be 3, %s\n", s4)
|
||||
t.Fail()
|
||||
}
|
||||
// Should this be 1 or 0...
|
||||
if len(SplitLabels(".")) != 1 {
|
||||
t.Logf("Labels should be 1, %s\n", ".")
|
||||
if len(SplitLabels(".")) != 0 {
|
||||
t.Logf("Labels should be 0, %s\n", ".")
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,12 @@ package dns
|
|||
|
||||
// SplitLabels splits a domainname string into its labels.
|
||||
// www.miek.nl. returns []string{"www", "miek", "nl"}
|
||||
// . returns []string{"."}
|
||||
// The root label (.) returns nil
|
||||
func SplitLabels(s string) []string {
|
||||
if (s == ".") {
|
||||
return nil
|
||||
}
|
||||
|
||||
k := 0
|
||||
labels := make([]string, 0)
|
||||
last := byte('.')
|
||||
|
@ -34,9 +38,6 @@ func SplitLabels(s string) []string {
|
|||
//
|
||||
// www.miek.nl. and miek.nl. have two labels in common: miek and nl
|
||||
// www.miek.nl. and www.bla.nl. have one label in common: nl
|
||||
// Be aware of these corner cases:
|
||||
// . and . have one label in common
|
||||
// . and "" (empty) have one label in common
|
||||
func CompareLabels(s1, s2 string) (n int) {
|
||||
l1 := SplitLabels(s1)
|
||||
l2 := SplitLabels(s2)
|
||||
|
|
Loading…
Reference in New Issue