1 commit ebdb37245e2033b065cce5a19597be4ef1c8875c
2 Author: Carl Mascott <cmascott@yahoo.com>
3 Date: Wed Dec 2 11:39:20 2020 +0100
5 DuckDNS: Update to use new API.
7 The new API supports IPv6 and a token based auth.
11 Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
13 diff --git a/src/ddns/providers.py b/src/ddns/providers.py
14 index 46d8a67..a1ca3f3 100644
15 --- a/src/ddns/providers.py
16 +++ b/src/ddns/providers.py
17 @@ -802,16 +802,62 @@ class DDNSProviderDtDNS(DDNSProvider):
21 -class DDNSProviderDuckDNS(DDNSProtocolDynDNS2, DDNSProvider):
22 +class DDNSProviderDuckDNS(DDNSProvider):
23 handle = "duckdns.org"
25 website = "http://www.duckdns.org/"
26 - protocols = ("ipv4",)
27 + protocols = ("ipv6", "ipv4",)
29 # Information about the format of the request is to be found
30 - # https://www.duckdns.org/install.jsp
31 + # https://www.duckdns.org/spec.jsp
33 + url = "https://www.duckdns.org/update"
34 + can_remove_records = False
37 + # Raise an error if no auth details are given.
39 + raise DDNSConfigurationError
42 + "domains" : self.hostname,
43 + "token" : self.token,
46 + # Check if we update an IPv4 address.
47 + address4 = self.get_address("ipv4")
49 + data["ip"] = address4
51 - url = "https://www.duckdns.org/nic/update"
52 + # Check if we update an IPv6 address.
53 + address6 = self.get_address("ipv6")
55 + data["ipv6"] = address6
57 + # Raise an error if no address is given.
58 + if "ip" not in data and "ipv6" not in data:
59 + raise DDNSConfigurationError
61 + # Send update to the server.
62 + response = self.send_request(self.url, data=data)
64 + # Get the full response message.
65 + output = response.read().decode()
67 + # Remove all leading and trailing whitespace.
68 + output = output.strip()
70 + # Handle success messages.
74 + # The provider does not give detailed information
75 + # if the update fails. Only a "KO" will be sent back.
77 + raise DDNSUpdateError
79 + # If we got here, some other update error happened.
80 + raise DDNSUpdateError
83 class DDNSProviderDyFi(DDNSProtocolDynDNS2, DDNSProvider):