fix whitespace diffs

This commit is contained in:
David Kerr 2017-02-16 10:22:53 -05:00
parent 1449e21a7d
commit 53d81eba97

154
ddclient
View file

@ -409,8 +409,6 @@ my %variables = (
'cmd-skip' => setv(T_STRING,0, 0, 1, '', undef), 'cmd-skip' => setv(T_STRING,0, 0, 1, '', undef),
'cmdv6' => setv(T_PROG, 0, 0, 1, '', undef), 'cmdv6' => setv(T_PROG, 0, 0, 1, '', undef),
'cmdv6-skip' => setv(T_STRING,0, 0, 1, '', undef), 'cmdv6-skip' => setv(T_STRING,0, 0, 1, '', undef),
'ip' => setv(T_IP, 0, 1, 0, undef, undef), 'ip' => setv(T_IP, 0, 1, 0, undef, undef),
'ipv6' => setv(T_IPV6, 0, 1, 0, undef, undef), 'ipv6' => setv(T_IPV6, 0, 1, 0, undef, undef),
'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')), 'wtime' => setv(T_DELAY, 0, 1, 1, 0, interval('30s')),
@ -2288,35 +2286,35 @@ sub get_ip {
$arg = '' unless $arg; $arg = '' unless $arg;
if ($use eq 'ip') { if ($use eq 'ip') {
$ip = opt('ip', $h); $ip = opt('ip', $h);
$arg = 'ip'; $arg = 'ip';
} elsif ($use eq 'if') { } elsif ($use eq 'if') {
$skip = opt('if-skip', $h) || ''; $skip = opt('if-skip', $h) || '';
$reply = `ifconfig $arg 2> /dev/null`; $reply = `ifconfig $arg 2> /dev/null`;
$reply = `ip addr list dev $arg 2> /dev/null` if $?; $reply = `ip addr list dev $arg 2> /dev/null` if $?;
$reply = '' if $?; $reply = '' if $?;
} elsif ($use eq 'cmd') { } elsif ($use eq 'cmd') {
if ($arg) { if ($arg) {
$skip = opt('cmd-skip', $h) || ''; $skip = opt('cmd-skip', $h) || '';
$reply = `$arg`; $reply = `$arg`;
$reply = '' if $?; $reply = '' if $?;
} }
} elsif ($use eq 'web') { } elsif ($use eq 'web') {
$url = opt('web', $h) || ''; $url = opt('web', $h) || '';
$skip = opt('web-skip', $h) || ''; $skip = opt('web-skip', $h) || '';
if (exists $builtinweb{$url}) { if (exists $builtinweb{$url}) {
$skip = $builtinweb{$url}->{'skip'} unless $skip; $skip = $builtinweb{$url}->{'skip'} unless $skip;
$url = $builtinweb{$url}->{'url'}; $url = $builtinweb{$url}->{'url'};
} }
$arg = $url; $arg = $url;
if ($url) { if ($url) {
# when using a web server to find public IPv4 address we should force use of IPv4 # when using a web server to find public IPv4 address we should force use of IPv4
$reply = geturl(opt('proxy', $h), $url, undef, undef, undef, undef, undef, '4') || ''; $reply = geturl(opt('proxy', $h), $url, undef, undef, undef, undef, undef, '4') || '';
} }
} elsif (($use eq 'cisco')) { } elsif (($use eq 'cisco')) {
@ -2372,8 +2370,7 @@ sub get_ip {
} }
if (!defined $reply) { if (!defined $reply) {
$reply = ''; $reply = '';
} }
if ($skip) { if ($skip) {
$skip =~ s/ /\\s/is; $skip =~ s/ /\\s/is;
$reply =~ s/^.*?${skip}//is; $reply =~ s/^.*?${skip}//is;
@ -2384,7 +2381,7 @@ sub get_ip {
$ip = filter_local($ip) if opt('fw-banlocal', $h); $ip = filter_local($ip) if opt('fw-banlocal', $h);
} }
if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) { if (($use ne 'ip') && (define($ip,'') eq '0.0.0.0')) {
$ip = undef; $ip = undef;
} }
debug("get_ip: using %s, %s reports %s", $use, $arg, define($ip, "<undefined>")); debug("get_ip: using %s, %s reports %s", $use, $arg, define($ip, "<undefined>"));
@ -2555,66 +2552,68 @@ sub nic_updateable {
my $ipv6 = $config{$host}{'wantipv6'}; my $ipv6 = $config{$host}{'wantipv6'};
if ($config{$host}{'login'} eq '') { if ($config{$host}{'login'} eq '') {
warning("null login name specified for host %s.", $host); warning("null login name specified for host %s.", $host);
} elsif ($config{$host}{'password'} eq '') { } elsif ($config{$host}{'password'} eq '') {
warning("null password specified for host %s.", $host); warning("null password specified for host %s.", $host);
} elsif ($opt{'force'}) { } elsif ($opt{'force'}) {
info("forcing update of %s.", $host); info("forcing update of %s.", $host);
$update = 1; $update = 1;
} elsif (!exists($cache{$host})) { } elsif (!exists($cache{$host})) {
info("forcing updating %s because no cached entry exists.", $host); info("forcing updating %s because no cached entry exists.", $host);
$update = 1; $update = 1;
} elsif ($cache{$host}{'wtime'} && $cache{$host}{'wtime'} > $now) { } elsif ($cache{$host}{'wtime'} && $cache{$host}{'wtime'} > $now) {
warning("cannot update %s from %s to %s until after %s.", warning("cannot update %s from %s to %s until after %s.",
$host, $host,
($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), $ip, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), $ip,
prettytime($cache{$host}{'wtime'}) prettytime($cache{$host}{'wtime'})
); );
} elsif ($cache{$host}{'mtime'} && interval_expired($host, 'mtime', 'max-interval')) { } elsif ($cache{$host}{'mtime'} && interval_expired($host, 'mtime', 'max-interval')) {
warning("forcing update of %s from %s to %s; %s since last update on %s.", warning("forcing update of %s from %s to %s; %s since last update on %s.",
$host, $host,
($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), $ip, ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), $ip,
prettyinterval($config{$host}{'max-interval'}), prettyinterval($config{$host}{'max-interval'}),
prettytime($cache{$host}{'mtime'}) prettytime($cache{$host}{'mtime'})
); );
$update = 1; $update = 1;
} elsif ((defined($config{$host}{'use'}) && ($config{$host}{'use'} ne 'no')) && } elsif ((defined($config{$host}{'use'}) && ($config{$host}{'use'} ne 'no')) &&
((!exists($cache{$host}{'ip'})) || ("$cache{$host}{'ip'}" ne "$ip"))) { ((!exists($cache{$host}{'ip'})) || ("$cache{$host}{'ip'}" ne "$ip"))) {
if (($cache{$host}{'status'} eq 'good') && if (($cache{$host}{'status'} eq 'good') &&
!interval_expired($host, 'mtime', 'min-interval')) { !interval_expired($host, 'mtime', 'min-interval')) {
warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.", warning("skipping update of %s from %s to %s.\nlast updated %s.\nWait at least %s between update attempts.",
$host, $host,
($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'),
$ip, $ip,
($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : '<never>'), ($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : '<never>'),
prettyinterval($config{$host}{'min-interval'}) prettyinterval($config{$host}{'min-interval'})
) )
if opt('verbose') || !define($cache{$host}{'warned-min-interval'}, 0); if opt('verbose') || !define($cache{$host}{'warned-min-interval'}, 0);
$cache{$host}{'warned-min-interval'} = $now;
$cache{$host}{'warned-min-interval'} = $now;
} elsif (($cache{$host}{'status'} ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) { } elsif (($cache{$host}{'status'} ne 'good') && !interval_expired($host, 'atime', 'min-error-interval')) {
warning("skipping update of %s from %s to %s.\nlast updated %s but last attempt on %s failed.\nWait at least %s between update attempts.", warning("skipping update of %s from %s to %s.\nlast updated %s but last attempt on %s failed.\nWait at least %s between update attempts.",
$host, $host,
($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'), ($cache{$host}{'ip'} ? $cache{$host}{'ip'} : '<nothing>'),
$ip, $ip,
($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : '<never>'), ($cache{$host}{'mtime'} ? prettytime($cache{$host}{'mtime'}) : '<never>'),
($cache{$host}{'atime'} ? prettytime($cache{$host}{'atime'}) : '<never>'), ($cache{$host}{'atime'} ? prettytime($cache{$host}{'atime'}) : '<never>'),
prettyinterval($config{$host}{'min-error-interval'}) prettyinterval($config{$host}{'min-error-interval'})
) )
if opt('verbose') || !define($cache{$host}{'warned-min-error-interval'}, 0); if opt('verbose') || !define($cache{$host}{'warned-min-error-interval'}, 0);
$cache{$host}{'warned-min-error-interval'} = $now;
} else { $cache{$host}{'warned-min-error-interval'} = $now;
$update = 1;
} } else {
$update = 1;
}
} elsif ((defined($config{$host}{'usev6'}) && ($config{$host}{'usev6'} ne 'no') ) && } elsif ((defined($config{$host}{'usev6'}) && ($config{$host}{'usev6'} ne 'no') ) &&
((!exists($cache{$host}{'ipv6'})) || ("$cache{$host}{'ipv6'}" ne "$ipv6"))) { ((!exists($cache{$host}{'ipv6'})) || ("$cache{$host}{'ipv6'}" ne "$ipv6"))) {
@ -2647,7 +2646,7 @@ sub nic_updateable {
} }
} elsif (defined($sub) && &$sub($host)) { } elsif (defined($sub) && &$sub($host)) {
$update = 1; $update = 1;
} elsif ((defined($cache{$host}{'static'}) && defined($config{$host}{'static'}) && } elsif ((defined($cache{$host}{'static'}) && defined($config{$host}{'static'}) &&
($cache{$host}{'static'} ne $config{$host}{'static'})) || ($cache{$host}{'static'} ne $config{$host}{'static'})) ||
(defined($cache{$host}{'wildcard'}) && defined($config{$host}{'wildcard'}) && (defined($cache{$host}{'wildcard'}) && defined($config{$host}{'wildcard'}) &&
@ -2656,8 +2655,8 @@ sub nic_updateable {
($cache{$host}{'mx'} ne $config{$host}{'mx'})) || ($cache{$host}{'mx'} ne $config{$host}{'mx'})) ||
(defined($cache{$host}{'backupmx'}) && defined($config{$host}{'backupmx'}) && (defined($cache{$host}{'backupmx'}) && defined($config{$host}{'backupmx'}) &&
($cache{$host}{'backupmx'} ne $config{$host}{'backupmx'})) ) { ($cache{$host}{'backupmx'} ne $config{$host}{'backupmx'})) ) {
info("updating %s because host settings have been changed.", $host); info("updating %s because host settings have been changed.", $host);
$update = 1; $update = 1;
} else { } else {
if (opt('verbose')) { if (opt('verbose')) {
@ -2672,19 +2671,18 @@ sub nic_updateable {
$config{$host}{'status'} = define($cache{$host}{'status'},''); $config{$host}{'status'} = define($cache{$host}{'status'},'');
$config{$host}{'update'} = $update; $config{$host}{'update'} = $update;
if ($update) { if ($update) {
$config{$host}{'status'} = 'noconnect'; $config{$host}{'status'} = 'noconnect';
$config{$host}{'atime'} = $now; $config{$host}{'atime'} = $now;
$config{$host}{'wtime'} = 0; $config{$host}{'wtime'} = 0;
$config{$host}{'warned-min-interval'} = 0; $config{$host}{'warned-min-interval'} = 0;
$config{$host}{'warned-min-error-interval'} = 0; $config{$host}{'warned-min-error-interval'} = 0;
delete $cache{$host}{'warned-min-interval'}; delete $cache{$host}{'warned-min-interval'};
delete $cache{$host}{'warned-min-error-interval'}; delete $cache{$host}{'warned-min-error-interval'};
} }
return $update; return $update;
} }
###################################################################### ######################################################################
## header_ok ## header_ok
###################################################################### ######################################################################