Skip to content

Commit fc9f1b6

Browse files
authored
fix(ddns): handle second-level domain correctly (#438)
1 parent be7b6e9 commit fc9f1b6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pkg/ddns/ddns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func splitDomainSOA(domain string) (prefix string, zone string, err error) {
108108
if len(r.Answer) > 0 {
109109
if soa, ok := r.Answer[0].(*dns.SOA); ok {
110110
zone = soa.Hdr.Name
111-
prefix = domain[:len(domain)-len(zone)-1]
111+
prefix = libdns.RelativeName(domain, zone)
112112
return
113113
}
114114
}

pkg/ddns/ddns_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ func TestSplitDomainSOA(t *testing.T) {
2727
zone: "example.com.",
2828
prefix: "abc",
2929
},
30+
{
31+
domain: "example.com",
32+
zone: "example.com.",
33+
prefix: "",
34+
},
3035
}
3136

3237
for _, c := range cases {

0 commit comments

Comments
 (0)