The zones list shows a padlock after signed zones, linking to their DNSSEC tab. Client lists in the statistics show the host name Jarl's records have for each address (PTR, else A/AAAA); no DNS queries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.6 KiB
Go
39 lines
1.6 KiB
Go
package server
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
|
|
"jarl/internal/model"
|
|
)
|
|
|
|
func TestClientNames(t *testing.T) {
|
|
st := model.NewState()
|
|
add := func(id int64, name, typ, data string, disabled bool) {
|
|
st.Records[id] = &model.Record{ID: id, ZoneID: 1, Name: name, Type: typ, Data: data, Disabled: disabled}
|
|
}
|
|
add(1, "nas.adbraun.lol.", "A", "192.168.1.20", false)
|
|
add(2, "20.1.168.192.in-addr.arpa.", "PTR", "storage.adbraun.lol.", false) // PTR wins over A
|
|
add(3, "web.adbraun.lol.", "A", "192.168.1.30", false) // no PTR: the A record's name
|
|
add(4, "alias.adbraun.lol.", "A", "192.168.1.30", false) // first in name order wins
|
|
add(5, "old.adbraun.lol.", "A", "192.168.1.40", true) // disabled: ignored
|
|
add(6, "secret.adbraun.lol.", "A", "192.168.1.50", false) // not readable
|
|
add(7, "v6.adbraun.lol.", "AAAA", "2001:db8::7", false)
|
|
add(8, "printer.adbraun.lol.", "A", "192.168.1.60", false) // not asked for
|
|
|
|
want := map[netip.Addr]bool{}
|
|
for _, a := range []string{"192.168.1.20", "192.168.1.30", "192.168.1.40", "192.168.1.50", "2001:db8::7", "10.0.0.1"} {
|
|
want[netip.MustParseAddr(a)] = true
|
|
}
|
|
got := clientNames(st, want, func(r *model.Record) bool { return r.ID != 6 })
|
|
exp := map[string]string{"192.168.1.20": "storage.adbraun.lol", "192.168.1.30": "alias.adbraun.lol", "2001:db8::7": "v6.adbraun.lol"}
|
|
if len(got) != len(exp) {
|
|
t.Errorf("got %v", got)
|
|
}
|
|
for a, n := range exp {
|
|
if got[netip.MustParseAddr(a)] != n {
|
|
t.Errorf("%s = %q, want %q", a, got[netip.MustParseAddr(a)], n)
|
|
}
|
|
}
|
|
}
|