]> git.ipfire.org Git - oddments/ddns.git/commitdiff
Add regfish as new provider.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 16 Jun 2014 18:15:42 +0000 (20:15 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Tue, 17 Jun 2014 16:51:56 +0000 (18:51 +0200)
ddns.conf.sample
src/ddns/__init__.py
src/ddns/providers.py

index bc41f83d1ff53fb7102dd0f74d0d39ece2380501..610afa7905de48ff27c7f7a9c4dc948ed09dc108 100644 (file)
 # username = user
 # password = pass
 
+# [test.regfish.com]
+# provider = regfish.com
+
+# Only use one of these two auth options.
+# token = token
+# username = user
+# password = pass
+
 # [test.selfhost.de]
 # provider = selfhost.de
 # username = user
index 30a1b8a7698907295aa2666b9e3d23fa8a30b97a..be81fc2db7852385f5f31908aa85b32b0999149e 100644 (file)
@@ -99,6 +99,7 @@ class DDNSCore(object):
                        DDNSProviderNOIP,
                        DDNSProviderLightningWireLabs,
                        DDNSProviderOVH,
+                       DDNSProviderRegfish,
                        DDNSProviderSelfhost,
                        DDNSProviderSPDNS,
                        DDNSProviderVariomedia,
index e936d72351657804e0b8a277ae3430f89ec58bb1..4e3d6b05cbfd9b658ae1d5817ccaa3530afd35d6 100644 (file)
@@ -510,6 +510,80 @@ class DDNSProviderOVH(DDNSProviderDynDNS):
                }
 
 
+class DDNSProviderRegfish(DDNSProvider):
+       INFO = {
+               "handle"    : "regfish.com",
+               "name"      : "Regfish GmbH",
+               "website"   : "http://www.regfish.com/",
+               "protocols" : ["ipv6", "ipv4",]
+       }
+
+       # A full documentation to the providers api can be found here
+       # but is only available in german.
+       # https://www.regfish.de/domains/dyndns/dokumentation
+
+       url = "https://dyndns.regfish.de/"
+
+       def update(self):
+               data = {
+                       "fqdn" : self.hostname,
+               }
+
+               # Check if we update an IPv6 address.
+               address6 = self.get_address("ipv6")
+               if address6:
+                       data["ipv6"] = address6
+
+               # Check if we update an IPv4 address.
+               address4 = self.get_address("ipv4")
+               if address4:
+                       data["ipv4"] = address4
+
+               # Raise an error if none address is given.
+               if not data.has_key("ipv6") and not data.has_key("ipv4"):
+                       raise DDNSConfigurationError
+
+               # Check if a token has been set.
+               if self.token:
+                       data["token"] = self.token
+
+               # Raise an error if no token and no useranem and password
+               # are given.
+               elif not self.username and not self.password:
+                       raise DDNSConfigurationError(_("No Auth details specified."))
+
+               # HTTP Basic Auth is only allowed if no token is used.
+               if self.token:
+                       # Send update to the server.
+                       response = self.send_request(self.url, data=data)
+               else:
+                       # Send update to the server.
+                       response = self.send_request(self.url, username=self.username, password=self.password,
+                               data=data)
+
+               # Get the full response message.
+               output = response.read()
+
+               # Handle success messages.
+               if "100" in output or "101" in output:
+                       return
+
+               # Handle error codes.
+               if "401" or "402" in output:
+                       raise DDNSAuthenticationError
+               elif "408" in output:
+                       raise DDNSRequestError(_("Invalid IPv4 address has been sent."))
+               elif "409" in output:
+                       raise DDNSRequestError(_("Invalid IPv6 address has been sent."))
+               elif "412" in output:
+                       raise DDNSRequestError(_("No valid FQDN was given."))
+               elif "414" in output:
+                       raise DDNSInternalServerError
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError
+
+
 class DDNSProviderSelfhost(DDNSProvider):
        INFO = {
                "handle"    : "selfhost.de",