diff --git a/ChangeLog.md b/ChangeLog.md index 5a9bfae..f376ad9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -75,6 +75,8 @@ repository history](https://github.com/ddclient/ddclient/commits/master). [#667](https://github.com/ddclient/ddclient/pull/667) * Fixed unnecessary repeated updates for some services. [#670](https://github.com/ddclient/ddclient/pull/670) + * Fixed DNSExit provider when configured with a zone and non-identical + hostname. [#673](https://github.com/ddclient/ddclient/issues/673) ## 2023-11-23 v3.11.2 diff --git a/ddclient.in b/ddclient.in index f686da5..bcd1197 100755 --- a/ddclient.in +++ b/ddclient.in @@ -4140,6 +4140,8 @@ o 'dnsexit2' The 'dnsexit2' protocol is the updated protocol for the (free) dynamic hostname services of 'DNSExit' (www.dnsexit.com). Their API is accepting JSON payload. +Note that we only update the record, it must already exist in the DNSExit system +(A and/or AAAA records where applicable). Configuration variables applicable to the 'dnsexit2' protocol are: protocol=dnsexit2 ## @@ -4173,10 +4175,19 @@ EoEXAMPLE ###################################################################### sub nic_dnsexit2_update { debug("\nnic_dnsexit2_update -------------------"); - - # The DNSExit API does not support updating multiple hosts at a time. + # The DNSExit API does not support updating hosts with different zones at the same time, + # handling update per host. for my $h (@_) { $config{$h}{'zone'} //= $h; + my $name = $h; + # Remove the zone suffix from $name. If the zone eq $name, $name can be left alone or + # set to the empty string; both have identical semantics. For consistency, always + # remove the zone even if it means $name becomes the empty string. + if ($name =~ s/(?:^|\.)\Q$config{$h}{'zone'}\E$//) { + # The zone was successfully trimmed from $name. + } else { + fatal("Hostname %s does not end with the zone %s", $h, $config{$h}{'zone'}); + } # The IPv4 and IPv6 addresses must be updated together in a single API call. my %ips; my @updates; @@ -4186,7 +4197,7 @@ sub nic_dnsexit2_update { info("Going to update IPv%s address to %s for %s.", $ipv, $ip, $h); $config{$h}{"status-ipv$ipv"} = 'failed'; push(@updates, { - name => $h, + name => $name, type => ($ipv eq '6') ? 'AAAA' : 'A', content => $ip, ttl => $config{$h}{'ttl'}, diff --git a/t/dnsexit2.pl b/t/dnsexit2.pl index ca25e31..b32c688 100644 --- a/t/dnsexit2.pl +++ b/t/dnsexit2.pl @@ -104,10 +104,7 @@ subtest 'Testing nic_dnsexit2_update' => sub { } ] }); - TODO: { - local $TODO = "https://github.com/ddclient/ddclient/issues/673"; - is_deeply($data, $expected_data, 'Data is correct'); - } + is_deeply($data, $expected_data, 'Data is correct'); reset_test_data(); }; @@ -139,10 +136,7 @@ subtest 'Testing nic_dnsexit2_update without a zone set' => sub { } ] }); - TODO: { - local $TODO = "https://github.com/ddclient/ddclient/issues/673"; - is_deeply($data, $expected_data, 'Data is correct'); - } + is_deeply($data, $expected_data, 'Data is correct'); reset_test_data($ua); }; @@ -200,11 +194,8 @@ subtest 'Testing nic_dnsexit2_update with two hostnames, one with a zone and one @requests = get_requests(); for my $i (0..1) { my $data = decode_and_sort_array($requests[$i]->{content}); - TODO: { - local $TODO = "https://github.com/ddclient/ddclient/issues/673"; - is_deeply($data, $expected_data1, 'Data is correct for call host1') if $i == 0; - is_deeply($data, $expected_data2, 'Data is correct for call host2') if $i == 1; - } + is_deeply($data, $expected_data1, 'Data is correct for call host1') if $i == 0; + is_deeply($data, $expected_data2, 'Data is correct for call host2') if $i == 1; } reset_test_data(); };