]> git.ipfire.org Git - ddns.git/blobdiff - src/ddns/providers.py
namecheap: Fix undeclared variable.
[ddns.git] / src / ddns / providers.py
index fc1fb82cb6ac63b7feb7e96ac5d6a013b0787fe3..6ac556444553fbf0d6e8b23854fe228ad6c81fc5 100644 (file)
@@ -161,10 +161,13 @@ class DDNSProvider(object):
                try:
                        self.update()
 
-               # Catch network errors early, because we do not want to log
+               # 1) Catch network errors early, because we do not want to log
                # them to the database. They are usually temporary and caused
                # by the client side, so that we will retry quickly.
-               except DDNSNetworkError as e:
+               # 2) If there is an internet server error (HTTP code 500) on the
+               # provider's site, we will not log a failure and try again
+               # shortly.
+               except (DDNSNetworkError, DDNSInternalServerError):
                        raise
 
                # In case of any errors, log the failed request and
@@ -1170,8 +1173,11 @@ class DDNSProviderNamecheap(DDNSResponseParserXML, DDNSProvider):
                # Namecheap requires the hostname splitted into a host and domain part.
                host, domain = self.hostname.split(".", 1)
 
+               # Get and store curent IP address.
+               address = self.get_address(proto)
+
                data = {
-                       "ip"       : self.get_address(proto),
+                       "ip"       : address,
                        "password" : self.password,
                        "host"     : host,
                        "domain"   : domain
@@ -1549,6 +1555,54 @@ class DDNSProviderZoneedit(DDNSProvider):
                raise DDNSUpdateError
 
 
+class DDNSProviderDNSmadeEasy(DDNSProvider):
+       handle    = "dnsmadeeasy.com"
+       name      = "DNSmadeEasy.com"
+       website   = "http://www.dnsmadeeasy.com/"
+       protocols = ("ipv4",)
+
+       # DNS Made Easy Nameserver Provider also offering Dynamic DNS
+       # Documentation can be found here:
+       # http://www.dnsmadeeasy.com/dynamic-dns/
+
+       url = "https://cp.dnsmadeeasy.com/servlet/updateip?"
+       can_remove_records = False
+
+       def update_protocol(self, proto):
+               data = {
+                       "ip" : self.get_address(proto),
+                       "id" : self.hostname,
+                       "username" : self.username,
+                       "password" : self.password,
+               }
+
+               # Send update to the server.
+               response = self.send_request(self.url, data=data)
+
+               # Get the full response message.
+               output = response.read()
+
+               # Handle success messages.
+               if output.startswith("success") or output.startswith("error-record-ip-same"):
+                       return
+
+               # Handle error codes.
+               if output.startswith("error-auth-suspend"):
+                       raise DDNSRequestError(_("Account has been suspended."))
+
+               elif output.startswith("error-auth-voided"):
+                       raise DDNSRequestError(_("Account has been revoked."))
+
+               elif output.startswith("error-record-invalid"):
+                       raise DDNSRequestError(_("Specified host does not exist."))
+
+               elif output.startswith("error-auth"):
+                       raise DDNSAuthenticationError
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError(_("Server response: %s") % output)
+
+
 class DDNSProviderZZZZ(DDNSProvider):
        handle    = "zzzz.io"
        name      = "zzzz"