Use opt()
instead of accessing %opt
or %globals
directly
This is for consistency, and to ensure that all possible ways of configuring are respected.
This commit is contained in:
parent
4d3dcdc7de
commit
2f8a4ba00a
1 changed files with 13 additions and 15 deletions
26
ddclient.in
26
ddclient.in
|
@ -1255,7 +1255,7 @@ sub main {
|
||||||
%saved_opt = %opt;
|
%saved_opt = %opt;
|
||||||
$result = 'OK';
|
$result = 'OK';
|
||||||
## read config file because 'daemon' mode may be defined there.
|
## read config file because 'daemon' mode may be defined there.
|
||||||
read_config($opt{'file'} // default('file'), \%config, \%globals);
|
read_config(opt('file'), \%config, \%globals);
|
||||||
init_config();
|
init_config();
|
||||||
test_possible_ip() if opt('query');
|
test_possible_ip() if opt('query');
|
||||||
|
|
||||||
|
@ -1288,19 +1288,17 @@ sub main {
|
||||||
$now = time;
|
$now = time;
|
||||||
$result = 'OK';
|
$result = 'OK';
|
||||||
%opt = %saved_opt;
|
%opt = %saved_opt;
|
||||||
read_config($opt{'file'} // default('file'), \%config, \%globals);
|
read_config(opt('file'), \%config, \%globals);
|
||||||
init_config();
|
init_config();
|
||||||
read_recap(opt('cache'), \%recap);
|
read_recap(opt('cache'), \%recap);
|
||||||
print_info() if opt('debug') && opt('verbose');
|
print_info() if opt('debug') && opt('verbose');
|
||||||
|
|
||||||
fatal("invalid argument '--use=%s'; possible values are:\n%s",
|
fatal("invalid argument '--use=%s'; possible values are:\n%s",
|
||||||
$opt{'use'}, join("\n", ip_strategies_usage()))
|
opt('use'), join("\n", ip_strategies_usage()))
|
||||||
if defined(opt('use')) && !$ip_strategies{lc(opt('use'))};
|
if defined(opt('use')) && !$ip_strategies{lc(opt('use'))};
|
||||||
if (defined($opt{'usev6'})) {
|
|
||||||
fatal("invalid argument '--usev6=%s'; possible values are:\n%s",
|
fatal("invalid argument '--usev6=%s'; possible values are:\n%s",
|
||||||
$opt{'usev6'}, join("\n", ipv6_strategies_usage()))
|
opt('usev6'), join("\n", ipv6_strategies_usage()))
|
||||||
unless exists $ipv6_strategies{lc opt('usev6')};
|
if defined(opt('usev6')) && !$ipv6_strategies{lc(opt('usev6'))};
|
||||||
}
|
|
||||||
|
|
||||||
$daemon = opt('daemon');
|
$daemon = opt('daemon');
|
||||||
|
|
||||||
|
@ -1347,12 +1345,12 @@ sub main {
|
||||||
sub runpostscript {
|
sub runpostscript {
|
||||||
my ($ip) = @_;
|
my ($ip) = @_;
|
||||||
|
|
||||||
if (defined $globals{postscript}) {
|
if (defined(my $ps = opt('postscript'))) {
|
||||||
my @postscript = split(/\s+/, $globals{postscript});
|
my @postscript = split(/\s+/, $ps);
|
||||||
if (-x $postscript[0]) {
|
if (-x $postscript[0]) {
|
||||||
system("$globals{postscript} $ip &");
|
system("$ps $ip &");
|
||||||
} else {
|
} else {
|
||||||
warning("Can not execute post script: %s", $globals{postscript});
|
warning("Can not execute post script: %s", $ps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1971,7 +1969,7 @@ sub init_config {
|
||||||
}
|
}
|
||||||
|
|
||||||
## sanity check
|
## sanity check
|
||||||
if (defined $opt{'host'} && defined $opt{'retry'}) {
|
if (defined(opt('host')) && opt('retry')) {
|
||||||
fatal("options --retry and --host (or --option host=..) are mutually exclusive");
|
fatal("options --retry and --host (or --option host=..) are mutually exclusive");
|
||||||
}
|
}
|
||||||
fatal("options --retry and --daemon cannot be used together") if (opt('retry') && opt('daemon'));
|
fatal("options --retry and --daemon cannot be used together") if (opt('retry') && opt('daemon'));
|
||||||
|
@ -2769,7 +2767,7 @@ sub geturl {
|
||||||
$use_ssl = 1;
|
$use_ssl = 1;
|
||||||
} elsif ($url =~ /^http:/) {
|
} elsif ($url =~ /^http:/) {
|
||||||
$use_ssl = 0;
|
$use_ssl = 0;
|
||||||
} elsif ($globals{'ssl'} && !($params{ignore_ssl_option} // 0)) {
|
} elsif (opt('ssl') && !($params{ignore_ssl_option} // 0)) {
|
||||||
$use_ssl = 1;
|
$use_ssl = 1;
|
||||||
} else {
|
} else {
|
||||||
$use_ssl = 0;
|
$use_ssl = 0;
|
||||||
|
@ -3573,7 +3571,7 @@ sub nic_updateable {
|
||||||
$warned_ipv4{$host} = 0 if $usev4 ne 'disabled' && $ipv4;
|
$warned_ipv4{$host} = 0 if $usev4 ne 'disabled' && $ipv4;
|
||||||
$warned_ipv6{$host} = 0 if $usev6 ne 'disabled' && $ipv6;
|
$warned_ipv6{$host} = 0 if $usev6 ne 'disabled' && $ipv6;
|
||||||
|
|
||||||
if ($opt{'force'}) {
|
if (opt('force')) {
|
||||||
info("update forced via 'force' option");
|
info("update forced via 'force' option");
|
||||||
$update = 1;
|
$update = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue