Don't issue warnings when freedns IP didn't change
Before this update, freedns warnings would appear in the log even though FreeDNS sent back a code 200 with a message indicating the IP address was already correct. A simple regex change was all that was needed to make this a success instead. Now, it looks like this: DEBUG: server = freedns.afraid.org SUCCESS: updating xxx.xxx.xxx good: IP address has not changed
This commit is contained in:
parent
23442303f4
commit
f283d1e7ee
2 changed files with 36 additions and 37 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
===============================================================================
|
===============================================================================
|
||||||
# DDCLIENT v3.8.2
|
# DDCLIENT v3.8.3
|
||||||
|
|
||||||
ddclient is a Perl client used to update dynamic DNS entries for accounts
|
ddclient is a Perl client used to update dynamic DNS entries for accounts
|
||||||
on many dynamic DNS services.
|
on many dynamic DNS services.
|
||||||
|
|
|
||||||
71
ddclient
71
ddclient
|
|
@ -25,7 +25,7 @@ use Getopt::Long;
|
||||||
use Sys::Hostname;
|
use Sys::Hostname;
|
||||||
use IO::Socket;
|
use IO::Socket;
|
||||||
|
|
||||||
my $version = "3.8.3";
|
my $version = "3.8.3.1-hank";
|
||||||
my $programd = $0;
|
my $programd = $0;
|
||||||
$programd =~ s%^.*/%%;
|
$programd =~ s%^.*/%%;
|
||||||
my $program = $programd;
|
my $program = $programd;
|
||||||
|
|
@ -3704,64 +3704,63 @@ EoEXAMPLE
|
||||||
##
|
##
|
||||||
######################################################################
|
######################################################################
|
||||||
sub nic_freedns_update {
|
sub nic_freedns_update {
|
||||||
|
|
||||||
|
|
||||||
debug("\nnic_freedns_update -------------------");
|
debug("\nnic_freedns_update -------------------");
|
||||||
|
|
||||||
## First get the list of updatable hosts
|
## First get the list of updatable hosts
|
||||||
my $url;
|
my $url;
|
||||||
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
$url = "http://$config{$_[0]}{'server'}/api/?action=getdyndns&sha=".&sha1_hex("$config{$_[0]}{'login'}|$config{$_[0]}{'password'}");
|
||||||
my $reply = geturl(opt('proxy'), $url);
|
my $reply = geturl(opt('proxy'), $url);
|
||||||
if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) {
|
if (!defined($reply) || !$reply || !header_ok($_[0], $reply)) {
|
||||||
failed("updating %s: Could not connect to %s for site list.", $_[0], $url);
|
failed("updating %s: Could not connect to %s for site list.", $_[0], $url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
my @lines = split("\n", $reply);
|
my @lines = split("\n", $reply);
|
||||||
my %freedns_hosts;
|
my %freedns_hosts;
|
||||||
grep {
|
grep {
|
||||||
my @rec = split(/\|/, $_);
|
my @rec = split(/\|/, $_);
|
||||||
$freedns_hosts{$rec[0]} = \@rec if ($#rec > 0);
|
$freedns_hosts{$rec[0]} = \@rec if ($#rec > 0);
|
||||||
} @lines;
|
} @lines;
|
||||||
if (!keys %freedns_hosts) {
|
if (!keys %freedns_hosts) {
|
||||||
failed("Could not get freedns update URLs from %s", $config{$_[0]}{'server'});
|
failed("Could not get freedns update URLs from %s", $config{$_[0]}{'server'});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
## update each configured host
|
## update each configured host
|
||||||
foreach my $h (@_) {
|
foreach my $h (@_) {
|
||||||
if(!$h){ next };
|
if(!$h){ next };
|
||||||
my $ip = delete $config{$h}{'wantip'};
|
my $ip = delete $config{$h}{'wantip'};
|
||||||
info("setting IP address to %s for %s", $ip, $h);
|
info("setting IP address to %s for %s", $ip, $h);
|
||||||
verbose("UPDATE:","updating %s", $h);
|
verbose("UPDATE:","updating %s", $h);
|
||||||
|
|
||||||
if($ip eq $freedns_hosts{$h}->[1]) {
|
if($ip eq $freedns_hosts{$h}->[1]) {
|
||||||
$config{$h}{'ip'} = $ip;
|
$config{$h}{'ip'} = $ip;
|
||||||
$config{$h}{'mtime'} = $now;
|
$config{$h}{'mtime'} = $now;
|
||||||
$config{$h}{'status'} = 'good';
|
$config{$h}{'status'} = 'good';
|
||||||
success("update not necessary %s: good: IP address already set to %s", $h, $ip);
|
success("update not necessary %s: good: IP address already set to %s", $h, $ip);
|
||||||
} else {
|
|
||||||
my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]);
|
|
||||||
if (!defined($reply) || !$reply) {
|
|
||||||
failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]);
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
if(!header_ok($h, $reply)) {
|
|
||||||
$config{$h}{'status'} = 'failed';
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($reply =~ /Updated.*$h.*to.*$ip/) {
|
|
||||||
$config{$h}{'ip'} = $ip;
|
|
||||||
$config{$h}{'mtime'} = $now;
|
|
||||||
$config{$h}{'status'} = 'good';
|
|
||||||
success("updating %s: good: IP address set to %s", $h, $ip);
|
|
||||||
} else {
|
} else {
|
||||||
$config{$h}{'status'} = 'failed';
|
my $reply = geturl(opt('proxy'), $freedns_hosts{$h}->[2]);
|
||||||
warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose');
|
if (!defined($reply) || !$reply) {
|
||||||
warning("REPLIED: %s", $reply);
|
failed("updating %s: Could not connect to %s.", $h, $freedns_hosts{$h}->[2]);
|
||||||
failed("updating %s: Invalid reply.", $h);
|
last;
|
||||||
|
}
|
||||||
|
if(!header_ok($h, $reply)) {
|
||||||
|
$config{$h}{'status'} = 'failed';
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($reply =~ /Updated.*$h.*to.*$ip/) {
|
||||||
|
$config{$h}{'ip'} = $ip;
|
||||||
|
$config{$h}{'mtime'} = $now;
|
||||||
|
$config{$h}{'status'} = 'good';
|
||||||
|
success("updating %s: good: IP address set to %s", $h, $ip);
|
||||||
|
} elsif ($reply =~ /Address .* has not changed/) {
|
||||||
|
success("updating %s: good: IP address has not changed", $h, $ip);
|
||||||
|
} else {
|
||||||
|
$config{$h}{'status'} = 'failed';
|
||||||
|
warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose');
|
||||||
|
warning("REPLIED: %s", $reply);
|
||||||
|
failed("updating %s: Invalid reply.", $h);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue