]> git.ipfire.org Git - ddns.git/blobdiff - src/ddns/providers.py
Add zzzz.io as new provider.
[ddns.git] / src / ddns / providers.py
index a9893b86213f3784b7a2bb248ec13b33badd4836..a5385a9c6b1bb25c12d11dd5950d0aac74bff917 100644 (file)
@@ -841,11 +841,11 @@ class DDNSProviderNOIP(DDNSProtocolDynDNS2, DDNSProvider):
 class DDNSProviderNsupdateINFO(DDNSProtocolDynDNS2, DDNSProvider):
        handle    = "nsupdate.info"
        name      = "nsupdate.info"
-       website   = "http://www.nsupdate.info/"
+       website   = "http://nsupdate.info/"
        protocols = ("ipv6", "ipv4",)
 
        # Information about the format of the HTTP request can be found
-       # after login on the provider user intrface and here:
+       # after login on the provider user interface and here:
        # http://nsupdateinfo.readthedocs.org/en/latest/user.html
 
        # Nsupdate.info uses the hostname as user part for the HTTP basic auth,
@@ -1152,3 +1152,49 @@ class DDNSProviderZoneedit(DDNSProtocolDynDNS2, DDNSProvider):
 
                # If we got here, some other update error happened.
                raise DDNSUpdateError
+
+
+class DDNSProviderZZZZ(DDNSProvider):
+       handle    = "zzzz.io"
+       name      = "zzzz"
+       website   = "https://zzzz.io"
+       protocols = ("ipv4",)
+
+       # Detailed information about the update request can be found here:
+       # https://zzzz.io/faq/
+
+       # Details about the possible response codes have been provided in the bugtracker:
+       # https://bugzilla.ipfire.org/show_bug.cgi?id=10584#c2
+
+       url = "https://zzzz.io/api/v1/update"
+
+       def update(self):
+               data = {
+                       "ip"    : self.get_address("ipv4"),
+                       "token" : self.token,
+               }
+
+               # zzzz uses the host from the full hostname as part
+               # of the update url.
+               host, domain = self.hostname.split(".", 1)
+
+               # Add host value to the update url.
+               url = "%s/%s" % (self.url, host)
+
+               # Send update to the server.
+               try:
+                       response = self.send_request(url, data=data)
+
+               # Handle error codes.
+               except urllib2.HTTPError, e:
+                       if e.code == 404:
+                               raise DDNSRequestError(_("Invalid hostname specified."))
+
+                       raise
+
+               # Handle success messages.
+               if response.code == 200:
+                       return
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError