Keep a name that became static when Unbound restarts
The names of DHCP clients are removed from a new Unbound by name, which also removed the record the configuration now publishes under it (a client name that became a reservation). Forget what an earlier Unbound had instead.
This commit is contained in:
@@ -150,6 +150,28 @@ func TestSyncDynamic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A client name that became a DHCP reservation: the restart that brought the
|
||||
// reservation must not remove the configuration's record by removing what an
|
||||
// earlier Unbound was given.
|
||||
func TestNewUnboundForgetsWhatTheOldOneHad(t *testing.T) {
|
||||
hv1 := DynRecord{Name: "hv1.home.example.org", Address: "192.168.1.21"}
|
||||
old := map[string]DynRecord{hv1.Name: hv1}
|
||||
if got := stillThere(old, "100", "200"); len(got) != 0 {
|
||||
t.Errorf("a new Unbound still has %v", got)
|
||||
}
|
||||
if got := stillThere(old, "", "200"); len(got) != 0 {
|
||||
t.Errorf("an unknown Unbound still has %v", got)
|
||||
}
|
||||
if got := stillThere(old, "200", "200"); len(got) != 1 {
|
||||
t.Errorf("the same Unbound lost %v", got)
|
||||
}
|
||||
// So the fresh sync sends nothing for it: the static record stays.
|
||||
ctl := &fakeCtl{}
|
||||
if _, err := syncDynamic(ctl, stillThere(old, "100", "200"), nil, true); err != nil || len(ctl.cmds) != 0 {
|
||||
t.Errorf("removed after a restart: %v %v", ctl.cmds, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseUnboundPID(t *testing.T) {
|
||||
out := "version: 1.26.1\nverbosity: 1\nthreads: 1\nuptime: 0 seconds\nunbound (pid 1458081) is running...\n"
|
||||
if pid, err := parseUnboundPID(out); err != nil || pid != "1458081" {
|
||||
|
||||
Reference in New Issue
Block a user