Add DHS as new provider.
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 9 Jun 2014 19:35:04 +0000 (21:35 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 9 Jun 2014 19:35:04 +0000 (21:35 +0200)
ddns.conf
src/ddns/__init__.py
src/ddns/providers.py

index b54f8ef..83ac1dc 100644 (file)
--- a/ddns.conf
+++ b/ddns.conf
 # Accounts are its own sections.
 # These are some examples.
 
+# [test.dhs.org]
+# provider = dhs.org
+# username = user
+# password = pass
+
 # [test.no-ip.org]
 # provider = no-ip.com
 # username = user
index 3b465f0..74989f3 100644 (file)
@@ -86,6 +86,7 @@ class DDNSCore(object):
                        Simply registers all providers.
                """
                for provider in (
+                       DDNSProviderDHS,
                        DDNSProviderNOIP,
                        DDNSProviderLightningWireLabs,
                        DDNSProviderSelfhost,
index 0a20e3a..9ffd67d 100644 (file)
@@ -121,6 +121,48 @@ class DDNSProvider(object):
                return self.core.system.get_address(proto)
 
 
+class DDNSProviderDHS(DDNSProvider):
+       INFO = {
+               "handle"    : "dhs.org",
+               "name"      : "DHS International",
+               "website"   : "http://dhs.org/",
+               "protocols" : ["ipv4",]
+       }
+
+       # No information about the used update api provided on webpage,
+       # grabed from source code of ez-ipudate.
+       url = "http://members.dhs.org/nic/hosts"
+
+       def __call__(self):
+               url = self.url % {
+                       "username" : self.username,
+                       "password" : self.password,
+               }
+
+               data = {
+                       "domain"       : self.hostname,
+                       "ip"           : self.get_address("ipv4"),
+                       "hostcmd"      : "edit",
+                       "hostcmdstage" : "2",
+                       "type"         : "4",
+               }
+
+               # Send update to the server.
+               response = self.send_request(url, username=self.username, password=self.password,
+                       data=data)
+
+               # Handle success messages.
+               if response.code == 200:
+                       return
+
+               # Handle error codes.
+               elif response.code == "401":
+                       raise DDNSAuthenticationError
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError
+
+
 class DDNSProviderLightningWireLabs(DDNSProvider):
        INFO = {
                "handle"    : "dns.lightningwirelabs.com",