Skip to content

Commit

Permalink
fix(ddns): handle second-level domain correctly (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb authored Oct 18, 2024
1 parent be7b6e9 commit fc9f1b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/ddns/ddns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/ddns/ddns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit fc9f1b6

Please sign in to comment.