Rebuild no-ip to inherit all required actions from dyndns.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 15 Jun 2014 18:40:16 +0000 (20:40 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 15 Jun 2014 18:40:16 +0000 (20:40 +0200)
src/ddns/providers.py

index 8a5185f..7dca932 100644 (file)
@@ -315,15 +315,20 @@ class DDNSProviderDynDNS(DDNSProvider):
        # http://dyn.com/support/developers/api/return-codes/
        url = "https://members.dyndns.org/nic/update"
 
-       def update(self):
+       def _prepare_request_data(self):
                data = {
                        "hostname" : self.hostname,
                        "myip"     : self.get_address("ipv4"),
                }
 
+               return data
+
+       def update(self):
+               data = self._prepare_request_data()
+
                # Send update to the server.
-               response = self.send_request(self.url, username=self.username, password=self.password,
-                       data=data)
+               response = self.send_request(self.url, data=data,
+                       username=self.username, password=self.password)
 
                # Get the full response message.
                output = response.read()
@@ -420,7 +425,7 @@ class DDNSProviderLightningWireLabs(DDNSProvider):
                raise DDNSUpdateError
 
 
-class DDNSProviderNOIP(DDNSProvider):
+class DDNSProviderNOIP(DDNSProviderDynDNS):
        INFO = {
                "handle"    : "no-ip.com",
                "name"      : "No-IP",
@@ -432,39 +437,15 @@ class DDNSProviderNOIP(DDNSProvider):
        # here: http://www.no-ip.com/integrate/request and
        # here: http://www.no-ip.com/integrate/response
 
-       url = "http://%(username)s:%(password)s@dynupdate.no-ip.com/nic/update"
-
-       def update(self):
-               url = self.url % {
-                       "username" : self.username,
-                       "password" : self.password,
-               }
+       url = "http://dynupdate.no-ip.com/nic/update"
 
+       def _prepare_request_data(self):
                data = {
                        "hostname" : self.hostname,
                        "address"  : self.get_address("ipv4"),
                }
 
-               # 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("good") or output.startswith("nochg"):
-                       return
-
-               # Handle error codes.
-               if output == "badauth":
-                       raise DDNSAuthenticationError
-               elif output == "aduse":
-                       raise DDNSAbuseError
-               elif output == "911":
-                       raise DDNSInternalServerError
-
-               # If we got here, some other update error happened.
-               raise DDNSUpdateError
+               return data
 
 
 class DDNSProviderSelfhost(DDNSProvider):