1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
From 3a224b66a4fa5758427dfe131a33e6337eebeff7 Mon Sep 17 00:00:00 2001
From: Indrajit Raychaudhuri <irc@indrajit.com>
Date: Thu, 2 Nov 2023 18:56:31 -0500
Subject: [PATCH] duckdns: Adjust script to support simultaneous IPv4 and IPv6
updates
Ref: ddclient/ddclient#588
---
ddclient.in | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/ddclient.in b/ddclient.in
index f38db33f..1d8a16a2 100755
--- a/ddclient.in
+++ b/ddclient.in
@@ -6477,8 +6477,10 @@ sub nic_duckdns_update {
## update each configured host
## should improve to update in one pass
foreach my $h (@_) {
- my $ip = delete $config{$h}{'wantip'};
- info("setting IP address to %s for %s", $ip, $h);
+ my $ipv4 = delete $config{$h}{'wantipv4'};
+ my $ipv6 = delete $config{$h}{'wantipv6'};
+ info("setting IPv4 address to %s for %s", $ipv4, $h) if $ipv4;
+ info("setting IPv6 address to %s for %s", $ipv6, $h) if $ipv6;
verbose("UPDATE:", "updating %s", $h);
# Set the URL that we're going to to update
@@ -6488,13 +6490,8 @@ sub nic_duckdns_update {
$url .= $h;
$url .= "&token=";
$url .= $config{$h}{'password'};
- if (is_ipv6($ip)) {
- $url .= "&ipv6=";
- } else {
- $url .= "&ip=";
- }
- $url .= $ip;
-
+ $url .= "&ip=$ipv4" if $ipv4;
+ $url .= "&ipv6=$ipv6" if $ipv6;
# Try to get URL
my $reply = geturl(proxy => opt('proxy'), url => $url);
@@ -6512,14 +6509,20 @@ sub nic_duckdns_update {
foreach $line (@reply) {
if ($line eq 'OK') {
- $config{$h}{'ip'} = $ip;
+ $config{$h}{'ipv4'} = $ipv4 if $ipv4;
+ $config{$h}{'ipv6'} = $ipv6 if $ipv6;
$config{$h}{'mtime'} = $now;
$config{$h}{'status'} = 'good';
+ $config{$h}{'status-ipv4'} = 'good' if $ipv4;
+ $config{$h}{'status-ipv6'} = 'good' if $ipv6;
$state = 'result';
- success("updating %s: good: IP address set to %s", $h, $ip);
+ success("updating %s: good: IPv4 address set to %s", $h, $ipv4) if $ipv4;
+ success("updating %s: good: IPv6 address set to %s", $h, $ipv6) if $ipv6;
} elsif ($line eq 'KO') {
$config{$h}{'status'} = 'failed';
+ $config{$h}{'status-ipv4'} = 'failed' if $ipv4;
+ $config{$h}{'status-ipv6'} = 'failed' if $ipv6;
$state = 'result';
failed("updating %s: Server said: '%s'", $h, $line);
}
|