[1/2] Add new provider Servercow

Submitted by Jonatan Schlag on Feb. 10, 2017, 2:35 p.m.

Details

Message ID 1486737359-22481-1-git-send-email-jonatan.schlag@ipfire.org
State New
Headers show

Commit Message

Jonatan Schlag Feb. 10, 2017, 2:35 p.m.
Tested-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/ddns/providers.py | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/ddns/providers.py b/src/ddns/providers.py
index 2c30d42..01d7827 100644
--- a/src/ddns/providers.py
+++ b/src/ddns/providers.py
@@ -1452,6 +1452,41 @@  class DDNSProviderSelfhost(DDNSProtocolDynDNS2, DDNSProvider):
 		return data
 
 
+class DDNSProviderServercow(DDNSProvider):
+	handle    = "servercow.de"
+	name      = "servercow.de"
+	website   = "https://servercow.de/"
+	protocols = ("ipv4", "ipv6")
+
+	url = "https://www.servercow.de/dnsupdate/update.php"
+	can_remove_records = False
+
+	def update_protocol(self, proto):
+		data = {
+			"ipaddr"   : self.get_address(proto),
+			"hostname" : self.hostname,
+			"username" : self.username,
+			"pass"     : self.password,
+		}
+
+		# Send request to provider
+		response = self.send_request(self.url, data=data)
+
+		# Read response
+		output = response.read()
+
+		# Server responds with OK if update was successful
+		if output.startswith("OK"):
+			return
+
+		# Catch any errors
+		elif output.startswith("FAILED - Authentication failed"):
+			raise DDNSAuthenticationError
+
+		# If we got here, some other update error happened
+		raise DDNSUpdateError(output)
+
+
 class DDNSProviderSPDNS(DDNSProtocolDynDNS2, DDNSProvider):
 	handle    = "spdns.org"
 	name      = "SPDYN"

Comments

Michael Tremer Feb. 13, 2017, 1:01 p.m.
Hello Jonatan,

thanks for sending in this patch. I have seen this work already, so I ACK this
patch.

Reviewed-by: Michael Tremer <michael.tremer@ipfire.org>

Good work!

Best,
-Michael

On Fri, 2017-02-10 at 15:35 +0100, Jonatan Schlag wrote:
> Tested-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> ---
>  src/ddns/providers.py | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/src/ddns/providers.py b/src/ddns/providers.py
> index 2c30d42..01d7827 100644
> --- a/src/ddns/providers.py
> +++ b/src/ddns/providers.py
> @@ -1452,6 +1452,41 @@ class DDNSProviderSelfhost(DDNSProtocolDynDNS2,
> DDNSProvider):
>  		return data
>  
>  
> +class DDNSProviderServercow(DDNSProvider):
> +	handle    = "servercow.de"
> +	name      = "servercow.de"
> +	website   = "https://servercow.de/"
> +	protocols = ("ipv4", "ipv6")
> +
> +	url = "https://www.servercow.de/dnsupdate/update.php"
> +	can_remove_records = False
> +
> +	def update_protocol(self, proto):
> +		data = {
> +			"ipaddr"   : self.get_address(proto),
> +			"hostname" : self.hostname,
> +			"username" : self.username,
> +			"pass"     : self.password,
> +		}
> +
> +		# Send request to provider
> +		response = self.send_request(self.url, data=data)
> +
> +		# Read response
> +		output = response.read()
> +
> +		# Server responds with OK if update was successful
> +		if output.startswith("OK"):
> +			return
> +
> +		# Catch any errors
> +		elif output.startswith("FAILED - Authentication failed"):
> +			raise DDNSAuthenticationError
> +
> +		# If we got here, some other update error happened
> +		raise DDNSUpdateError(output)
> +
> +
>  class DDNSProviderSPDNS(DDNSProtocolDynDNS2, DDNSProvider):
>  	handle    = "spdns.org"
>  	name      = "SPDYN"