]> git.ipfire.org Git - oddments/ddns.git/blobdiff - src/ddns/providers.py
dy.fi: Use HTTPS to perform updates.
[oddments/ddns.git] / src / ddns / providers.py
index 7a1d97cf5195b2e7bd3dfec587134cab2f1c5d55..f1fed2265c6c62510f3207039cf26f007fa3deca 100644 (file)
@@ -826,7 +826,7 @@ class DDNSProviderDyFi(DDNSProtocolDynDNS2, DDNSProvider):
        # https://www.dy.fi/page/clients?lang=en
        # https://www.dy.fi/page/specification?lang=en
 
-       url = "http://www.dy.fi/nic/update"
+       url = "https://www.dy.fi/nic/update"
 
        # Please only send automatic updates when your IP address changes,
        # or once per 5 to 6 days to refresh the address mapping (they will
@@ -1188,6 +1188,51 @@ class DDNSProviderJoker(DDNSProtocolDynDNS2, DDNSProvider):
                url = "https://svc.joker.com/nic/update"
 
 
+class DDNSProviderKEYSYSTEMS(DDNSProvider):
+       handle    = "key-systems.net"
+       name      = "dynamicdns.key-systems.net"
+       website   = "https://domaindiscount24.com/"
+       protocols = ("ipv4",)
+
+       # There are only information provided by the domaindiscount24 how to
+       # perform an update with HTTP APIs
+       # https://www.domaindiscount24.com/faq/dynamic-dns
+       # examples: https://dynamicdns.key-systems.net/update.php?hostname=hostname&password=password&ip=auto
+       #           https://dynamicdns.key-systems.net/update.php?hostname=hostname&password=password&ip=213.x.x.x&mx=213.x.x.x
+
+       url = "https://dynamicdns.key-systems.net/update.php"
+       can_remove_records = False
+
+       def update_protocol(self, proto):
+               address = self.get_address(proto)
+               data = {
+                       "hostname"      : self.hostname,
+                       "password"      : self.password,
+                       "ip"            : address,
+               }
+
+               # Send update to the server.
+               response = self.send_request(self.url, data=data)
+
+               # Get the full response message.
+               output = response.read().decode()
+
+               # Handle success messages.
+               if "code = 200" in output:
+                       return
+
+               # Handle error messages.
+               if "abuse prevention triggered" in output:
+                       raise DDNSAbuseError
+               elif "invalid password" in output:
+                       raise DDNSAuthenticationError
+               elif "Authorization failed" in output:
+                       raise DDNSRequestError(_("Invalid hostname specified"))
+
+               # If we got here, some other update error happened.
+               raise DDNSUpdateError
+
+
 class DDNSProviderGoogle(DDNSProtocolDynDNS2, DDNSProvider):
         handle    = "domains.google.com"
         name      = "Google Domains"
@@ -1203,7 +1248,7 @@ class DDNSProviderGoogle(DDNSProtocolDynDNS2, DDNSProvider):
 class DDNSProviderLightningWireLabs(DDNSProvider):
        handle    = "dns.lightningwirelabs.com"
        name      = "Lightning Wire Labs DNS Service"
-       website   = "http://dns.lightningwirelabs.com/"
+       website   = "https://dns.lightningwirelabs.com/"
 
        # Information about the format of the HTTPS request is to be found
        # https://dns.lightningwirelabs.com/knowledge-base/api/ddns
@@ -1211,27 +1256,17 @@ class DDNSProviderLightningWireLabs(DDNSProvider):
        url = "https://dns.lightningwirelabs.com/update"
 
        def update(self):
+               # Raise an error if no auth details are given.
+               if not self.token:
+                       raise DDNSConfigurationError
+
                data =  {
                        "hostname" : self.hostname,
+                       "token"    : self.token,
                        "address6" : self.get_address("ipv6", "-"),
                        "address4" : self.get_address("ipv4", "-"),
                }
 
-               # Check if a token has been set.
-               if self.token:
-                       data["token"] = self.token
-
-               # Check for username and password.
-               elif self.username and self.password:
-                       data.update({
-                               "username" : self.username,
-                               "password" : self.password,
-                       })
-
-               # Raise an error if no auth details are given.
-               else:
-                       raise DDNSConfigurationError
-
                # Send update to the server.
                response = self.send_request(self.url, data=data)