Whitespace fixes
This commit is contained in:
parent
b488cb2235
commit
161c623557
1 changed files with 87 additions and 129 deletions
62
ddclient.in
62
ddclient.in
|
@ -4007,31 +4007,26 @@ Example ${program}.conf file entries:
|
|||
my-toplevel-domain.com,my-other-domain.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_dyndns2_update
|
||||
######################################################################
|
||||
sub nic_dyndns2_update {
|
||||
debug("\nnic_dyndns2_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(login password server static custom wildcard mx backupmx wantipv4 wantipv6)]);
|
||||
|
||||
my %errors = (
|
||||
'badauth' => 'Bad authorization (username or password)',
|
||||
'badsys' => 'The system parameter given was not valid',
|
||||
|
||||
'notfqdn' => 'A Fully-Qualified Domain Name was not provided',
|
||||
'nohost' => 'The hostname specified does not exist in the database',
|
||||
'!yours' => 'The hostname specified exists, but not under the username currently being used',
|
||||
'!donator' => 'The offline setting was set, when the user is not a donator',
|
||||
'!active' => 'The hostname specified is in a Custom DNS domain which has not yet been activated.',
|
||||
'abuse', => 'The hostname specified is blocked for abuse; you should receive an email notification which provides an unblock request link. More info can be found on https://www.dyndns.com/support/abuse.html',
|
||||
|
||||
'numhost' => 'System error: Too many or too few hosts found. Contact support@dyndns.org',
|
||||
'dnserr' => 'System error: DNS error encountered. Contact support@dyndns.org',
|
||||
|
||||
'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive',
|
||||
);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -4040,25 +4035,20 @@ sub nic_dyndns2_update {
|
|||
my $ipv6 = $config{$h}{'wantipv6'};
|
||||
delete $config{$_}{'wantipv4'} for @hosts;
|
||||
delete $config{$_}{'wantipv6'} for @hosts;
|
||||
|
||||
info("setting IPv4 address to %s for %s", $ipv4, $hosts) if $ipv4;
|
||||
info("setting IPv6 address to %s for %s", $ipv6, $hosts) if $ipv6;
|
||||
verbose("UPDATE:", "updating %s", $hosts);
|
||||
|
||||
## Select the DynDNS system to update
|
||||
my $url = "http://$config{$h}{'server'}$config{$h}{'script'}?system=";
|
||||
if ($config{$h}{'custom'}) {
|
||||
warning("updating %s: 'custom' and 'static' may not be used together. ('static' ignored)", $hosts)
|
||||
if $config{$h}{'static'};
|
||||
$url .= 'custom';
|
||||
|
||||
} elsif ($config{$h}{'static'}) {
|
||||
$url .= 'statdns';
|
||||
|
||||
} else {
|
||||
$url .= 'dyndns';
|
||||
}
|
||||
|
||||
$url .= "&hostname=$hosts";
|
||||
$url .= "&myip=";
|
||||
$url .= $ipv4 if $ipv4;
|
||||
|
@ -4066,14 +4056,12 @@ sub nic_dyndns2_update {
|
|||
$url .= "," if $ipv4;
|
||||
$url .= $ipv6;
|
||||
}
|
||||
|
||||
## some args are not valid for a custom domain.
|
||||
$url .= "&wildcard=ON" if ynu($config{$h}{'wildcard'}, 1, 0, 0);
|
||||
if ($config{$h}{'mx'}) {
|
||||
$url .= "&mx=$config{$h}{'mx'}";
|
||||
$url .= "&backmx=" . ynu($config{$h}{'backupmx'}, 'YES', 'NO');
|
||||
}
|
||||
|
||||
my $reply = geturl(
|
||||
proxy => opt('proxy'),
|
||||
url => $url,
|
||||
|
@ -4085,43 +4073,33 @@ sub nic_dyndns2_update {
|
|||
next;
|
||||
}
|
||||
next if !header_ok($hosts, $reply);
|
||||
|
||||
my @reply = split /\n/, $reply;
|
||||
my $state = 'header';
|
||||
|
||||
for my $line (@reply) {
|
||||
if ($state eq 'header') {
|
||||
$state = 'body';
|
||||
|
||||
} elsif ($state eq 'body') {
|
||||
$state = 'results' if $line eq '';
|
||||
|
||||
} elsif ($state =~ /^results/) {
|
||||
$state = 'results2';
|
||||
|
||||
# bug #10: some dyndns providers does not return the IP so
|
||||
# we can't use the returned IP
|
||||
my ($status, $returnedips) = split / /, lc $line;
|
||||
|
||||
for my $h (@hosts) {
|
||||
$config{$h}{'status-ipv4'} = $status if $ipv4;
|
||||
$config{$h}{'status-ipv6'} = $status if $ipv6;
|
||||
}
|
||||
|
||||
if ($status eq 'good') {
|
||||
for my $h (@hosts) {
|
||||
$config{$h}{'ipv4'} = $ipv4 if $ipv4;
|
||||
$config{$h}{'ipv6'} = $ipv6 if $ipv6;
|
||||
$config{$h}{'mtime'} = $now;
|
||||
}
|
||||
|
||||
success("updating %s: %s: IPv4 address set to %s", $hosts, $status, $ipv4) if $ipv4;
|
||||
success("updating %s: %s: IPv6 address set to %s", $hosts, $status, $ipv6) if $ipv6;
|
||||
|
||||
} elsif (exists $errors{$status}) {
|
||||
if ($status eq 'nochg') {
|
||||
warning("updating %s: %s: %s", $hosts, $status, $errors{$status});
|
||||
|
||||
for my $h (@hosts) {
|
||||
$config{$h}{'ipv4'} = $ipv4 if $ipv4;
|
||||
$config{$h}{'ipv6'} = $ipv6 if $ipv6;
|
||||
|
@ -4129,26 +4107,20 @@ sub nic_dyndns2_update {
|
|||
$config{$h}{'status-ipv4'} = 'good' if $ipv4;
|
||||
$config{$h}{'status-ipv6'} = 'good' if $ipv6;
|
||||
}
|
||||
|
||||
} else {
|
||||
failed("updating %s: %s: %s", $hosts, $status, $errors{$status});
|
||||
}
|
||||
|
||||
} elsif ($status =~ /w(\d+)(.)/) {
|
||||
my ($wait, $units) = ($1, lc $2);
|
||||
my ($sec, $scale) = ($wait, 1);
|
||||
|
||||
($scale, $units) = (1, 'seconds') if $units eq 's';
|
||||
($scale, $units) = (60, 'minutes') if $units eq 'm';
|
||||
($scale, $units) = (60*60, 'hours') if $units eq 'h';
|
||||
|
||||
$sec = $wait * $scale;
|
||||
for my $h (@hosts) {
|
||||
$config{$h}{'wtime'} = $now + $sec;
|
||||
}
|
||||
|
||||
warning("updating %s: %s: wait %s %s before further updates", $hosts, $status, $wait, $units);
|
||||
|
||||
} else {
|
||||
failed("updating %s: unexpected status (%s)", $hosts, $line);
|
||||
}
|
||||
|
@ -4319,9 +4291,7 @@ sub dnsexit2_update_host {
|
|||
######################################################################
|
||||
sub nic_noip_update {
|
||||
debug("\nnic_noip_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(login password server static custom wildcard mx backupmx wantipv4 wantipv6)]);
|
||||
|
||||
my %errors = (
|
||||
'badauth' => 'Invalid username or password',
|
||||
'badagent' => 'Invalid user agent',
|
||||
|
@ -4332,7 +4302,6 @@ sub nic_noip_update {
|
|||
'dnserr' => 'System error: DNS error encountered. Contact support@dyndns.org',
|
||||
'nochg' => 'No update required; unnecessary attempts to change to the current address are considered abusive',
|
||||
);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -4430,6 +4399,7 @@ sub nic_noip_update {
|
|||
if $state ne 'results2';
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_noip_examples
|
||||
######################################################################
|
||||
|
@ -4664,9 +4634,7 @@ sub nic_zoneedit1_force_update {
|
|||
######################################################################
|
||||
sub nic_zoneedit1_update {
|
||||
debug("\nnic_zoneedit1_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(login password server zone wantip)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -4730,6 +4698,7 @@ sub nic_zoneedit1_update {
|
|||
if @hosts;
|
||||
}
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_easydns_force_update
|
||||
######################################################################
|
||||
|
@ -4753,6 +4722,7 @@ sub nic_easydns_force_update {
|
|||
}
|
||||
return $update;
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_easydns_examples
|
||||
######################################################################
|
||||
|
@ -4797,21 +4767,19 @@ Example ${program}.conf file entries:
|
|||
my-toplevel-domain.com,my-other-domain.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_easydns_update
|
||||
######################################################################
|
||||
sub nic_easydns_update {
|
||||
debug("\nnic_easydns_update -------------------");
|
||||
|
||||
my %groups = map { $_ => [ $_ ] } @_;
|
||||
|
||||
my %errors = (
|
||||
'NOACCESS' => 'Authentication failed. This happens if the username/password OR host or domain are wrong.',
|
||||
'NOSERVICE' => 'Dynamic DNS is not turned on for this domain.',
|
||||
'ILLEGAL' => 'Client sent data that is not allowed in a dynamic DNS update.',
|
||||
'TOOSOON' => 'Update frequency is too short.',
|
||||
);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -5735,17 +5703,15 @@ Example ${program}.conf file entries:
|
|||
host1.example.com,host2.example.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_godaddy_update
|
||||
######################################################################
|
||||
sub nic_godaddy_update {
|
||||
debug("\nnic_godaddy_update --------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(server login password zone wantipv4 wantipv6)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
|
||||
for my $host (@hosts) {
|
||||
my $ipv4 = delete $config{$host}{'wantipv4'};
|
||||
my $ipv6 = delete $config{$host}{'wantipv6'};
|
||||
|
@ -5869,14 +5835,13 @@ Example ${program}.conf file entries:
|
|||
my-toplevel-domain.com,my-other-domain.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_googledomains_update
|
||||
######################################################################
|
||||
sub nic_googledomains_update {
|
||||
debug("\nnic_googledomains_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(server login password wantip)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $key = $hosts[0];
|
||||
|
@ -6049,9 +6014,7 @@ EoEXAMPLE
|
|||
######################################################################
|
||||
sub nic_nsupdate_update {
|
||||
debug("\nnic_nsupdate_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(login password server zone wantipv4 wantipv6)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -6159,19 +6122,17 @@ Example ${program}.conf file entries:
|
|||
my-toplevel-domain.com,my-other-domain.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_cloudflare_update
|
||||
######################################################################
|
||||
sub nic_cloudflare_update {
|
||||
debug("\nnic_cloudflare_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(ssh login password server wildcard mx backupmx zone wantipv4 wantipv6)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
my $key = $hosts[0];
|
||||
|
||||
my $headers = "Content-Type: application/json\n";
|
||||
if ($config{$key}{'login'} eq 'token') {
|
||||
$headers .= "Authorization: Bearer $config{$key}{'password'}\n";
|
||||
|
@ -6304,14 +6265,13 @@ Example ${program}.conf file entries:
|
|||
my-toplevel-domain.com,my-other-domain.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_hetzner_update
|
||||
######################################################################
|
||||
sub nic_hetzner_update {
|
||||
debug("\nnic_hetzner_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(ssh login password server wildcard mx backupmx zone wantipv4 wantipv6)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $hosts = join(',', @hosts);
|
||||
|
@ -6355,7 +6315,6 @@ sub nic_hetzner_update {
|
|||
}
|
||||
info("Zone ID is %s", $zone_id);
|
||||
|
||||
|
||||
# IPv4 and IPv6 handling are similar enough to do in a loop...
|
||||
for my $ip ($ipv4, $ipv6) {
|
||||
next if (!$ip);
|
||||
|
@ -6455,6 +6414,7 @@ Example ${program}.conf file entries:
|
|||
record.myhost.com,other.myhost.com
|
||||
EoEXAMPLE
|
||||
}
|
||||
|
||||
######################################################################
|
||||
## nic_yandex_update
|
||||
##
|
||||
|
@ -6463,9 +6423,7 @@ EoEXAMPLE
|
|||
######################################################################
|
||||
sub nic_yandex_update {
|
||||
debug("\nnic_yandex_update -------------------");
|
||||
|
||||
my %groups = group_hosts_by(\@_, [qw(server login pasword wantip)]);
|
||||
|
||||
for my $sig (keys %groups) {
|
||||
my @hosts = @{$groups{$sig}};
|
||||
my $key = $hosts[0];
|
||||
|
|
Loading…
Reference in a new issue