From patchwork Wed Dec 2 11:33:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 3692 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4CmH0Y6096z3wpp for ; Wed, 2 Dec 2020 11:33:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4CmH0X223Pz1fd; Wed, 2 Dec 2020 11:33:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4CmH0V2xlNz2y2V; Wed, 2 Dec 2020 11:33:30 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4CmH0T27YKz2xlC for ; Wed, 2 Dec 2020 11:33:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4CmH0S1SnkzRp; Wed, 2 Dec 2020 11:33:28 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1606908808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PAkVzDE/deKuydxXjkOJtafK80RJjEzMjGiETFa738Y=; b=/fJaVazE/3dwl00vxkikgg8i2GBj+weaYuOAg/mxnQGP5nYJThUxquz2CDrLJ4Xncwo8BV WJci8RImswsHqbCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1606908808; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=PAkVzDE/deKuydxXjkOJtafK80RJjEzMjGiETFa738Y=; b=nYXQCDjA2Ct3qxdp4BIDWot01A+3m/aplARFEnbs72N1fjUjdtPOLvshdB6qegB5meYD5z A9YTbfmFlfeDT378+nz20u9O89gkPucfBCkzBZgKlU4p+seQn8QWlO+iVQhGZKtsL6NVs5 tsWrlvLqmkBTcvtyomQB6o1U6c87TLywAb5Iq98Vwf3uetGh6ux0NmiMM/eD7fA/mkx11b dxCWxSrgOS+utxA4rW0lvw2cgEhjILOsaTtKFTivjSnSIrYetaG5IiQNe7OoTAj7tcn233 odot3uN9wOnlzGv5oAT7p62NwVTeP0YyYmTKWMBEQ/h8Ooa570pvnw/ZQdqlzA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] ddns: Import upstream patch for provider DuckDNS. Date: Wed, 2 Dec 2020 12:33:22 +0100 Message-Id: <20201202113322.5674-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Fixes #12415. Signed-off-by: Stefan Schantl --- lfs/ddns | 1 + src/patches/ddns-013-duckdns-new-api.patch | 83 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/patches/ddns-013-duckdns-new-api.patch diff --git a/lfs/ddns b/lfs/ddns index 0a71b52ea..2a6dbca2b 100644 --- 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 index 000000000..a671bf917 --- /dev/null +++ b/src/patches/ddns-013-duckdns-new-api.patch @@ -0,0 +1,83 @@ +commit ebdb37245e2033b065cce5a19597be4ef1c8875c +Author: Carl Mascott +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 + +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):