Merge pull request #713 from rhansen/easydns
easydns: Multiple fixes and cleanups
This commit is contained in:
commit
cf078017c2
2 changed files with 56 additions and 80 deletions
10
ChangeLog.md
10
ChangeLog.md
|
@ -43,6 +43,9 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
|
||||||
[#709](https://github.com/ddclient/ddclient/pull/709)
|
[#709](https://github.com/ddclient/ddclient/pull/709)
|
||||||
* The diagnostic `--geturl` command-line argument was removed.
|
* The diagnostic `--geturl` command-line argument was removed.
|
||||||
[#712](https://github.com/ddclient/ddclient/pull/712)
|
[#712](https://github.com/ddclient/ddclient/pull/712)
|
||||||
|
* `easydns`: The default value for `min-interval` was increased from 5m to 10m
|
||||||
|
to match easyDNS documentation.
|
||||||
|
[#713](https://github.com/ddclient/ddclient/pull/713)
|
||||||
|
|
||||||
### New features
|
### New features
|
||||||
|
|
||||||
|
@ -121,6 +124,13 @@ repository history](https://github.com/ddclient/ddclient/commits/master).
|
||||||
[#692](https://github.com/ddclient/ddclient/pull/692)
|
[#692](https://github.com/ddclient/ddclient/pull/692)
|
||||||
* `regfishde`: Fixed IPv6 support.
|
* `regfishde`: Fixed IPv6 support.
|
||||||
[#691](https://github.com/ddclient/ddclient/pull/691)
|
[#691](https://github.com/ddclient/ddclient/pull/691)
|
||||||
|
* `easydns`: IPv4 and IPv6 addresses are now updated separately to be
|
||||||
|
consistent with the easyDNS documentation.
|
||||||
|
[#713](https://github.com/ddclient/ddclient/pull/713)
|
||||||
|
* `easydns`: Fixed parsing of result code from server response.
|
||||||
|
[#713](https://github.com/ddclient/ddclient/pull/713)
|
||||||
|
* `easydns`: Fixed successful updates treated as failed updates.
|
||||||
|
[#713](https://github.com/ddclient/ddclient/pull/713)
|
||||||
|
|
||||||
## 2023-11-23 v3.11.2
|
## 2023-11-23 v3.11.2
|
||||||
|
|
||||||
|
|
100
ddclient.in
100
ddclient.in
|
@ -866,7 +866,9 @@ our %protocols = (
|
||||||
'variables' => {
|
'variables' => {
|
||||||
%{$variables{'protocol-common-defaults'}},
|
%{$variables{'protocol-common-defaults'}},
|
||||||
'backupmx' => setv(T_BOOL, 0, 1, 0, undef),
|
'backupmx' => setv(T_BOOL, 0, 1, 0, undef),
|
||||||
'min-interval' => setv(T_DELAY, 0, 0, interval('5m'), 0),
|
# From <https://kb.easydns.com/knowledge/dynamic-dns/>: "You need to wait at least 10
|
||||||
|
# minutes between updates."
|
||||||
|
'min-interval' => setv(T_DELAY, 0, 0, interval('10m'), 0),
|
||||||
'mx' => setv(T_OFQDN, 0, 1, undef, undef),
|
'mx' => setv(T_OFQDN, 0, 1, undef, undef),
|
||||||
'server' => setv(T_FQDNP, 0, 0, 'api.cp.easydns.com', undef),
|
'server' => setv(T_FQDNP, 0, 0, 'api.cp.easydns.com', undef),
|
||||||
'script' => setv(T_STRING, 0, 1, '/dyn/generic.php', undef),
|
'script' => setv(T_STRING, 0, 1, '/dyn/generic.php', undef),
|
||||||
|
@ -4790,35 +4792,21 @@ sub nic_easydns_update {
|
||||||
debug("\nnic_easydns_update -------------------");
|
debug("\nnic_easydns_update -------------------");
|
||||||
my %errors = (
|
my %errors = (
|
||||||
'NOACCESS' => 'Authentication failed. This happens if the username/password OR host or domain are wrong.',
|
'NOACCESS' => 'Authentication failed. This happens if the username/password OR host or domain are wrong.',
|
||||||
|
'NO_AUTH' => 'Authentication failed. This happens if the username/password OR host or domain are wrong.',
|
||||||
'NOSERVICE' => 'Dynamic DNS is not turned on for this domain.',
|
'NOSERVICE' => 'Dynamic DNS is not turned on for this domain.',
|
||||||
'ILLEGAL' => 'Client sent data that is not allowed in a dynamic DNS update.',
|
'ILLEGAL INPUT' => 'Client sent data that is not allowed in a dynamic DNS update.',
|
||||||
'TOOSOON' => 'Update frequency is too short.',
|
'TOOSOON' => 'Update frequency is too short.',
|
||||||
);
|
);
|
||||||
for my $h (@_) {
|
for my $h (@_) {
|
||||||
my $ipv4 = delete $config{$h}{'wantipv4'};
|
for my $ipv ('4', '6') {
|
||||||
my $ipv6 = delete $config{$h}{'wantipv6'};
|
my $ip = delete $config{$h}{"wantipv$ipv"} or next;
|
||||||
|
info("$h: setting IPv$ipv address to $ip");
|
||||||
info("setting IP address to %s %s for %s", $ipv4, $ipv6, $h);
|
|
||||||
verbose("UPDATE:", "updating %s", $h);
|
|
||||||
|
|
||||||
#'https://api.cp.easydns.com/dyn/generic.php?hostname=test.burry.ca&myip=10.20.30.40&wildcard=ON'
|
#'https://api.cp.easydns.com/dyn/generic.php?hostname=test.burry.ca&myip=10.20.30.40&wildcard=ON'
|
||||||
|
my $url = "https://$config{$h}{'server'}$config{$h}{'script'}?hostname=$h&myip=$ip";
|
||||||
my $url;
|
$url .= "&wildcard=" . ynu($config{$h}{'wildcard'}, 'ON', 'OFF', 'OFF')
|
||||||
$url = "https://$config{$h}{'server'}$config{$h}{'script'}?";
|
if defined($config{$h}{'wildcard'});
|
||||||
$url .= "hostname=$h";
|
$url .= "&mx=$config{$h}{'mx'}&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO')
|
||||||
$url .= "&myip=";
|
if $config{$h}{'mx'};
|
||||||
$url .= $ipv4 if $ipv4;
|
|
||||||
for my $ipv6a ($ipv6) {
|
|
||||||
$url .= "&myip=";
|
|
||||||
$url .= $ipv6a
|
|
||||||
}
|
|
||||||
$url .= "&wildcard=" . ynu($config{$h}{'wildcard'}, 'ON', 'OFF', 'OFF') if defined $config{$h}{'wildcard'};
|
|
||||||
|
|
||||||
if ($config{$h}{'mx'}) {
|
|
||||||
$url .= "&mx=$config{$h}{'mx'}";
|
|
||||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
|
||||||
}
|
|
||||||
|
|
||||||
my $reply = geturl(
|
my $reply = geturl(
|
||||||
proxy => opt('proxy'),
|
proxy => opt('proxy'),
|
||||||
url => $url,
|
url => $url,
|
||||||
|
@ -4826,55 +4814,33 @@ sub nic_easydns_update {
|
||||||
password => $config{$h}{'password'},
|
password => $config{$h}{'password'},
|
||||||
) // '';
|
) // '';
|
||||||
if ($reply eq '') {
|
if ($reply eq '') {
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'});
|
failed("$h: Could not connect to $config{$h}{'server'}");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
next if !header_ok($h, $reply);
|
next if !header_ok($h, $reply);
|
||||||
|
(my $body = $reply) =~ s/^.*?\n\n//s or do {
|
||||||
my @reply = split /\n/, $reply;
|
failed("$h: Could not connect to $config{$h}{'server'}");
|
||||||
my $state = 'header';
|
next;
|
||||||
for my $line (@reply) {
|
};
|
||||||
if ($state eq 'header') {
|
my $resultcode_re = join('|', map({quotemeta} 'NOERROR', keys(%errors)));
|
||||||
$state = 'body';
|
my ($status) = $body =~ qr/\b($resultcode_re)\b/;
|
||||||
|
# 'good' is the only status value that ddclient considers to be successful. All other
|
||||||
} elsif ($state eq 'body') {
|
# values are considered to be failures and will result in frequent retries (every
|
||||||
$state = 'results' if $line eq '';
|
# min-error-interval, which defaults to 5m).
|
||||||
|
$status = 'good' if ($status // '') =~ qr/^NOERROR|OK$/;
|
||||||
} elsif ($state =~ /^results/) {
|
$config{$h}{"status-ipv$ipv"} = $status;
|
||||||
$state = 'results2';
|
if ($status ne 'good') {
|
||||||
|
if (exists $errors{$status}) {
|
||||||
my ($status) = $line =~ /^(\S*)\b.*/;
|
failed("$h: $status: $errors{$status}");
|
||||||
|
|
||||||
$config{$h}{'status-ipv4'} = $status if $ipv4;
|
|
||||||
$config{$h}{'status-ipv6'} = $status if $ipv6;
|
|
||||||
if ($status eq 'NOERROR') {
|
|
||||||
$config{$h}{'ipv4'} = $ipv4;
|
|
||||||
$config{$h}{'ipv6'} = $ipv6;
|
|
||||||
$config{$h}{'mtime'} = $now;
|
|
||||||
success("updating %s: %s: IP address set to %s %s", $h, $status, $ipv4, $ipv6);
|
|
||||||
|
|
||||||
} elsif ($status =~ /TOOSOON/) {
|
|
||||||
## make sure we wait at least a little
|
|
||||||
my ($wait, $units) = (5, 'm');
|
|
||||||
my ($sec, $scale) = ($wait, 1);
|
|
||||||
|
|
||||||
($scale, $units) = (1, 'seconds') if $units eq 's';
|
|
||||||
($scale, $units) = (60, 'minutes') if $units eq 'm';
|
|
||||||
($scale, $units) = (60*60, 'hours') if $units eq 'h';
|
|
||||||
$config{$h}{'wtime'} = $now + $sec;
|
|
||||||
warning("updating %s: %s: wait %d %s before further updates", $h, $status, $wait, $units);
|
|
||||||
|
|
||||||
} elsif (exists $errors{$status}) {
|
|
||||||
failed("updating %s: %s: %s", $h, $line, $errors{$status});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
failed("updating %s: unexpected status (%s)", $h, $line);
|
failed("$h: unexpected result: $body");
|
||||||
}
|
}
|
||||||
last;
|
next;
|
||||||
}
|
}
|
||||||
|
$config{$h}{"ipv$ipv"} = $ip;
|
||||||
|
$config{$h}{'mtime'} = $now;
|
||||||
|
success("$h: IPv$ipv address set to $ip");
|
||||||
}
|
}
|
||||||
failed("updating %s: Could not connect to %s.", $h, $config{$h}{'server'})
|
|
||||||
if $state ne 'results2';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue