From 53b373fc9e71c090e506a5810f31030612ec232a Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 19 Jul 2024 16:08:41 -0400 Subject: [PATCH 01/12] godaddy: Delete unnecessary comments --- ddclient.in | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ddclient.in b/ddclient.in index ba2eeea..dd5fb12 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5781,7 +5781,7 @@ sub nic_godaddy_update { (my $code) = ($reply =~ m%^s*HTTP/.*\s+(\d+)%i); my $ok = header_ok($host, $reply); my $msg; - $reply =~ s/^.*?\n\n//s; # extract payload + $reply =~ s/^.*?\n\n//s; my $response = eval {decode_json($reply)}; if (!defined($response) && $code != "200") { $$status = "bad"; @@ -5791,7 +5791,6 @@ sub nic_godaddy_update { info("%s.%s -- %s - %s.", $hostname, $zone, $response->{code}, $response->{message}); } if ($ok) { - # read data $config{$host}{"ipv$ipversion"} = $ip; $config{$host}{'mtime'} = $now; $$status = 'good'; @@ -5800,7 +5799,7 @@ sub nic_godaddy_update { next; } elsif ($code == "400") { $msg = 'GoDaddy API URL ($url) was malformed.'; - } elsif ($code == "401") { # authentication error + } elsif ($code == "401") { if ($config{$host}{'login'} && $config{$host}{'login'}) { $msg = 'login or password option incorrect.'; } else { From f82d2af0f262611064150c0f321bbab1bb7e390e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 02:03:50 -0400 Subject: [PATCH 02/12] godaddy: Whitespace fixes --- ddclient.in | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/ddclient.in b/ddclient.in index dd5fb12..884c64d 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5740,29 +5740,23 @@ sub nic_godaddy_update { for my $host (@_) { my $ipv4 = delete $config{$host}{'wantipv4'}; my $ipv6 = delete $config{$host}{'wantipv6'}; - my $zone = $config{$host}{'zone'}; (my $hostname = $host) =~ s/\.\Q$zone\E$//; - for my $ip ($ipv4, $ipv6) { next if (!$ip); - info("%s.%s -- Setting IP address to %s.", $hostname, $zone, $ip); verbose("UPDATE:", "updating %s.%s", $hostname, $zone); - my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4'; my $status = \$config{$host}{"status-ipv$ipversion"}; my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A'; - my $data = encode_json([ { + my $data = encode_json([{ data => $ip, defined($config{$host}{'ttl'}) ? (ttl => $config{$host}{'ttl'}) : (), name => $hostname, type => $rrset_type, - } ]); - + }]); my $url = "https://$config{$host}{'server'}"; $url .= "/${zone}/records/${rrset_type}/${hostname}"; - my $header = "Content-Type: application/json\n"; $header .= "Accept: application/json\n"; $header .= "Authorization: sso-key $config{$host}{'login'}:$config{$host}{'password'}\n"; @@ -5777,7 +5771,6 @@ sub nic_godaddy_update { failed("%s.%s -- Could not connect to %s.", $hostname, $zone, $config{$host}{'server'}); next; } - (my $code) = ($reply =~ m%^s*HTTP/.*\s+(\d+)%i); my $ok = header_ok($host, $reply); my $msg; @@ -5785,7 +5778,6 @@ sub nic_godaddy_update { my $response = eval {decode_json($reply)}; if (!defined($response) && $code != "200") { $$status = "bad"; - failed("%s.%s -- Unexpected or empty service response, cannot parse data.", $hostname, $zone); } elsif (defined($response->{code})) { info("%s.%s -- %s - %s.", $hostname, $zone, $response->{code}, $response->{message}); @@ -5794,7 +5786,6 @@ sub nic_godaddy_update { $config{$host}{"ipv$ipversion"} = $ip; $config{$host}{'mtime'} = $now; $$status = 'good'; - success("%s.%s -- Updated successfully to %s (status: %s).", $hostname, $zone, $ip, $code); next; } elsif ($code == "400") { @@ -5819,7 +5810,6 @@ sub nic_godaddy_update { } else { $msg = 'Unexpected service response.'; } - $$status = 'bad'; failed("%s.%s -- %s", $hostname, $zone, $msg); } From c63eb0f0603bd44fe74cc3a529f248b766cb98c0 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 18 May 2024 01:00:19 -0400 Subject: [PATCH 03/12] godaddy: Fix dubious response body check It doesn't make sense to continue processing if the response body can't be parsed. Maybe GoDaddy returned 200 and there's a bug in the body parsing logic, in which case the `bad` result should actually be `good`. But it's better to assume that the update wasn't saved, in case the server returns 200 with a JSON object that semantically means "failed to update". --- ddclient.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 884c64d..afb2e89 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5776,9 +5776,10 @@ sub nic_godaddy_update { my $msg; $reply =~ s/^.*?\n\n//s; my $response = eval {decode_json($reply)}; - if (!defined($response) && $code != "200") { + if (!defined($response)) { $$status = "bad"; failed("%s.%s -- Unexpected or empty service response, cannot parse data.", $hostname, $zone); + next; } elsif (defined($response->{code})) { info("%s.%s -- %s - %s.", $hostname, $zone, $response->{code}, $response->{message}); } From e01ed55a580c9a478490e33851db9c803979f273 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 00:35:09 -0400 Subject: [PATCH 04/12] godaddy: Simplify and improve error messages --- ddclient.in | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ddclient.in b/ddclient.in index afb2e89..be3231c 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5744,9 +5744,8 @@ sub nic_godaddy_update { (my $hostname = $host) =~ s/\.\Q$zone\E$//; for my $ip ($ipv4, $ipv6) { next if (!$ip); - info("%s.%s -- Setting IP address to %s.", $hostname, $zone, $ip); - verbose("UPDATE:", "updating %s.%s", $hostname, $zone); my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4'; + info("$host: Setting IPv$ipversion address to $ip"); my $status = \$config{$host}{"status-ipv$ipversion"}; my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A'; my $data = encode_json([{ @@ -5768,7 +5767,7 @@ sub nic_godaddy_update { data => $data, ); unless ($reply) { - failed("%s.%s -- Could not connect to %s.", $hostname, $zone, $config{$host}{'server'}); + failed("$host: Could not connect to $config{$host}{'server'}"); next; } (my $code) = ($reply =~ m%^s*HTTP/.*\s+(\d+)%i); @@ -5778,16 +5777,16 @@ sub nic_godaddy_update { my $response = eval {decode_json($reply)}; if (!defined($response)) { $$status = "bad"; - failed("%s.%s -- Unexpected or empty service response, cannot parse data.", $hostname, $zone); + failed("$host: Unexpected or empty service response, cannot parse data"); next; } elsif (defined($response->{code})) { - info("%s.%s -- %s - %s.", $hostname, $zone, $response->{code}, $response->{message}); + info("$host: $response->{code} - $response->{message}"); } if ($ok) { $config{$host}{"ipv$ipversion"} = $ip; $config{$host}{'mtime'} = $now; $$status = 'good'; - success("%s.%s -- Updated successfully to %s (status: %s).", $hostname, $zone, $ip, $code); + success("$host: Updated successfully to $ip (status: $code)"); next; } elsif ($code == "400") { $msg = 'GoDaddy API URL ($url) was malformed.'; @@ -5801,18 +5800,18 @@ sub nic_godaddy_update { } elsif ($code == "403") { $msg = 'Customer identified by login and password options denied permission.'; } elsif ($code == "404") { - $msg = "\"${hostname}.${zone}\" not found at GoDaddy, please check zone option and login/password."; + $msg = "\"$host\" not found at GoDaddy, please check zone option and login/password."; } elsif ($code == "422") { - $msg = "\"${hostname}.${zone}\" has invalid domain or lacks A/AAAA record."; + $msg = "\"$host\" has invalid domain or lacks A/AAAA record."; } elsif ($code == "429") { $msg = 'Too many requests to GoDaddy within brief period.'; } elsif ($code == "503") { - $msg = "\"${hostname}.${zone}\" is unavailable."; + $msg = "\"$host\" is unavailable."; } else { $msg = 'Unexpected service response.'; } $$status = 'bad'; - failed("%s.%s -- %s", $hostname, $zone, $msg); + failed("$host: $msg"); } } } From 56f4a2afe22b7ad9837c4033fdb3288a5165ad7d Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 01:00:21 -0400 Subject: [PATCH 05/12] godaddy: Don't bother setting status on error It's initialized to a non-'good' value before the function is called, and ddclient doesn't distinguish between different non-good values, so it is sufficient to leave it alone. --- ddclient.in | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ddclient.in b/ddclient.in index be3231c..4ad1361 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5746,7 +5746,6 @@ sub nic_godaddy_update { next if (!$ip); my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4'; info("$host: Setting IPv$ipversion address to $ip"); - my $status = \$config{$host}{"status-ipv$ipversion"}; my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A'; my $data = encode_json([{ data => $ip, @@ -5776,7 +5775,6 @@ sub nic_godaddy_update { $reply =~ s/^.*?\n\n//s; my $response = eval {decode_json($reply)}; if (!defined($response)) { - $$status = "bad"; failed("$host: Unexpected or empty service response, cannot parse data"); next; } elsif (defined($response->{code})) { @@ -5785,7 +5783,7 @@ sub nic_godaddy_update { if ($ok) { $config{$host}{"ipv$ipversion"} = $ip; $config{$host}{'mtime'} = $now; - $$status = 'good'; + $config{$host}{"status-ipv$ipversion"} = 'good'; success("$host: Updated successfully to $ip (status: $code)"); next; } elsif ($code == "400") { @@ -5810,7 +5808,6 @@ sub nic_godaddy_update { } else { $msg = 'Unexpected service response.'; } - $$status = 'bad'; failed("$host: $msg"); } } From 3258ea34c0b2c8ec1216a3bd245e2f19dbb968cc Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 01:16:49 -0400 Subject: [PATCH 06/12] godaddy: Shorten variables for brevity and consistency --- ddclient.in | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/ddclient.in b/ddclient.in index 4ad1361..7feafa5 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5737,27 +5737,27 @@ EoEXAMPLE ###################################################################### sub nic_godaddy_update { debug("\nnic_godaddy_update --------------------"); - for my $host (@_) { - my $ipv4 = delete $config{$host}{'wantipv4'}; - my $ipv6 = delete $config{$host}{'wantipv6'}; - my $zone = $config{$host}{'zone'}; - (my $hostname = $host) =~ s/\.\Q$zone\E$//; + for my $h (@_) { + my $ipv4 = delete $config{$h}{'wantipv4'}; + my $ipv6 = delete $config{$h}{'wantipv6'}; + my $zone = $config{$h}{'zone'}; + (my $hostname = $h) =~ s/\.\Q$zone\E$//; for my $ip ($ipv4, $ipv6) { next if (!$ip); - my $ipversion = ($ip eq ($ipv6 // '')) ? '6' : '4'; - info("$host: Setting IPv$ipversion address to $ip"); - my $rrset_type = ($ipversion eq '6') ? 'AAAA' : 'A'; + my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4'; + info("$h: Setting IPv$ipv address to $ip"); + my $rrset_type = ($ipv eq '6') ? 'AAAA' : 'A'; my $data = encode_json([{ data => $ip, - defined($config{$host}{'ttl'}) ? (ttl => $config{$host}{'ttl'}) : (), + defined($config{$h}{'ttl'}) ? (ttl => $config{$h}{'ttl'}) : (), name => $hostname, type => $rrset_type, }]); - my $url = "https://$config{$host}{'server'}"; + my $url = "https://$config{$h}{'server'}"; $url .= "/${zone}/records/${rrset_type}/${hostname}"; my $header = "Content-Type: application/json\n"; $header .= "Accept: application/json\n"; - $header .= "Authorization: sso-key $config{$host}{'login'}:$config{$host}{'password'}\n"; + $header .= "Authorization: sso-key $config{$h}{'login'}:$config{$h}{'password'}\n"; my $reply = geturl( proxy => opt('proxy'), url => $url, @@ -5766,30 +5766,30 @@ sub nic_godaddy_update { data => $data, ); unless ($reply) { - failed("$host: Could not connect to $config{$host}{'server'}"); + failed("$h: Could not connect to $config{$h}{'server'}"); next; } (my $code) = ($reply =~ m%^s*HTTP/.*\s+(\d+)%i); - my $ok = header_ok($host, $reply); + my $ok = header_ok($h, $reply); my $msg; $reply =~ s/^.*?\n\n//s; my $response = eval {decode_json($reply)}; if (!defined($response)) { - failed("$host: Unexpected or empty service response, cannot parse data"); + failed("$h: Unexpected or empty service response, cannot parse data"); next; } elsif (defined($response->{code})) { - info("$host: $response->{code} - $response->{message}"); + info("$h: $response->{code} - $response->{message}"); } if ($ok) { - $config{$host}{"ipv$ipversion"} = $ip; - $config{$host}{'mtime'} = $now; - $config{$host}{"status-ipv$ipversion"} = 'good'; - success("$host: Updated successfully to $ip (status: $code)"); + $config{$h}{"ipv$ipv"} = $ip; + $config{$h}{'mtime'} = $now; + $config{$h}{"status-ipv$ipv"} = 'good'; + success("$h: Updated successfully to $ip (status: $code)"); next; } elsif ($code == "400") { $msg = 'GoDaddy API URL ($url) was malformed.'; } elsif ($code == "401") { - if ($config{$host}{'login'} && $config{$host}{'login'}) { + if ($config{$h}{'login'} && $config{$h}{'login'}) { $msg = 'login or password option incorrect.'; } else { $msg = 'login or password option missing.'; @@ -5798,17 +5798,17 @@ sub nic_godaddy_update { } elsif ($code == "403") { $msg = 'Customer identified by login and password options denied permission.'; } elsif ($code == "404") { - $msg = "\"$host\" not found at GoDaddy, please check zone option and login/password."; + $msg = "\"$h\" not found at GoDaddy, please check zone option and login/password."; } elsif ($code == "422") { - $msg = "\"$host\" has invalid domain or lacks A/AAAA record."; + $msg = "\"$h\" has invalid domain or lacks A/AAAA record."; } elsif ($code == "429") { $msg = 'Too many requests to GoDaddy within brief period.'; } elsif ($code == "503") { - $msg = "\"$host\" is unavailable."; + $msg = "\"$h\" is unavailable."; } else { $msg = 'Unexpected service response.'; } - failed("$host: $msg"); + failed("$h: $msg"); } } } From b1c00296042701a1a96f264ef7504a4bf26cdbe8 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 01:20:08 -0400 Subject: [PATCH 07/12] godaddy: Simplify `for` loop --- ddclient.in | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ddclient.in b/ddclient.in index 7feafa5..0b9883f 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5738,13 +5738,10 @@ EoEXAMPLE sub nic_godaddy_update { debug("\nnic_godaddy_update --------------------"); for my $h (@_) { - my $ipv4 = delete $config{$h}{'wantipv4'}; - my $ipv6 = delete $config{$h}{'wantipv6'}; my $zone = $config{$h}{'zone'}; (my $hostname = $h) =~ s/\.\Q$zone\E$//; - for my $ip ($ipv4, $ipv6) { - next if (!$ip); - my $ipv = ($ip eq ($ipv6 // '')) ? '6' : '4'; + for my $ipv ('4', '6') { + my $ip = delete($config{$h}{"wantipv$ipv"}) or next; info("$h: Setting IPv$ipv address to $ip"); my $rrset_type = ($ipv eq '6') ? 'AAAA' : 'A'; my $data = encode_json([{ From 6e98c0cdb2148fff63fb991407a6d900cf4c9006 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 01:37:04 -0400 Subject: [PATCH 08/12] godaddy: Invert conditional to improve readability --- ddclient.in | 55 +++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/ddclient.in b/ddclient.in index 0b9883f..087e6c2 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5768,7 +5768,6 @@ sub nic_godaddy_update { } (my $code) = ($reply =~ m%^s*HTTP/.*\s+(\d+)%i); my $ok = header_ok($h, $reply); - my $msg; $reply =~ s/^.*?\n\n//s; my $response = eval {decode_json($reply)}; if (!defined($response)) { @@ -5777,35 +5776,37 @@ sub nic_godaddy_update { } elsif (defined($response->{code})) { info("$h: $response->{code} - $response->{message}"); } - if ($ok) { - $config{$h}{"ipv$ipv"} = $ip; - $config{$h}{'mtime'} = $now; - $config{$h}{"status-ipv$ipv"} = 'good'; - success("$h: Updated successfully to $ip (status: $code)"); - next; - } elsif ($code == "400") { - $msg = 'GoDaddy API URL ($url) was malformed.'; - } elsif ($code == "401") { - if ($config{$h}{'login'} && $config{$h}{'login'}) { - $msg = 'login or password option incorrect.'; + if (!$ok) { + my $msg; + if ($code == "400") { + $msg = 'GoDaddy API URL ($url) was malformed.'; + } elsif ($code == "401") { + if ($config{$h}{'login'} && $config{$h}{'login'}) { + $msg = 'login or password option incorrect.'; + } else { + $msg = 'login or password option missing.'; + } + $msg .= ' Correct values can be obtained from from https://developer.godaddy.com/keys/.'; + } elsif ($code == "403") { + $msg = 'Customer identified by login and password options denied permission.'; + } elsif ($code == "404") { + $msg = "\"$h\" not found at GoDaddy, please check zone option and login/password."; + } elsif ($code == "422") { + $msg = "\"$h\" has invalid domain or lacks A/AAAA record."; + } elsif ($code == "429") { + $msg = 'Too many requests to GoDaddy within brief period.'; + } elsif ($code == "503") { + $msg = "\"$h\" is unavailable."; } else { - $msg = 'login or password option missing.'; + $msg = 'Unexpected service response.'; } - $msg .= ' Correct values can be obtained from from https://developer.godaddy.com/keys/.'; - } elsif ($code == "403") { - $msg = 'Customer identified by login and password options denied permission.'; - } elsif ($code == "404") { - $msg = "\"$h\" not found at GoDaddy, please check zone option and login/password."; - } elsif ($code == "422") { - $msg = "\"$h\" has invalid domain or lacks A/AAAA record."; - } elsif ($code == "429") { - $msg = 'Too many requests to GoDaddy within brief period.'; - } elsif ($code == "503") { - $msg = "\"$h\" is unavailable."; - } else { - $msg = 'Unexpected service response.'; + failed("$h: $msg"); + next; } - failed("$h: $msg"); + $config{$h}{"ipv$ipv"} = $ip; + $config{$h}{'mtime'} = $now; + $config{$h}{"status-ipv$ipv"} = 'good'; + success("$h: Updated successfully to $ip (status: $code)"); } } } From 4b2155a43c88c1953b2eb2f7b200e308885e6d52 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 02:00:30 -0400 Subject: [PATCH 09/12] godaddy: Combine URL lines to improve readability Also drop unnecessary curly braces for consistency. --- ddclient.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ddclient.in b/ddclient.in index 087e6c2..a9e3004 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5750,8 +5750,7 @@ sub nic_godaddy_update { name => $hostname, type => $rrset_type, }]); - my $url = "https://$config{$h}{'server'}"; - $url .= "/${zone}/records/${rrset_type}/${hostname}"; + my $url = "https://$config{$h}{'server'}/$zone/records/$rrset_type/$hostname"; my $header = "Content-Type: application/json\n"; $header .= "Accept: application/json\n"; $header .= "Authorization: sso-key $config{$h}{'login'}:$config{$h}{'password'}\n"; From b9144c01c2c8d4b965e203b7dc08921b0608bae8 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 03:02:31 -0400 Subject: [PATCH 10/12] godaddy: Use `eq` for string equality `==` is for numeric equality. --- ddclient.in | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ddclient.in b/ddclient.in index a9e3004..82c9b52 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5777,24 +5777,24 @@ sub nic_godaddy_update { } if (!$ok) { my $msg; - if ($code == "400") { + if ($code eq "400") { $msg = 'GoDaddy API URL ($url) was malformed.'; - } elsif ($code == "401") { + } elsif ($code eq "401") { if ($config{$h}{'login'} && $config{$h}{'login'}) { $msg = 'login or password option incorrect.'; } else { $msg = 'login or password option missing.'; } $msg .= ' Correct values can be obtained from from https://developer.godaddy.com/keys/.'; - } elsif ($code == "403") { + } elsif ($code eq "403") { $msg = 'Customer identified by login and password options denied permission.'; - } elsif ($code == "404") { + } elsif ($code eq "404") { $msg = "\"$h\" not found at GoDaddy, please check zone option and login/password."; - } elsif ($code == "422") { + } elsif ($code eq "422") { $msg = "\"$h\" has invalid domain or lacks A/AAAA record."; - } elsif ($code == "429") { + } elsif ($code eq "429") { $msg = 'Too many requests to GoDaddy within brief period.'; - } elsif ($code == "503") { + } elsif ($code eq "503") { $msg = "\"$h\" is unavailable."; } else { $msg = 'Unexpected service response.'; From bdc69d879f5c9d45d08f3cc5aaee982f54b2da15 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 02:19:22 -0400 Subject: [PATCH 11/12] geturl: Accept an arrayref for headers --- ddclient.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddclient.in b/ddclient.in index 82c9b52..2822677 100755 --- a/ddclient.in +++ b/ddclient.in @@ -2873,7 +2873,7 @@ sub geturl { push(@curlopt, "url=\"".escape_curl_param("${protocol}://${server}/${url}").'"'); # Each header line is added individually - @header_lines = split('\n', $headers); + @header_lines = ref($headers) eq 'ARRAY' ? @$headers : split('\n', $headers); $_ = "header=\"".escape_curl_param($_).'"' for (@header_lines); push(@curlopt, @header_lines); From 12b2c0d03dedb30e740dad2b81986d9088da4ce5 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 7 Jun 2024 02:32:30 -0400 Subject: [PATCH 12/12] godaddy: Inline some unnecessary variables --- ddclient.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ddclient.in b/ddclient.in index 2822677..cd59f97 100755 --- a/ddclient.in +++ b/ddclient.in @@ -5744,22 +5744,22 @@ sub nic_godaddy_update { my $ip = delete($config{$h}{"wantipv$ipv"}) or next; info("$h: Setting IPv$ipv address to $ip"); my $rrset_type = ($ipv eq '6') ? 'AAAA' : 'A'; - my $data = encode_json([{ - data => $ip, - defined($config{$h}{'ttl'}) ? (ttl => $config{$h}{'ttl'}) : (), - name => $hostname, - type => $rrset_type, - }]); my $url = "https://$config{$h}{'server'}/$zone/records/$rrset_type/$hostname"; - my $header = "Content-Type: application/json\n"; - $header .= "Accept: application/json\n"; - $header .= "Authorization: sso-key $config{$h}{'login'}:$config{$h}{'password'}\n"; my $reply = geturl( proxy => opt('proxy'), url => $url, - headers => $header, + headers => [ + 'Content-Type: application/json', + 'Accept: application/json', + "Authorization: sso-key $config{$h}{'login'}:$config{$h}{'password'}", + ], method => 'PUT', - data => $data, + data => encode_json([{ + data => $ip, + defined($config{$h}{'ttl'}) ? (ttl => $config{$h}{'ttl'}) : (), + name => $hostname, + type => $rrset_type, + }]), ); unless ($reply) { failed("$h: Could not connect to $config{$h}{'server'}");