watcher: follow a watched name's CNAME for port and TLS checks (closes #203)
check / check (push) Canceled after 0s

When a watched name's nameservers answer with a CNAME and no address,
the DNS check follows every target they gave with ResolveIPAddresses
and saves all addresses found as cnameAddresses in the hostname state,
so nameservers disagreeing on the target do not change them between
checks. Port and TLS checks use them. A change, also from or to none,
is notified as a CNAME address change; the first check from a state
file without them sends none. When a target cannot be followed, or
none of the name's nameservers answered, the last check's addresses
are kept. The domain check now runs the hostname check for the apex
instead of a copy of it.

Model: opus-5-5
This commit was merged in pull request #209.
This commit is contained in:
2026-10-02 08:26:27 +02:00
parent a18803ff28
commit ee4cadbd05
8 changed files with 627 additions and 32 deletions
+11 -2
View File
@@ -312,7 +312,8 @@ func lookupNameservers(t *testing.T, name string) []string {
return nameservers
}
// addresses returns the A and AAAA values saved for a hostname.
// addresses returns the A and AAAA values saved for a hostname, and the
// addresses saved at the end of its CNAME chain.
func addresses(hs *state.HostnameState) []string {
var ips []string
@@ -321,7 +322,7 @@ func addresses(hs *state.HostnameState) []string {
ips = append(ips, nsState.Records["AAAA"]...)
}
return ips
return append(ips, hs.CNAMEAddresses...)
}
// assertNotified checks that a notification with this title and
@@ -371,6 +372,14 @@ func TestFirstRunBaseline(t *testing.T) {
assertNoNotifications(t, deps)
assertStatePopulated(t, deps)
// testHost answers with an address, so the check saves an empty list
// of CNAME addresses for it; nil would mean the check did not look
// at whether to follow a CNAME.
hs, _ := deps.state.GetHostnameState(testHost)
if hs.CNAMEAddresses == nil || len(hs.CNAMEAddresses) != 0 {
t.Errorf("saved CNAME addresses %#v, want []", hs.CNAMEAddresses)
}
}
func assertNoNotifications(