fix(dns): skip wildcard templates in reverse lookup

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-04 03:17:07 +00:00
parent 833db1974d
commit 95663717f4
2 changed files with 25 additions and 0 deletions

View file

@ -1359,6 +1359,10 @@ func collectReverseName(namesByIP *cache.Cache, name string, ips []string, expir
return
}
if strings.HasPrefix(normalizeName(name), "*.") {
return
}
for _, ip := range ips {
normalized := normalizeIP(ip)
if normalized == "" {

View file

@ -396,6 +396,27 @@ func TestServiceResolveReverseNamesReturnsNamedField(t *testing.T) {
}
}
func TestServiceResolveReverseIgnoresWildcardTemplateNames(t *testing.T) {
service := NewService(ServiceOptions{
Records: map[string]NameRecords{
"*.charon.lthn": {
A: []string{"10.10.10.10"},
},
"gateway.charon.lthn": {
A: []string{"10.10.10.10"},
},
},
})
names, ok := service.ResolveReverse("10.10.10.10")
if !ok {
t.Fatal("expected reverse lookup to resolve")
}
if len(names) != 1 || names[0] != "gateway.charon.lthn" {
t.Fatalf("expected reverse lookup to omit wildcard names, got %#v", names)
}
}
func TestServiceResolvePTRAliasesMatchReverseLookup(t *testing.T) {
service := NewService(ServiceOptions{
Records: map[string]NameRecords{