From 39301272d21797e2ce427b5afecc9b086a22ff4b Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Tue, 10 Jun 2014 17:10:20 +0200 Subject: [PATCH] Add DNS Park as new provider. --- ddns.conf | 5 ++++ src/ddns/__init__.py | 1 + src/ddns/providers.py | 54 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/ddns.conf b/ddns.conf index 83ac1dc..095c72e 100644 --- a/ddns.conf +++ b/ddns.conf @@ -20,6 +20,11 @@ # username = user # password = pass +# [test.dnspark.com] +# provider = dnspark.com +# username = user +# password = pass + # [test.no-ip.org] # provider = no-ip.com # username = user diff --git a/src/ddns/__init__.py b/src/ddns/__init__.py index 74989f3..673ba27 100644 --- a/src/ddns/__init__.py +++ b/src/ddns/__init__.py @@ -87,6 +87,7 @@ class DDNSCore(object): """ for provider in ( DDNSProviderDHS, + DDNSProviderDNSpark, DDNSProviderNOIP, DDNSProviderLightningWireLabs, DDNSProviderSelfhost, diff --git a/src/ddns/providers.py b/src/ddns/providers.py index 9ffd67d..5ff0631 100644 --- a/src/ddns/providers.py +++ b/src/ddns/providers.py @@ -163,6 +163,60 @@ class DDNSProviderDHS(DDNSProvider): raise DDNSUpdateError +class DDNSProviderDNSpark(DDNSProvider): + INFO = { + "handle" : "dnspark.com", + "name" : "DNS Park", + "website" : "http://dnspark.com/", + "protocols" : ["ipv4",] + } + + # Informations to the used api can be found here: + # https://dnspark.zendesk.com/entries/31229348-Dynamic-DNS-API-Documentation + url = "https://control.dnspark.com/api/dynamic/update.php" + + def __call__(self): + url = self.url % { + "username" : self.username, + "password" : self.password, + } + + data = { + "domain" : self.hostname, + "ip" : self.get_address("ipv4"), + } + + # Send update to the server. + response = self.send_request(url, username=self.username, password=self.password, + data=data) + + # Get the full response message. + output = response.read() + + # Handle success messages. + if output.startswith("ok") or output.startswith("nochange"): + return + + # Handle error codes. + if output == "unauth": + raise DDNSAuthenticationError + elif output == "abuse": + raise DDNSAbuseError + elif output == "blocked": + raise DDNSBlockedError + elif output == "nofqdn": + raise DDNSRequestError(_("No valid FQDN was given.")) + elif output == "nohost": + raise DDNSRequestError(_("Invalid hostname specified.")) + elif output == "notdyn": + raise DDNSRequestError(_("Hostname not marked as a dynamic host.")) + elif output == "invalid": + raise DDNSRequestError(_("Invalid IP address has been sent.")) + + # If we got here, some other update error happened. + raise DDNSUpdateError + + class DDNSProviderLightningWireLabs(DDNSProvider): INFO = { "handle" : "dns.lightningwirelabs.com", -- 2.39.2