Stream the delegation check's queries too
release / release (push) Successful in 1m42s

Every DNS query the name server checks send is now reported from
exchangeHostPort as a dig command line with a short answer (addresses,
referral, DS, NXDOMAIN) and its round-trip time; the serials check's SOA
queries keep their own events with the server's result. The delegation
check streams with ?stream=1 like /serials, and the Name servers tab
shows its queries as they happen, keeps its result and follows a running
check when you come back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adamandClaude Opus 5.5 committed 2026-10-09 16:00:39 +00:00
1 parent 1d6c28ba69
commit bb6b4ab64d
6 files changed
+334 -128

No files matched your search

+62
View File
@@ -6,6 +6,7 @@ import (
"net/netip"
"strconv"
"strings"
"sync"
"testing"
"time"
@@ -307,3 +308,64 @@ func TestDelegationDS(t *testing.T) {
}
}
}
// TestWatch: with Watch set, every query is reported as it starts and
// ends, as a dig command line with a summary of the answer.
func TestWatch(t *testing.T) {
port, res := internet(t, func(q dns.Question) *dns.Msg {
m := new(dns.Msg)
if q.Qtype == dns.TypeNS && q.Name == "adbraun.lol." {
m.Ns = []dns.RR{rr("adbraun.lol. 3600 IN NS ns1.adbraun.lol.")}
m.Extra = []dns.RR{rr("ns1.adbraun.lol. 3600 IN A 127.0.0.12")}
}
return m
})
var mu sync.Mutex
var events []Event
c := checker(port, res)
c.Watch = func(e Event) {
mu.Lock()
events = append(events, e)
mu.Unlock()
}
ref := uint32(7)
c.Delegation(context.Background(), "adbraun.lol.", []string{"ns1.adbraun.lol."}, map[string][]string{"ns1.adbraun.lol.": {"127.0.0.12"}}, &ref, nil)
open := map[int64]string{}
var queries, answers []string
for _, e := range events {
switch e.Kind {
case "start":
if !strings.HasPrefix(e.Query, "dig @") {
t.Errorf("query %q", e.Query)
}
open[e.ID] = e.Query
queries = append(queries, e.Query)
case "end":
q, ok := open[e.ID]
if !ok {
t.Errorf("end without start: %+v", e)
}
delete(open, e.ID)
a := e.Answer + e.Error
if e.Result != nil {
a = e.Result.Status
}
answers = append(answers, q+" => "+a)
}
}
if len(open) != 0 {
t.Errorf("never ended: %v", open)
}
all := strings.Join(answers, "\n")
for _, want := range []string{
" adbraun.lol. NS +norec => referral to ns1.adbraun.lol.", // asking a parent server
"@127.0.0.12 -p " + port + " adbraun.lol. SOA +norec => in_sync", // asking the delegated server
} {
if !strings.Contains(all, want) {
t.Errorf("no %q in\n%s", want, all)
}
}
if len(queries) < 4 {
t.Errorf("only %d queries:\n%s", len(queries), all)
}
}