]> git.ipfire.org Git - ddns.git/commitdiff
Merge remote-tracking branch 'stevee/twodns.de'
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Jun 2014 10:25:55 +0000 (10:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 22 Jun 2014 10:25:55 +0000 (10:25 +0000)
Conflicts:
src/ddns/__init__.py
src/ddns/providers.py

1  2 
ddns.conf.sample
src/ddns/__init__.py
src/ddns/providers.py

diff --combined ddns.conf.sample
index 9de99a128fda2b946f2e9313189d3e8a1df96d87,107acc878bc20c1d9ac97c835629ffd7e302c3f6..90755369ddb682a8dbd07ca3fed642e3c08125bc
  # Accounts are its own sections.
  # These are some examples.
  
 +# [test.all-inkl.com]
 +# provider = all-inkl.com
 +# username = user
 +# password = pass
 +
  # [test.dhs.org]
  # provider = dhs.org
  # username = user
  # token = token
  # proto = ipv4 OR ipv6
  
 +# [test.namecheap.com]
 +# provider = namecheap.com
 +# password = pass
 +
  # [test.no-ip.org]
  # provider = no-ip.com
  # username = user
  # username = user
  # password = pass
  
 +# [test.strato.com]
 +# provider = strato.com
 +# username = user
 +# password = pass
 +
  # [test.lightningwirelabs.com]
  # provider = dns.lightningwirelabs.com
  
  # username = user
  # password = pass
  
+ # [test.twodns.de]
+ # provider = twodns.de
+ # username = user
+ # password = pass
  # [test.variomedia.de]
  # provider = variomedia.de
  # username = user
diff --combined src/ddns/__init__.py
index 38b3ad7014585b26e725aeaf68e73a0452c38343,18d89ec09da172850fd9ccfe8bbf596d495e7dfe..f22eb66c400bf735ab1eee741fde2ea68d30b406
@@@ -91,7 -91,6 +91,7 @@@ class DDNSCore(object)
                        Simply registers all providers.
                """
                for provider in (
 +                      DDNSProviderAllInkl,
                        DDNSProviderDHS,
                        DDNSProviderDNSpark,
                        DDNSProviderDtDNS,
                        DDNSProviderDynU,
                        DDNSProviderEasyDNS,
                        DDNSProviderFreeDNSAfraidOrg,
 +                      DDNSProviderNamecheap,
                        DDNSProviderNOIP,
                        DDNSProviderLightningWireLabs,
                        DDNSProviderOVH,
                        DDNSProviderRegfish,
                        DDNSProviderSelfhost,
                        DDNSProviderSPDNS,
 +                      DDNSProviderStrato,
+                       DDNSProviderTwoDNS,
                        DDNSProviderVariomedia,
                ):
                        self.register_provider(provider)
diff --combined src/ddns/providers.py
index fc03af2b7eef0a8fd3dc065b7b3302d189ef72be,fdc86c69d53778f561d7a303e430f7b6915db7be..3d89350087f17dbc2823280d54d90e7fe5b95f1e
@@@ -20,8 -20,6 +20,8 @@@
  ###############################################################################
  
  import logging
 +import urllib2
 +import xml.dom.minidom
  
  from i18n import _
  
@@@ -169,47 -167,6 +169,47 @@@ class DDNSProvider(object)
                return self.core.system.get_address(proto)
  
  
 +class DDNSProviderAllInkl(DDNSProvider):
 +      INFO = {
 +              "handle"    : "all-inkl.com",
 +              "name"      : "All-inkl.com",
 +              "website"   : "http://all-inkl.com/",
 +              "protocols" : ["ipv4",]
 +      }
 +
 +      # There are only information provided by the vendor how to
 +      # perform an update on a FRITZ Box. Grab requried informations
 +      # from the net.
 +      # http://all-inkl.goetze.it/v01/ddns-mit-einfachen-mitteln/
 +
 +      url = "http://dyndns.kasserver.com"
 +
 +      def update(self):
 +
 +              # There is no additional data required so we directly can
 +              # send our request.
 +              try:
 +                      # Send request to the server.
 +                      response = self.send_request(self.url, username=self.username, password=self.password)
 +
 +                      # Handle 401 HTTP Header (Authentication Error)
 +              except urllib2.HTTPError, e:
 +                      if e.code == 401:
 +                              raise DDNSAuthenticationError
 +
 +                      raise
 +
 +              # Get the full response message.
 +              output = response.read()
 +
 +              # Handle success messages.
 +              if output.startswith("good") or output.startswith("nochg"):
 +                      return
 +
 +              # If we got here, some other update error happened.
 +              raise DDNSUpdateError
 +
 +
  class DDNSProviderDHS(DDNSProvider):
        INFO = {
                "handle"    : "dhs.org",
@@@ -547,77 -504,6 +547,77 @@@ class DDNSProviderLightningWireLabs(DDN
                raise DDNSUpdateError
  
  
 +class DDNSProviderNamecheap(DDNSProvider):
 +      INFO = {
 +              "handle"    : "namecheap.com",
 +              "name"      : "Namecheap",
 +              "website"   : "http://namecheap.com",
 +              "protocols" : ["ipv4",]
 +      }
 +
 +      # Information about the format of the HTTP request is to be found
 +      # https://www.namecheap.com/support/knowledgebase/article.aspx/9249/0/nc-dynamic-dns-to-dyndns-adapter
 +      # https://community.namecheap.com/forums/viewtopic.php?f=6&t=6772
 +
 +      url = "https://dynamicdns.park-your-domain.com/update"
 +
 +      def parse_xml(self, document, content):
 +              # Send input to the parser.
 +              xmldoc = xml.dom.minidom.parseString(document)
 +
 +              # Get XML elements by the given content.
 +              element = xmldoc.getElementsByTagName(content)
 +
 +              # If no element has been found, we directly can return None.
 +              if not element:
 +                      return None
 +
 +              # Only get the first child from an element, even there are more than one.
 +              firstchild = element[0].firstChild
 +
 +              # Get the value of the child.
 +              value = firstchild.nodeValue
 +
 +              # Return the value.
 +              return value
 +              
 +      def update(self):
 +              # Namecheap requires the hostname splitted into a host and domain part.
 +              host, domain = self.hostname.split(".", 1)
 +
 +              data = {
 +                      "ip"       : self.get_address("ipv4"),
 +                      "password" : self.password,
 +                      "host"     : host,
 +                      "domain"   : domain
 +              }
 +
 +              # 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 self.parse_xml(output, "IP") == self.get_address("ipv4"):
 +                      return
 +
 +              # Handle error codes.
 +              errorcode = self.parse_xml(output, "ResponseNumber")
 +
 +              if errorcode == "304156":
 +                      raise DDNSAuthenticationError
 +              elif errorcode == "316153":
 +                      raise DDNSRequestError(_("Domain not found."))
 +              elif errorcode == "316154":
 +                      raise DDNSRequestError(_("Domain not active."))
 +              elif errorcode in ("380098", "380099"):
 +                      raise DDNSInternalServerError
 +
 +              # If we got here, some other update error happened.
 +              raise DDNSUpdateError
 +
 +
  class DDNSProviderNOIP(DDNSProviderDynDNS):
        INFO = {
                "handle"    : "no-ip.com",
@@@ -780,22 -666,31 +780,45 @@@ class DDNSProviderSPDNS(DDNSProviderDyn
        # http://wiki.securepoint.de/index.php/SPDNS_Update-Tokens
  
        url = "https://update.spdns.de/nic/update"
 +
 +
 +class DDNSProviderStrato(DDNSProviderDynDNS):
 +      INFO = {
 +              "handle"    : "strato.com",
 +              "name"      : "Strato AG",
 +              "website"   : "http:/www.strato.com/",
 +              "protocols" : ["ipv4",]
 +      }
 +
 +      # Information about the request and response can be obtained here:
 +      # http://www.strato-faq.de/article/671/So-einfach-richten-Sie-DynDNS-f%C3%BCr-Ihre-Domains-ein.html
 +
 +      url = "https://dyndns.strato.com/nic/update"
  
  
+ class DDNSProviderTwoDNS(DDNSProviderDynDNS):
+       INFO = {
+               "handle"    : "twodns.de",
+               "name"      : "TwoDNS",
+               "website"   : "http://www.twodns.de",
+               "protocols" : ["ipv4",]
+       }
+       # Detailed information about the request can be found here
+       # http://twodns.de/en/faqs
+       # http://twodns.de/en/api
+       url = "https://update.twodns.de/update"
+       def _prepare_request_data(self):
+               data = {
+                       "ip" : self.get_address("ipv4"),
+                       "hostname" : self.hostname
+               }
+               return data
  class DDNSProviderVariomedia(DDNSProviderDynDNS):
        INFO = {
                "handle"   : "variomedia.de",