]> git.ipfire.org Git - ddns.git/blobdiff - src/ddns/providers.py
Add dyns.cx|net as new provider.
[ddns.git] / src / ddns / providers.py
index 6ab9073ecee6a7a283dffcfcbcb0f2a2342717c2..2ffc35d50953da4fe44823c5b7b647f05d34c4c3 100644 (file)
@@ -129,7 +129,7 @@ class DDNSProvider(object):
 
                # Check if we actually need to update this host.
                elif self.is_uptodate(self.protocols):
-                       logger.info(_("The dynamic host %(hostname)s (%(provider)s) is already up to date") % \
+                       logger.debug(_("The dynamic host %(hostname)s (%(provider)s) is already up to date") % \
                                { "hostname" : self.hostname, "provider" : self.name })
                        return
 
@@ -214,7 +214,7 @@ class DDNSProtocolDynDNS2(object):
                # Handle error codes.
                if output == "badauth":
                        raise DDNSAuthenticationError
-               elif output == "aduse":
+               elif output == "abuse":
                        raise DDNSAbuseError
                elif output == "notfqdn":
                        raise DDNSRequestError(_("No valid FQDN was given."))
@@ -224,6 +224,8 @@ class DDNSProtocolDynDNS2(object):
                        raise DDNSInternalServerError
                elif output == "dnserr":
                        raise DDNSInternalServerError(_("DNS error encountered."))
+               elif output == "badagent":
+                       raise DDNSBlockedError
 
                # If we got here, some other update error happened.
                raise DDNSUpdateError(_("Server response: %s") % output)
@@ -320,6 +322,11 @@ class DDNSProviderBindNsupdate(DDNSProvider):
                if server:
                        scriptlet.append("server %s" % server)
 
+               # Set the DNS zone the host should be added to.
+               zone = self.get("zone", None)
+               if zone:
+                       scriptlet.append("zone %s" % zone)
+
                key = self.get("key", None)
                if key:
                        secret = self.get("secret")
@@ -516,9 +523,11 @@ class DDNSProviderDynU(DDNSProtocolDynDNS2, DDNSProvider):
                data = DDNSProtocolDynDNS2._prepare_request_data(self)
 
                # This one supports IPv6
-               data.update({
-                       "myipv6"   : self.get_address("ipv6"),
-               })
+               myipv6 = self.get_address("ipv6")
+
+               # Add update information if we have an IPv6 address.
+               if myipv6:
+                       data["myipv6"] = myipv6
 
                return data
 
@@ -536,6 +545,61 @@ class DDNSProviderEasyDNS(DDNSProtocolDynDNS2, DDNSProvider):
        url = "http://api.cp.easydns.com/dyn/tomato.php"
 
 
+class DDNSProviderDomopoli(DDNSProtocolDynDNS2, DDNSProvider):
+       handle    = "domopoli.de"
+       name      = "domopoli.de"
+       website   = "http://domopoli.de/"
+       protocols = ("ipv4",)
+
+       # https://www.domopoli.de/?page=howto#DynDns_start
+
+       url = "http://dyndns.domopoli.de/nic/update"
+
+
+class DDNSProviderDynsNet(DDNSProvider):
+       handle    = "dyns.net"
+       name      = "DyNS"
+       website   = "http://www.dyns.net/"
+       protocols = ("ipv4",)
+
+       # There is very detailed informatio about how to send the update request and
+       # the possible response codes. (Currently we are using the v1.1 proto)
+       # http://www.dyns.net/documentation/technical/protocol/
+
+       url = "http://www.dyns.net/postscript011.php"
+
+       def update(self):
+               data = {
+                       "ip"       : self.get_address("ipv4"),
+                       "host"     : self.hostname,
+                       "username" : self.username,
+                       "password" : self.password,
+               }
+
+               # Send update to the server.
+               response = self.send_request(self.url, data=data)
+
+               # Get the full response message.
+               output = response.read()
+
+               # Handle success messages.
+               if output.startswith("200"):
+                       return
+
+               # Handle error codes.
+               if output.startswith("400"):
+                       raise DDNSRequestError(_("Malformed request has been sent."))
+               elif output.startswith("401"):
+                       raise DDNSAuthenticationError
+               elif output.startswith("402"):
+                       raise DDNSRequestError(_("Too frequent update requests have been sent."))
+               elif output.startswith("403"):
+                       raise DDNSInternalServerError
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError(_("Server response: %s") % output) 
+
+
 class DDNSProviderEnomCom(DDNSResponseParserXML, DDNSProvider):
        handle    = "enom.com"
        name      = "eNom Inc."
@@ -598,7 +662,7 @@ class DDNSProviderEntryDNS(DDNSProvider):
 
                # Send update to the server.
                try:
-                       response = self.send_request(url, method="PUT", data=data)
+                       response = self.send_request(url, data=data)
 
                # Handle error codes
                except urllib2.HTTPError, e: