From: Stefan Schantl Date: Mon, 16 Jun 2014 18:15:42 +0000 (+0200) Subject: Add regfish as new provider. X-Git-Tag: 001~40^2 X-Git-Url: http://git.ipfire.org/?p=ddns.git;a=commitdiff_plain;h=ef33455ebe5dd1391516dbe3707b3e55c5f59602 Add regfish as new provider. --- diff --git a/ddns.conf.sample b/ddns.conf.sample index bc41f83..610afa7 100644 --- a/ddns.conf.sample +++ b/ddns.conf.sample @@ -49,6 +49,14 @@ # 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 diff --git a/src/ddns/__init__.py b/src/ddns/__init__.py index 30a1b8a..be81fc2 100644 --- a/src/ddns/__init__.py +++ b/src/ddns/__init__.py @@ -99,6 +99,7 @@ class DDNSCore(object): DDNSProviderNOIP, DDNSProviderLightningWireLabs, DDNSProviderOVH, + DDNSProviderRegfish, DDNSProviderSelfhost, DDNSProviderSPDNS, DDNSProviderVariomedia, diff --git a/src/ddns/providers.py b/src/ddns/providers.py index e936d72..4e3d6b0 100644 --- a/src/ddns/providers.py +++ b/src/ddns/providers.py @@ -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",