Whitespace fixes

This commit is contained in:
Richard Hansen 2024-07-12 15:54:01 -04:00
parent b488cb2235
commit 161c623557

View file

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