From 88f39629b6c58aee3bb6825c8dadc1321a7fb70b Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 15 Jun 2014 20:40:16 +0200 Subject: [PATCH] Rebuild no-ip to inherit all required actions from dyndns. --- src/ddns/providers.py | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/src/ddns/providers.py b/src/ddns/providers.py index 8a5185f..7dca932 100644 --- a/src/ddns/providers.py +++ b/src/ddns/providers.py @@ -315,15 +315,20 @@ class DDNSProviderDynDNS(DDNSProvider): # http://dyn.com/support/developers/api/return-codes/ url = "https://members.dyndns.org/nic/update" - def update(self): + def _prepare_request_data(self): data = { "hostname" : self.hostname, "myip" : self.get_address("ipv4"), } + return data + + def update(self): + data = self._prepare_request_data() + # Send update to the server. - response = self.send_request(self.url, username=self.username, password=self.password, - data=data) + response = self.send_request(self.url, data=data, + username=self.username, password=self.password) # Get the full response message. output = response.read() @@ -420,7 +425,7 @@ class DDNSProviderLightningWireLabs(DDNSProvider): raise DDNSUpdateError -class DDNSProviderNOIP(DDNSProvider): +class DDNSProviderNOIP(DDNSProviderDynDNS): INFO = { "handle" : "no-ip.com", "name" : "No-IP", @@ -432,39 +437,15 @@ class DDNSProviderNOIP(DDNSProvider): # here: http://www.no-ip.com/integrate/request and # here: http://www.no-ip.com/integrate/response - url = "http://%(username)s:%(password)s@dynupdate.no-ip.com/nic/update" - - def update(self): - url = self.url % { - "username" : self.username, - "password" : self.password, - } + url = "http://dynupdate.no-ip.com/nic/update" + def _prepare_request_data(self): data = { "hostname" : self.hostname, "address" : self.get_address("ipv4"), } - # Send update to the server. - response = self.send_request(url, data=data) - - # Get the full response message. - output = response.read() - - # Handle success messages. - if output.startswith("good") or output.startswith("nochg"): - return - - # Handle error codes. - if output == "badauth": - raise DDNSAuthenticationError - elif output == "aduse": - raise DDNSAbuseError - elif output == "911": - raise DDNSInternalServerError - - # If we got here, some other update error happened. - raise DDNSUpdateError + return data class DDNSProviderSelfhost(DDNSProvider): -- 2.39.2