Fixing bug #13: multiple fetch-ip but introducing a multiple ip bug
git-svn-id: svn+ssh://svn.code.sf.net/p/ddclient/code/trunk@121 3873ddee-7413-0410-b6c4-c2c57c1ab35a
This commit is contained in:
parent
4edbb7a3e9
commit
e406318257
1 changed files with 48 additions and 37 deletions
85
ddclient
85
ddclient
|
@ -740,47 +740,58 @@ sub runpostscript {
|
||||||
## update_nics
|
## update_nics
|
||||||
######################################################################
|
######################################################################
|
||||||
sub update_nics {
|
sub update_nics {
|
||||||
my %examined = ();
|
my %examined = ();
|
||||||
|
my %iplist = ();
|
||||||
|
|
||||||
foreach my $s (sort keys %services) {
|
foreach my $s (sort keys %services) {
|
||||||
my (@hosts, %ips) = ();
|
my (@hosts, %ips) = ();
|
||||||
my $updateable = $services{$s}{'updateable'};
|
my $updateable = $services{$s}{'updateable'};
|
||||||
my $update = $services{$s}{'update'};
|
my $update = $services{$s}{'update'};
|
||||||
|
|
||||||
|
foreach my $h (sort keys %config) {
|
||||||
|
next if $config{$h}{'protocol'} ne lc($s);
|
||||||
|
$examined{$h} = 1;
|
||||||
|
my $use = $config{$h}{'use'} || opt('use');
|
||||||
|
local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
|
||||||
|
# bug #13: we should only do this once
|
||||||
|
# use isn't enough, we have to save the origin to.
|
||||||
|
# this will break the multiple ip stuff if use has
|
||||||
|
# been used twice for the same device.
|
||||||
|
my $ip = "";
|
||||||
|
if (defined $iplist{$use}) {
|
||||||
|
$ip = $iplist{$use};
|
||||||
|
} else {
|
||||||
|
$ip = get_ip($use, $h);
|
||||||
|
if (!defined $ip || !$ip) {
|
||||||
|
warning("unable to determine IP address")
|
||||||
|
if !$daemon || opt('verbose');
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
||||||
|
warning("malformed IP address (%s)", $ip);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
$iplist{$use} = $ip;
|
||||||
|
}
|
||||||
|
$config{$h}{'wantip'} = $ip;
|
||||||
|
next if !nic_updateable($h, $updateable);
|
||||||
|
push @hosts, $h;
|
||||||
|
$ips{$ip} = $h;
|
||||||
|
}
|
||||||
|
if (@hosts) {
|
||||||
|
$0 = sprintf("%s - updating %s", $program, join(',', @hosts));
|
||||||
|
&$update(@hosts);
|
||||||
|
runpostscript(join ' ', keys %ips);
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach my $h (sort keys %config) {
|
foreach my $h (sort keys %config) {
|
||||||
next if $config{$h}{'protocol'} ne lc($s);
|
if (!exists $examined{$h}) {
|
||||||
$examined{$h} = 1;
|
failed("%s was not updated because protocol %s is not supported.",
|
||||||
my $use = $config{$h}{'use'} || opt('use');
|
$h, define($config{$h}{'protocol'}, '<undefined>')
|
||||||
local $opt{$use} = $config{$h}{$use} if $config{$h}{$use};
|
);
|
||||||
my $ip = get_ip($use, $h);
|
}
|
||||||
if (!defined $ip || !$ip) {
|
|
||||||
warning("unable to determine IP address")
|
|
||||||
if !$daemon || opt('verbose');
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
if ($ip !~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) {
|
|
||||||
warning("malformed IP address (%s)", $ip);
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
$config{$h}{'wantip'} = $ip;
|
|
||||||
next if !nic_updateable($h, $updateable);
|
|
||||||
push @hosts, $h;
|
|
||||||
$ips{$ip} = $h;
|
|
||||||
}
|
}
|
||||||
if (@hosts) {
|
write_cache(opt('cache'));
|
||||||
$0 = sprintf("%s - updating %s", $program, join(',', @hosts));
|
|
||||||
&$update(@hosts);
|
|
||||||
runpostscript(join ' ', keys %ips);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach my $h (sort keys %config) {
|
|
||||||
if (!exists $examined{$h}) {
|
|
||||||
failed("%s was not updated because protocol %s is not supported.",
|
|
||||||
$h, define($config{$h}{'protocol'}, '<undefined>')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
write_cache(opt('cache'));
|
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
## unlink_pid()
|
## unlink_pid()
|
||||||
|
|
Loading…
Reference in a new issue