From 2a9abc9d4c2793fbdb972b50ed34126a680f60ec Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 15 Jun 2024 19:25:17 -0400 Subject: [PATCH 1/5] Delete unused `nic_easydns_force_update` function --- ddclient.in | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/ddclient.in b/ddclient.in index 0121397..4af3997 100755 --- a/ddclient.in +++ b/ddclient.in @@ -4675,30 +4675,6 @@ sub nic_zoneedit1_update { } } -###################################################################### -## nic_easydns_force_update -###################################################################### -sub nic_easydns_force_update { - my $host = shift; - my $update = 0; - - if ($config{$host}{'mx'} ne $recap{$host}{'mx'}) { - info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); - $update = 1; - - } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'}, 1, 2, 3) ne ynu($config{$host}{'backupmx'}, 1, 2, 3))) { - info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'}, "YES", "NO", "NO")); - $update = 1; - - } elsif ($config{$host}{'static'} ne $recap{$host}{'static'}) { - - info("forcing updating %s because 'static' has changed to %s.", $host, ynu($config{$host}{'static'}, "YES", "NO", "NO")); - $update = 1; - - } - return $update; -} - ###################################################################### ## nic_easydns_examples ###################################################################### From 5a8bee1e4dd5106e31c42b0d92926308313ae692 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 16 Jun 2024 17:13:54 -0400 Subject: [PATCH 2/5] Delete unnecessary `nic_dyndns2_force_update` The `nic_updateable` function already checks the variables to see if they have changed, so this function is redundant. --- ddclient.in | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/ddclient.in b/ddclient.in index 4af3997..ba1fdce 100755 --- a/ddclient.in +++ b/ddclient.in @@ -836,7 +836,7 @@ our %protocols = ( }, }, 'dyndns1' => { - 'force_update' => \&nic_dyndns2_force_update, + 'force_update' => undef, 'update' => \&nic_dyndns1_update, 'examples' => \&nic_dyndns1_examples, 'variables' => { @@ -846,7 +846,7 @@ our %protocols = ( }, }, 'dyndns2' => { - 'force_update' => \&nic_dyndns2_force_update, + 'force_update' => undef, 'update' => \&nic_dyndns2_update, 'examples' => \&nic_dyndns2_examples, 'variables' => { @@ -3932,29 +3932,7 @@ sub nic_dyndns1_update { } } } -###################################################################### -## nic_dyndns2_force_update -###################################################################### -sub nic_dyndns2_force_update { - my $host = shift; - my $update = 0; - if ($config{$host}{'mx'} ne $recap{$host}{'mx'}) { - info("forcing updating %s because 'mx' has changed to %s.", $host, $config{$host}{'mx'}); - $update = 1; - - } elsif ($config{$host}{'mx'} && (ynu($config{$host}{'backupmx'}, 1, 2, 3) ne ynu($recap{$host}{'backupmx'}, 1, 2, 3))) { - info("forcing updating %s because 'backupmx' has changed to %s.", $host, ynu($config{$host}{'backupmx'}, "YES", "NO", "NO")); - $update = 1; - - } elsif ($config{$host}{'static'} ne $recap{$host}{'static'}) { - - info("forcing updating %s because 'static' has changed to %s.", $host, ynu($config{$host}{'static'}, "YES", "NO", "NO")); - $update = 1; - - } - return $update; -} ###################################################################### ## nic_dyndns2_examples ###################################################################### From 0ffffb140075dc3a35a33c52b9725609572de762 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 18 Jun 2024 02:16:45 -0400 Subject: [PATCH 3/5] Delete unnecessary `force_update => undef` lines --- ddclient.in | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/ddclient.in b/ddclient.in index ba1fdce..dc2daab 100755 --- a/ddclient.in +++ b/ddclient.in @@ -709,7 +709,6 @@ our %variables = ( ); our %protocols = ( '1984' => { - 'force_update' => undef, 'update' => \&nic_1984_update, 'examples' => \&nic_1984_examples, 'variables' => { @@ -719,7 +718,6 @@ our %protocols = ( }, }, 'changeip' => { - 'force_update' => undef, 'update' => \&nic_changeip_update, 'examples' => \&nic_changeip_examples, 'variables' => { @@ -729,7 +727,6 @@ our %protocols = ( }, }, 'cloudflare' => { - 'force_update' => undef, 'update' => \&nic_cloudflare_update, 'examples' => \&nic_cloudflare_examples, 'variables' => { @@ -746,7 +743,6 @@ our %protocols = ( }, }, 'cloudns' => { - 'force_update' => undef, 'update' => \&nic_cloudns_update, 'examples' => \&nic_cloudns_examples, 'variables' => { @@ -757,7 +753,6 @@ our %protocols = ( }, }, 'ddns.fm' => { - 'force_update' => undef, 'update' => \&nic_ddnsfm_update, 'examples' => \&nic_ddnsfm_examples, 'variables' => { @@ -767,7 +762,6 @@ our %protocols = ( }, }, 'digitalocean' => { - 'force_update' => undef, 'update' => \&nic_digitalocean_update, 'examples' => \&nic_digitalocean_examples, 'variables' => { @@ -778,7 +772,6 @@ our %protocols = ( }, }, 'dinahosting' => { - 'force_update' => undef, 'update' => \&nic_dinahosting_update, 'examples' => \&nic_dinahosting_examples, 'variables' => { @@ -789,7 +782,6 @@ our %protocols = ( }, }, 'dnsmadeeasy' => { - 'force_update' => undef, 'update' => \&nic_dnsmadeeasy_update, 'examples' => \&nic_dnsmadeeasy_examples, 'variables' => { @@ -799,7 +791,6 @@ our %protocols = ( }, }, 'dondominio' => { - 'force_update' => undef, 'update' => \&nic_dondominio_update, 'examples' => \&nic_dondominio_examples, 'variables' => { @@ -808,7 +799,6 @@ our %protocols = ( }, }, 'dslreports1' => { - 'force_update' => undef, 'update' => \&nic_dslreports1_update, 'examples' => \&nic_dslreports1_examples, 'variables' => { @@ -817,7 +807,6 @@ our %protocols = ( }, }, 'domeneshop' => { - 'force_update' => undef, 'update' => \&nic_domeneshop_update, 'examples' => \&nic_domeneshop_examples, 'variables' => { @@ -826,7 +815,6 @@ our %protocols = ( }, }, 'duckdns' => { - 'force_update' => undef, 'update' => \&nic_duckdns_update, 'examples' => \&nic_duckdns_examples, 'variables' => { @@ -836,7 +824,6 @@ our %protocols = ( }, }, 'dyndns1' => { - 'force_update' => undef, 'update' => \&nic_dyndns1_update, 'examples' => \&nic_dyndns1_examples, 'variables' => { @@ -846,7 +833,6 @@ our %protocols = ( }, }, 'dyndns2' => { - 'force_update' => undef, 'update' => \&nic_dyndns2_update, 'examples' => \&nic_dyndns2_examples, 'variables' => { @@ -856,7 +842,6 @@ our %protocols = ( }, }, 'easydns' => { - 'force_update' => undef, 'update' => \&nic_easydns_update, 'examples' => \&nic_easydns_examples, 'variables' => { @@ -872,7 +857,6 @@ our %protocols = ( }, }, 'freedns' => { - 'force_update' => undef, 'update' => \&nic_freedns_update, 'examples' => \&nic_freedns_examples, 'variables' => { @@ -882,7 +866,6 @@ our %protocols = ( }, }, 'freemyip' => { - 'force_update' => undef, 'update' => \&nic_freemyip_update, 'examples' => \&nic_freemyip_examples, 'variables' => { @@ -892,7 +875,6 @@ our %protocols = ( }, }, 'gandi' => { - 'force_update' => undef, 'update' => \&nic_gandi_update, 'examples' => \&nic_gandi_examples, 'variables' => { @@ -907,7 +889,6 @@ our %protocols = ( } }, 'godaddy' => { - 'force_update' => undef, 'update' => \&nic_godaddy_update, 'examples' => \&nic_godaddy_examples, 'variables' => { @@ -919,7 +900,6 @@ our %protocols = ( }, }, 'he.net' => { - 'updateable' => undef, 'update' => \&nic_henet_update, 'examples' => \&nic_henet_examples, 'variables' => { @@ -930,7 +910,6 @@ our %protocols = ( }, }, 'hetzner' => { - 'force_update' => undef, 'update' => \&nic_hetzner_update, 'examples' => \&nic_hetzner_examples, 'variables' => { @@ -943,7 +922,6 @@ our %protocols = ( }, }, 'inwx' => { - 'force_update' => undef, 'update' => \&nic_inwx_update, 'examples' => \&nic_inwx_examples, 'variables' => { @@ -953,7 +931,6 @@ our %protocols = ( }, }, 'mythicdyn' => { - 'force_update' => undef, 'update' => \&nic_mythicdyn_update, 'examples' => \&nic_mythicdyn_examples, 'variables' => { @@ -963,7 +940,6 @@ our %protocols = ( }, }, 'namecheap' => { - 'force_update' => undef, 'update' => \&nic_namecheap_update, 'examples' => \&nic_namecheap_examples, 'variables' => { @@ -973,7 +949,6 @@ our %protocols = ( }, }, 'nfsn' => { - 'force_update' => undef, 'update' => \&nic_nfsn_update, 'examples' => \&nic_nfsn_examples, 'variables' => { @@ -985,7 +960,6 @@ our %protocols = ( }, }, 'njalla' => { - 'force_update' => undef, 'update' => \&nic_njalla_update, 'examples' => \&nic_njalla_examples, 'variables' => { @@ -996,7 +970,6 @@ our %protocols = ( }, }, 'noip' => { - 'force_update' => undef, 'update' => \&nic_noip_update, 'examples' => \&nic_noip_examples, 'variables' => { @@ -1005,7 +978,6 @@ our %protocols = ( }, }, 'nsupdate' => { - 'force_update' => undef, 'update' => \&nic_nsupdate_update, 'examples' => \&nic_nsupdate_examples, 'variables' => { @@ -1017,7 +989,6 @@ our %protocols = ( }, }, 'ovh' => { - 'force_update' => undef, 'update' => \&nic_ovh_update, 'examples' => \&nic_ovh_examples, 'variables' => { @@ -1027,7 +998,6 @@ our %protocols = ( }, }, 'porkbun' => { - 'force_update' => undef, 'update' => \&nic_porkbun_update, 'examples' => \&nic_porkbun_examples, 'variables' => { @@ -1041,7 +1011,6 @@ our %protocols = ( }, }, 'sitelutions' => { - 'force_update' => undef, 'update' => \&nic_sitelutions_update, 'examples' => \&nic_sitelutions_examples, 'variables' => { @@ -1051,7 +1020,6 @@ our %protocols = ( }, }, 'yandex' => { - 'force_update' => undef, 'update' => \&nic_yandex_update, 'examples' => \&nic_yandex_examples, 'variables' => { @@ -1061,7 +1029,6 @@ our %protocols = ( }, }, 'zoneedit1' => { - 'force_update' => undef, 'update' => \&nic_zoneedit1_update, 'examples' => \&nic_zoneedit1_examples, 'variables' => { @@ -1072,7 +1039,6 @@ our %protocols = ( }, }, 'keysystems' => { - 'force_update' => undef, 'update' => \&nic_keysystems_update, 'examples' => \&nic_keysystems_examples, 'variables' => { @@ -1082,7 +1048,6 @@ our %protocols = ( }, }, 'dnsexit2' => { - 'force_update' => undef, 'update' => \&nic_dnsexit2_update, 'examples' => \&nic_dnsexit2_examples, 'variables' => { @@ -1096,7 +1061,6 @@ our %protocols = ( }, }, 'regfishde' => { - 'force_update' => undef, 'update' => \&nic_regfishde_update, 'examples' => \&nic_regfishde_examples, 'variables' => { @@ -1106,7 +1070,6 @@ our %protocols = ( }, }, 'enom' => { - 'force_update' => undef, 'update' => \&nic_enom_update, 'examples' => \&nic_enom_examples, 'variables' => { @@ -1116,7 +1079,6 @@ our %protocols = ( }, }, 'infomaniak' => { - 'force_update' => undef, 'update' => \&nic_infomaniak_update, 'examples' => \&nic_infomaniak_examples, 'variables' => { @@ -1125,7 +1087,6 @@ our %protocols = ( }, }, 'emailonly' => { - 'force_update' => undef, 'update' => \&nic_emailonly_update, 'examples' => \&nic_emailonly_examples, 'variables' => { From 38a4e9eeef4916fdfd14974f0d896668650db1bd Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 26 Jul 2024 17:23:21 -0400 Subject: [PATCH 4/5] nic_updateable: Remove unnecessary `force_update` parameter `nic_updateable` can look up the host's `force_update` function itself so there's no need to pass it as an argument. --- ddclient.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ddclient.in b/ddclient.in index dc2daab..5c73b46 100755 --- a/ddclient.in +++ b/ddclient.in @@ -1366,7 +1366,6 @@ sub update_nics { for my $p (sort keys %protocols) { my (@hosts, %ipsv4, %ipsv6) = (); - my $force_update = $protocols{$p}{'force_update'}; my $update = $protocols{$p}{'update'}; for my $h (sort keys %config) { @@ -1461,7 +1460,7 @@ sub update_nics { next; } - next if !nic_updateable($h, $force_update); + next if !nic_updateable($h); push @hosts, $h; $ipsv4{$ipv4} = $h if ($ipv4); @@ -3527,8 +3526,8 @@ EoEXAMPLE ## Returns true if we can go ahead and update the IP address at server ###################################################################### sub nic_updateable { - my $host = shift; - my $sub = shift; + my ($host) = @_; + my $force_update = $protocols{$config{$host}{protocol}}{force_update}; my $update = 0; my $ip = $config{$host}{'wantip'}; my $ipv4 = $config{$host}{'wantipv4'}; @@ -3708,7 +3707,7 @@ sub nic_updateable { $update = 1; } - } elsif (defined($sub) && &$sub($host)) { + } elsif (defined($force_update) && $force_update->($host)) { $update = 1; } elsif ((defined($recap{$host}{'static'}) && defined($config{$host}{'static'}) && ($recap{$host}{'static'} ne $config{$host}{'static'})) || From 89d7193f692edfeab442e260cadb5c874305993b Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 26 Jul 2024 18:15:21 -0400 Subject: [PATCH 5/5] nic_updateable: Simplify option changed detection logic --- ddclient.in | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ddclient.in b/ddclient.in index 5c73b46..c7c58a4 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3709,15 +3709,10 @@ sub nic_updateable { } elsif (defined($force_update) && $force_update->($host)) { $update = 1; - } elsif ((defined($recap{$host}{'static'}) && defined($config{$host}{'static'}) && - ($recap{$host}{'static'} ne $config{$host}{'static'})) || - (defined($recap{$host}{'wildcard'}) && defined($config{$host}{'wildcard'}) && - ($recap{$host}{'wildcard'} ne $config{$host}{'wildcard'})) || - (defined($recap{$host}{'mx'}) && defined($config{$host}{'mx'}) && - ($recap{$host}{'mx'} ne $config{$host}{'mx'})) || - (defined($recap{$host}{'backupmx'}) && defined($config{$host}{'backupmx'}) && - ($recap{$host}{'backupmx'} ne $config{$host}{'backupmx'}))) { - info("updating %s because host settings have been changed.", $host); + } elsif (my @changed = grep({ my $rv = $recap{$host}{$_}; my $cv = $config{$host}{$_}; + defined($rv) && defined($cv) && $rv ne $cv; } + qw(static wildcard mx backupmx))) { + info("$host: update forced because options changed: " . join(', ', @changed)); $update = 1; } else {