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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
From 00ae6ec809cd5db7a3b4418ad393c145252f1b75 Mon Sep 17 00:00:00 2001
From: Lenard Hess <lenard@rrhess.de>
Date: Mon, 10 Jul 2023 18:57:02 +0200
Subject: [PATCH 1/3] Fixed caching behaviour for new providers with legacy
'use' logic
Ref: https://github.com/rrthomas/ddclient/pull/10
---
ddclient.in | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/ddclient.in b/ddclient.in
index 9221a1c9..c871b5b6 100755
--- a/ddclient.in
+++ b/ddclient.in
@@ -1337,6 +1337,18 @@ sub update_nics {
if (@hosts) {
$0 = sprintf("%s - updating %s", $program, join(',', @hosts));
&$update(@hosts);
+
+ # Backwards compatibility:
+ # If we only have 'use', we set 'wantipv4' or 'wantipv6' depending on the IP type of
+ # 'wantip'. Newer provider implementations such as cloudflare only check 'wantipv*'
+ # and set 'status-ipv*' accordingly, ignoring 'wantip' and 'status'.
+ # For these we then load back the 'status' from 'status-ipv*' to ensure correct
+ # caching and updating behaviour.
+ foreach my $h (@hosts) {
+ $config{$h}{'status'} //= $config{$h}{'status-ipv4'};
+ $config{$h}{'status'} //= $config{$h}{'status-ipv6'};
+ }
+
runpostscript(join ' ', keys %ipsv4, keys %ipsv6);
}
}
From 240176c5de6360ed9202975fb5e72e9f4148540f Mon Sep 17 00:00:00 2001
From: Lenard Hess <lenard@rrhess.de>
Date: Mon, 10 Jul 2023 21:48:27 +0200
Subject: [PATCH 2/3] Added preliminary explanation for provider functions
---
ddclient.in | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/ddclient.in b/ddclient.in
index c871b5b6..3a4a0780 100755
--- a/ddclient.in
+++ b/ddclient.in
@@ -3696,6 +3696,25 @@ sub header_ok {
}
return $ok;
}
+
+######################################################################
+## DDNS providers
+# A DDNS provider consists of an example function, the update
+# function, and an optional updateable function.
+#
+# The example function simply returns a string for the help message,
+# explaining how to configure the provider
+#
+# The update function performs the actual record update.
+# It receives an array of hosts as its argument.
+#
+# The updateable function allows a provider implementation to force
+# an update even if ddclient has itself determined no update is
+# necessary. The function shall return 1 if an update should be
+# performed, else 0.
+######################################################################
+
+
######################################################################
## nic_dyndns1_examples
######################################################################
From 6c91b3ca2c868989ad5bf6535fa186dbae74ba14 Mon Sep 17 00:00:00 2001
From: Lenard Hess <lenard@rrhess.de>
Date: Thu, 13 Jul 2023 14:10:44 +0200
Subject: [PATCH 3/3] easydns, porkbun: Set status-ipv4 and status-ipv6 instead
of status
This fixes caching issues when using the 'usev4' or 'usev6' parameters.
Without this, the "min-interval" and "warned-min-interval" limits will
not work.
For the legacy 'use' parameter, the wrapping code takes care of
translating 'status-ipv*' to 'status'.
---
ddclient.in | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/ddclient.in b/ddclient.in
index 3a4a0780..65076d26 100755
--- a/ddclient.in
+++ b/ddclient.in
@@ -4747,7 +4747,8 @@ sub nic_easydns_update {
my ($status) = $line =~ /^(\S*)\b.*/;
my $h = shift @hosts;
- $config{$h}{'status'} = $status;
+ $config{$h}{'status-ipv4'} = $status if $ipv4;
+ $config{$h}{'status-ipv6'} = $status if $ipv6;
if ($status eq 'NOERROR') {
$config{$h}{'ipv4'} = $ipv4;
$config{$h}{'ipv6'} = $ipv6;
@@ -7081,12 +7082,12 @@ sub nic_porkbun_update {
);
# No response, declare as failed
if (!defined($reply) || !$reply) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv4'} = "bad";
failed("updating %s: Could not connect to porkbun.com.", $host);
next;
}
if (!header_ok($host, $reply)) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv4'} = "bad";
failed("updating %s: failed (%s)", $host, $reply);
next;
}
@@ -7095,12 +7096,12 @@ sub nic_porkbun_update {
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
my $response = eval { decode_json(${^MATCH}) };
if (!defined($response)) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv4'} = "bad";
failed("%s -- Unexpected service response.", $host);
next;
}
if ($response->{status} ne 'SUCCESS') {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv4'} = "bad";
failed("%s -- Unexpected status. (status = %s)", $host, $response->{status});
next;
}
@@ -7112,7 +7113,7 @@ sub nic_porkbun_update {
}
my $current_content = $records->[0]->{'content'};
if ($current_content eq $ipv4) {
- $config{$host}{'status'} = "good";
+ $config{$host}{'status-ipv4'} = "good";
success("updating %s: skipped: IPv4 address was already set to %s.", $host, $ipv4);
next;
}
@@ -7144,11 +7145,11 @@ sub nic_porkbun_update {
failed("updating %s: failed (%s)", $host, $reply);
next;
}
- $config{$host}{'status'} = "good";
+ $config{$host}{'status-ipv4'} = "good";
success("updating %s: good: IPv4 address set to %s", $host, $ipv4);
next;
} else {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv4'} = "bad";
failed("updating %s: No applicable existing records.", $host);
next;
}
@@ -7174,12 +7175,12 @@ sub nic_porkbun_update {
);
# No response, declare as failed
if (!defined($reply) || !$reply) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv6'} = "bad";
failed("updating %s: Could not connect to porkbun.com.", $host);
next;
}
if (!header_ok($host, $reply)) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv6'} = "bad";
failed("updating %s: failed (%s)", $host, $reply);
next;
}
@@ -7188,12 +7189,12 @@ sub nic_porkbun_update {
$reply =~ qr/{(?:[^{}]*|(?R))*}/mp;
my $response = eval { decode_json(${^MATCH}) };
if (!defined($response)) {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv6'} = "bad";
failed("%s -- Unexpected service response.", $host);
next;
}
if ($response->{status} ne 'SUCCESS') {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv6'} = "bad";
failed("%s -- Unexpected status. (status = %s)", $host, $response->{status});
next;
}
@@ -7205,7 +7206,7 @@ sub nic_porkbun_update {
}
my $current_content = $records->[0]->{'content'};
if ($current_content eq $ipv6) {
- $config{$host}{'status'} = "good";
+ $config{$host}{'status-ipv6'} = "good";
success("updating %s: skipped: IPv6 address was already set to %s.", $host, $ipv6);
next;
}
@@ -7237,11 +7238,11 @@ sub nic_porkbun_update {
failed("updating %s: failed (%s)", $host, $reply);
next;
}
- $config{$host}{'status'} = "good";
+ $config{$host}{'status-ipv6'} = "good";
success("updating %s: good: IPv6 address set to %s", $host, $ipv4);
next;
} else {
- $config{$host}{'status'} = "bad";
+ $config{$host}{'status-ipv6'} = "bad";
failed("updating %s: No applicable existing records.", $host);
next;
}
|