Add freedns.afraid.org as new provider.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sat, 14 Jun 2014 21:23:38 +0000 (23:23 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sat, 14 Jun 2014 21:57:20 +0000 (23:57 +0200)
ddns.conf.sample
src/ddns/__init__.py
src/ddns/providers.py

index 9ac67e4..bf31b59 100644 (file)
 # provider = dtdns.org
 # password = pass
 
+# [test.freedns.afraid.org]
+# provider = freedns.afraid.org
+# token = token
+# proto = ipv4 OR ipv6
+
 # [test.no-ip.org]
 # provider = no-ip.com
 # username = user
index e728c37..8af99d7 100644 (file)
@@ -94,6 +94,7 @@ class DDNSCore(object):
                        DDNSProviderDHS,
                        DDNSProviderDNSpark,
                        DDNSProviderDtDNS,
+                       DDNSProviderFreeDNSAfraidOrg,
                        DDNSProviderNOIP,
                        DDNSProviderLightningWireLabs,
                        DDNSProviderSelfhost,
index 2788c97..605b65e 100644 (file)
@@ -312,6 +312,52 @@ class DDNSProviderDtDNS(DDNSProvider):
                raise DDNSUpdateError
 
 
+class DDNSProviderFreeDNSAfraidOrg(DDNSProvider):
+       INFO = {
+               "handle"    : "freedns.afraid.org",
+               "name"      : "freedns.afraid.org",
+               "website"   : "http://freedns.afraid.org/",
+               "protocols" : ["ipv6", "ipv4",]
+               }
+
+       # No information about the request or response could be found on the vendor
+       # page. All used values have been collected by testing.
+       url = "https://freedns.afraid.org/dynamic/update.php"
+
+       @property
+       def proto(self):
+               return self.get("proto")
+
+       def update(self):
+               address = self.get_address(self.proto)
+
+               data = {
+                       "address" : address,
+               }
+
+               # Add auth token to the update url.
+               url = "%s?%s" % (self.url, self.token)
+
+               # Send update to the server.
+               response = self.send_request(url, data=data)
+
+               # Get the full response message.
+               output = response.read()
+
+               # Handle success messages.
+               if output.startswith("Updated") or "has not changed" in output:
+                       return
+
+               # Handle error codes.
+               if output == "ERROR: Unable to locate this record":
+                       raise DDNSAuthenticationError
+               elif "is an invalid IP address" in output:
+                       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",