]> git.ipfire.org Git - oddments/ddns.git/blobdiff - src/ddns/providers.py
zzzz.io: Also support IPv6
[oddments/ddns.git] / src / ddns / providers.py
index a57dc8496c32d0f282e7cf4d5a133bb7cdf610d5..acec95b7a6e0ffd1afba2d36cd76a7101243d056 100644 (file)
@@ -1152,3 +1152,56 @@ 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 = ("ipv6", "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):
+               for protocol in self.protocols:
+                       address = self.get_address(protocol)
+
+                       if address:
+                               self.update_for_protocol(protocol, address)
+
+       def update_for_protocol(self, proto, address):
+               data = {
+                       "ip"    : address,
+                       "token" : self.token,
+               }
+
+               if proto == "ipv6":
+                       data["type"] = "aaaa"
+
+               # 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 DDNSNotFound:
+                       raise DDNSRequestError(_("Invalid hostname specified"))
+
+               # Handle success messages.
+               if response.code == 200:
+                       return
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError