fix(ddns): handle second-level domain correctly (#438)

This commit is contained in:
UUBulb 2024-10-18 12:26:43 +08:00 committed by GitHub
parent be7b6e9c5e
commit fc9f1b6bcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -108,7 +108,7 @@ func splitDomainSOA(domain string) (prefix string, zone string, err error) {
if len(r.Answer) > 0 {
if soa, ok := r.Answer[0].(*dns.SOA); ok {
zone = soa.Hdr.Name
prefix = domain[:len(domain)-len(zone)-1]
prefix = libdns.RelativeName(domain, zone)
return
}
}

View File

@ -27,6 +27,11 @@ func TestSplitDomainSOA(t *testing.T) {
zone: "example.com.",
prefix: "abc",
},
{
domain: "example.com",
zone: "example.com.",
prefix: "",
},
}
for _, c := range cases {