Fix remaining zone.Remove* functions
Fix the remove function and make them more like zone.Remove()
This commit is contained in:
parent
6cb4f9cf69
commit
9a80799666
|
@ -182,6 +182,11 @@ z2.miek.nl. IN NSEC miek.nl. TXT RRSIG NSEC`
|
|||
t.Log("Not all names correct")
|
||||
t.Fail()
|
||||
}
|
||||
z.RemoveName("z2.miek.nl.")
|
||||
if z.sortedNames[0] != "z1.miek.nl." || z.sortedNames[1] != "z3.miek.nl." {
|
||||
t.Logf("Not all names correct %v\n", z.sortedNames)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
||||
|
||||
func TestDomainName(t *testing.T) {
|
||||
|
|
7
zone.go
7
zone.go
|
@ -284,6 +284,13 @@ func (z *Zone) RemoveName(s string) error {
|
|||
z.ModTime = time.Now().UTC()
|
||||
defer z.Unlock()
|
||||
delete(z.Names, s)
|
||||
i := sort.SearchStrings(z.sortedNames, s)
|
||||
if z.sortedNames[i] == s {
|
||||
copy(z.sortedNames[i:], z.sortedNames[i+1:])
|
||||
z.sortedNames[len(z.sortedNames)-1] = ""
|
||||
z.sortedNames = z.sortedNames[:len(z.sortedNames)-1]
|
||||
}
|
||||
|
||||
if len(s) > 1 && s[0] == '*' && s[1] == '.' {
|
||||
z.Wildcard--
|
||||
if z.Wildcard < 0 {
|
||||
|
|
Loading…
Reference in New Issue