]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
ddns: Import upstream patch for provider DuckDNS.
authorStefan Schantl <stefan.schantl@ipfire.org>
Wed, 2 Dec 2020 11:33:22 +0000 (12:33 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 2 Dec 2020 14:56:46 +0000 (14:56 +0000)
Fixes #12415.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
lfs/ddns
src/patches/ddns-013-duckdns-new-api.patch [new file with mode: 0644]

index 0a71b52eacc9f9197995537f1dca5e59744ba7b5..2a6dbca2b7a1fbe2c92a691cb8596561055904de 100644 (file)
--- a/lfs/ddns
+++ b/lfs/ddns
@@ -74,6 +74,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        # Apply upstream patches.
        cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/ddns-013-dyfi-use-https.patch
        cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/ddns-013-ddnss-fix-unhandled-exeption-on-update-patch
+       cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/ddns-013-duckdns-new-api.patch
 
        cd $(DIR_APP) && [ -x "configure" ] || sh ./autogen.sh
        cd $(DIR_APP) && ./configure \
diff --git a/src/patches/ddns-013-duckdns-new-api.patch b/src/patches/ddns-013-duckdns-new-api.patch
new file mode 100644 (file)
index 0000000..a671bf9
--- /dev/null
@@ -0,0 +1,83 @@
+commit ebdb37245e2033b065cce5a19597be4ef1c8875c
+Author: Carl Mascott <cmascott@yahoo.com>
+Date:   Wed Dec 2 11:39:20 2020 +0100
+
+    DuckDNS: Update to use new API.
+    
+    The new API supports IPv6 and a token based auth.
+    
+    Reference #12415.
+    
+    Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
+
+diff --git a/src/ddns/providers.py b/src/ddns/providers.py
+index 46d8a67..a1ca3f3 100644
+--- a/src/ddns/providers.py
++++ b/src/ddns/providers.py
+@@ -802,16 +802,62 @@ class DDNSProviderDtDNS(DDNSProvider):
+               raise DDNSUpdateError
+-class DDNSProviderDuckDNS(DDNSProtocolDynDNS2, DDNSProvider):
++class DDNSProviderDuckDNS(DDNSProvider):
+       handle    = "duckdns.org"
+       name      = "Duck DNS"
+       website   = "http://www.duckdns.org/"
+-      protocols = ("ipv4",)
++      protocols = ("ipv6", "ipv4",)
+       # Information about the format of the request is to be found
+-      # https://www.duckdns.org/install.jsp
++      # https://www.duckdns.org/spec.jsp
++
++      url = "https://www.duckdns.org/update"
++      can_remove_records = False
++
++      def update(self):
++              # Raise an error if no auth details are given.
++              if not self.token:
++                      raise DDNSConfigurationError
++
++              data =  {
++                      "domains" : self.hostname,
++                      "token"    : self.token,
++              }
++
++              # Check if we update an IPv4 address.
++              address4 = self.get_address("ipv4")
++              if address4:
++                      data["ip"] = address4
+-      url = "https://www.duckdns.org/nic/update"
++              # Check if we update an IPv6 address.
++              address6 = self.get_address("ipv6")
++              if address6:
++                      data["ipv6"] = address6
++
++              # Raise an error if no address is given.
++              if "ip" not in data and "ipv6" not in data:
++                      raise DDNSConfigurationError
++
++              # Send update to the server.
++              response = self.send_request(self.url, data=data)
++
++              # Get the full response message.
++              output = response.read().decode()
++
++              # Remove all leading and trailing whitespace.
++              output = output.strip()
++
++              # Handle success messages.
++              if output == "OK":
++                      return
++
++              # The provider does not give detailed information
++              # if the update fails. Only a "KO" will be sent back.
++              if output == "KO":
++                      raise DDNSUpdateError
++
++              # If we got here, some other update error happened.
++              raise DDNSUpdateError
+ class DDNSProviderDyFi(DDNSProtocolDynDNS2, DDNSProvider):