Skip to content

Commit

Permalink
Minor change to cache ip on freedns no-change
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Gregg committed Nov 29, 2015
1 parent b478bf1 commit a2815d5
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions ddclient
Original file line number Diff line number Diff line change
Expand Up @@ -3730,29 +3730,33 @@ sub nic_freedns_update {
info("setting IP address to %s for %s", $ip, $h);
verbose("UPDATE:","updating %s", $h);

if($ip eq $freedns_hosts{$h}->[1]) {
$config{$h}{'ip'} = $ip;
$config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good';
success("update not necessary %s: good: IP address already set to %s", $h, $ip);
if($ip eq $freedns_hosts{$h}->[1]) {
$config{$h}{'ip'} = $ip;
$config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good';
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';
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);
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 (\d+\.\d+\.\d+\.\d+) has not changed/) {
$ip = $1;
$config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good';
$config{$h}{'ip'} = $ip;
success("updating %s: good: IP address %s has not changed", $h, $ip);
} else {
$config{$h}{'status'} = 'failed';
warning("SENT: %s", $freedns_hosts{$h}->[2]) unless opt('verbose');
Expand Down

0 comments on commit a2815d5

Please sign in to comment.