Update providers so they don't need to format the request URL.
[oddments/ddns.git] / ddns / providers.py
index f3230fc..124cf2f 100644 (file)
@@ -1,4 +1,23 @@
 #!/usr/bin/python
+###############################################################################
+#                                                                             #
+# ddns - A dynamic DNS client for IPFire                                      #
+# Copyright (C) 2012 IPFire development team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 # Import all possible exception types.
 from .errors import *
@@ -114,18 +133,21 @@ 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?hostname=%(hostname)s&myip=%(address)s"
+       url = "http://%(username)s:%(password)s@dynupdate.no-ip.com/nic/update"
 
        def __call__(self):
                url = self.url % {
-                       "hostname" : self.hostname,
                        "username" : self.username,
                        "password" : self.password,
+               }
+
+               data = {
+                       "hostname" : self.hostname,
                        "address"  : self.get_address("ipv4"),
                }
 
                # Send update to the server.
-               response = self.send_request(url)
+               response = self.send_request(url, data=data)
 
                # Get the full response message.
                output = response.read()
@@ -154,12 +176,16 @@ class DDNSProviderSelfhost(DDNSProvider):
                "protocols" : ["ipv4",],
        }
 
-       url = "https://carol.selfhost.de/update?username=%(username)s&password=%(password)s&textmodi=1"
+       url = "https://carol.selfhost.de/update"
 
        def __call__(self):
-               url = self.url % { "username" : self.username, "password" : self.password }
+               data = {
+                       "username" : self.username,
+                       "password" : self.password,
+                       "textmodi" : "1",
+               }
 
-               response = self.send_request(url)
+               response = self.send_request(self.url, data=data)
 
                match = re.search("status=20(0|4)", response.read())
                if not match: