]>
git.ipfire.org Git - oddments/ddns.git/blob - src/ddns/providers.py
2 ###############################################################################
4 # ddns - A dynamic DNS client for IPFire #
5 # Copyright (C) 2012-2017 IPFire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
29 import xml
.dom
.minidom
33 # Import all possible exception types.
36 logger
= logging
.getLogger("ddns.providers")
43 Returns a dict with all automatically registered providers.
45 return _providers
.copy()
47 class DDNSProvider(object):
48 # A short string that uniquely identifies
52 # The full name of the provider.
55 # A weburl to the homepage of the provider.
56 # (Where to register a new account?)
59 # A list of supported protocols.
60 protocols
= ("ipv6", "ipv4")
64 # holdoff time - Number of days no update is performed unless
65 # the IP address has changed.
68 # holdoff time for update failures - Number of days no update
69 # is tried after the last one has failed.
70 holdoff_failure_days
= 0.5
72 # True if the provider is able to remove records, too.
73 # Required to remove AAAA records if IPv6 is absent again.
74 can_remove_records
= True
76 # True if the provider supports authentication via a random
77 # generated token instead of username and password.
78 supports_token_auth
= True
83 Should be overwritten to check if the system the code is running
84 on has all the required tools to support this provider.
88 def __init__(self
, core
, **settings
):
91 # Copy a set of default settings and
92 # update them by those from the configuration file.
93 self
.settings
= self
.DEFAULT_SETTINGS
.copy()
94 self
.settings
.update(settings
)
96 def __init_subclass__(cls
, **kwargs
):
97 super().__init
_subclass
__(**kwargs
)
99 if not all((cls
.handle
, cls
.name
, cls
.website
)):
100 raise DDNSError(_("Provider is not properly configured"))
102 assert cls
.handle
not in _providers
, \
103 "Provider '%s' has already been registered" % cls
.handle
106 _providers
[cls
.handle
] = cls
109 return "<DDNS Provider %s (%s)>" % (self
.name
, self
.handle
)
111 def __cmp__(self
, other
):
112 return (lambda a
, b
: (a
> b
)-(a
< b
))(self
.hostname
, other
.hostname
)
118 def get(self
, key
, default
=None):
120 Get a setting from the settings dictionary.
122 return self
.settings
.get(key
, default
)
127 Fast access to the hostname.
129 return self
.get("hostname")
134 Fast access to the username.
136 return self
.get("username")
141 Fast access to the password.
143 return self
.get("password")
148 Fast access to the token.
150 return self
.get("token")
152 def __call__(self
, force
=False):
154 logger
.debug(_("Updating %s forced") % self
.hostname
)
156 # Do nothing if the last update has failed or no update is required
157 elif self
.has_failure
or not self
.requires_update
:
160 # Execute the update.
164 # 1) Catch network errors early, because we do not want to log
165 # them to the database. They are usually temporary and caused
166 # by the client side, so that we will retry quickly.
167 # 2) If there is an internet server error (HTTP code 500) on the
168 # provider's site, we will not log a failure and try again
170 except (DDNSNetworkError
, DDNSInternalServerError
):
173 # In case of any errors, log the failed request and
174 # raise the exception.
175 except DDNSError
as e
:
176 self
.core
.db
.log_failure(self
.hostname
, e
)
179 logger
.info(_("Dynamic DNS update for %(hostname)s (%(provider)s) successful") %
180 {"hostname": self
.hostname
, "provider": self
.name
})
181 self
.core
.db
.log_success(self
.hostname
)
184 for protocol
in self
.protocols
:
185 if self
.have_address(protocol
):
186 self
.update_protocol(protocol
)
187 elif self
.can_remove_records
:
188 self
.remove_protocol(protocol
)
190 def update_protocol(self
, proto
):
191 raise NotImplementedError
193 def remove_protocol(self
, proto
):
194 if not self
.can_remove_records
:
195 raise RuntimeError("can_remove_records is enabled, but remove_protocol() not implemented")
197 raise NotImplementedError
200 def requires_update(self
):
201 # If the IP addresses have changed, an update is required
202 if self
.ip_address_changed(self
.protocols
):
203 logger
.debug(_("An update for %(hostname)s (%(provider)s) is performed because of an IP address change") %
204 {"hostname": self
.hostname
, "provider": self
.name
})
208 # If the holdoff time has expired, an update is required, too
209 if self
.holdoff_time_expired():
210 logger
.debug(_("An update for %(hostname)s (%(provider)s) is performed because the holdoff time has expired") %
211 {"hostname": self
.hostname
, "provider": self
.name
})
215 # Otherwise, we don't need to perform an update
216 logger
.debug(_("No update required for %(hostname)s (%(provider)s)") %
217 {"hostname": self
.hostname
, "provider": self
.name
})
222 def has_failure(self
):
224 Returns True when the last update has failed and no retry
225 should be performed, yet.
227 last_status
= self
.db
.last_update_status(self
.hostname
)
229 # Return False if the last update has not failed.
230 if not last_status
== "failure":
233 # If there is no holdoff time, we won't update ever again.
234 if self
.holdoff_failure_days
is None:
235 logger
.warning(_("An update has not been performed because earlier updates failed for %s") % self
.hostname
)
236 logger
.warning(_("There will be no retries"))
240 # Determine when the holdoff time ends
241 last_update
= self
.db
.last_update(self
.hostname
, status
=last_status
)
242 holdoff_end
= last_update
+ datetime
.timedelta(days
=self
.holdoff_failure_days
)
244 now
= datetime
.datetime
.utcnow()
245 if now
< holdoff_end
:
246 failure_message
= self
.db
.last_update_failure_message(self
.hostname
)
248 logger
.warning(_("An update has not been performed because earlier updates failed for %s") % self
.hostname
)
251 logger
.warning(_("Last failure message:"))
253 for line
in failure_message
.splitlines():
254 logger
.warning(" %s" % line
)
256 logger
.warning(_("Further updates will be withheld until %s") % holdoff_end
)
262 def ip_address_changed(self
, protos
):
264 Returns True if this host is already up to date
265 and does not need to change the IP address on the
269 addresses
= self
.core
.system
.resolve(self
.hostname
, proto
)
270 current_address
= self
.get_address(proto
)
272 # Handle if the system has not got any IP address from a protocol
273 # (i.e. had full dual-stack connectivity which it has not any more)
274 if current_address
is None:
275 # If addresses still exists in the DNS system and if this provider
276 # is able to remove records, we will do that.
277 if addresses
and self
.can_remove_records
:
280 # Otherwise, we cannot go on...
283 if not current_address
in addresses
:
288 def holdoff_time_expired(self
):
290 Returns true if the holdoff time has expired
291 and the host requires an update
293 # If no holdoff days is defined, we cannot go on
294 if not self
.holdoff_days
:
297 # Get the timestamp of the last successfull update
298 last_update
= self
.db
.last_update(self
.hostname
, status
="success")
300 # If no timestamp has been recorded, no update has been
301 # performed. An update should be performed now.
305 # Determine when the holdoff time ends
306 holdoff_end
= last_update
+ datetime
.timedelta(days
=self
.holdoff_days
)
308 now
= datetime
.datetime
.utcnow()
310 if now
>= holdoff_end
:
311 logger
.debug("The holdoff time has expired for %s" % self
.hostname
)
314 logger
.debug("Updates for %s are held off until %s" %
315 (self
.hostname
, holdoff_end
))
318 def send_request(self
, *args
, **kwargs
):
320 Proxy connection to the send request
323 return self
.core
.system
.send_request(*args
, **kwargs
)
325 def get_address(self
, proto
, default
=None):
327 Proxy method to get the current IP address.
329 return self
.core
.system
.get_address(proto
) or default
331 def have_address(self
, proto
):
333 Returns True if an IP address for the given protocol
336 address
= self
.get_address(proto
)
344 class DDNSProtocolDynDNS2(object):
346 This is an abstract class that implements the DynDNS updater
347 protocol version 2. As this is a popular way to update dynamic
348 DNS records, this class is supposed make the provider classes
352 # Information about the format of the request is to be found
353 # http://dyn.com/support/developers/api/perform-update/
354 # http://dyn.com/support/developers/api/return-codes/
356 # The DynDNS protocol version 2 does not allow to remove records
357 can_remove_records
= False
359 # The DynDNS protocol version 2 only supports authentication via
360 # username and password.
361 supports_token_auth
= False
363 def prepare_request_data(self
, proto
):
365 "hostname" : self
.hostname
,
366 "myip" : self
.get_address(proto
),
371 def update_protocol(self
, proto
):
372 data
= self
.prepare_request_data(proto
)
374 return self
.send_request(data
)
376 def send_request(self
, data
):
377 # Send update to the server.
378 response
= DDNSProvider
.send_request(self
, self
.url
, data
=data
, username
=self
.username
, password
=self
.password
)
380 # Get the full response message.
381 output
= response
.read().decode()
383 # Handle success messages.
384 if output
.startswith("good") or output
.startswith("nochg"):
387 # Handle error codes.
388 if output
== "badauth":
389 raise DDNSAuthenticationError
390 elif output
== "abuse":
392 elif output
== "notfqdn":
393 raise DDNSRequestError(_("No valid FQDN was given"))
394 elif output
== "nohost":
395 raise DDNSRequestError(_("Specified host does not exist"))
396 elif output
== "911":
397 raise DDNSInternalServerError
398 elif output
== "dnserr":
399 raise DDNSInternalServerError(_("DNS error encountered"))
400 elif output
== "badagent":
401 raise DDNSBlockedError
402 elif output
== "badip":
403 raise DDNSBlockedError
405 # If we got here, some other update error happened.
406 raise DDNSUpdateError(_("Server response: %s") % output
)
409 class DDNSResponseParserXML(object):
411 This class provides a parser for XML responses which
412 will be sent by various providers. This class uses the python
413 shipped XML minidom module to walk through the XML tree and return
417 def get_xml_tag_value(self
, document
, content
):
418 # Send input to the parser.
419 xmldoc
= xml
.dom
.minidom
.parseString(document
)
421 # Get XML elements by the given content.
422 element
= xmldoc
.getElementsByTagName(content
)
424 # If no element has been found, we directly can return None.
428 # Only get the first child from an element, even there are more than one.
429 firstchild
= element
[0].firstChild
431 # Get the value of the child.
432 value
= firstchild
.nodeValue
438 class DDNSProviderAllInkl(DDNSProvider
):
439 handle
= "all-inkl.com"
440 name
= "All-inkl.com"
441 website
= "http://all-inkl.com/"
442 protocols
= ("ipv4",)
444 # There are only information provided by the vendor how to
445 # perform an update on a FRITZ Box. Grab requried informations
447 # http://all-inkl.goetze.it/v01/ddns-mit-einfachen-mitteln/
449 url
= "http://dyndns.kasserver.com"
450 can_remove_records
= False
451 supports_token_auth
= False
454 # There is no additional data required so we directly can
456 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
)
458 # Get the full response message.
459 output
= response
.read().decode()
461 # Handle success messages.
462 if output
.startswith("good") or output
.startswith("nochg"):
465 # If we got here, some other update error happened.
466 raise DDNSUpdateError
469 class DDNSProviderBindNsupdate(DDNSProvider
):
471 name
= "BIND nsupdate utility"
472 website
= "http://en.wikipedia.org/wiki/Nsupdate"
476 supports_token_auth
= False
480 # Search if the nsupdate utility is available
481 paths
= os
.environ
.get("PATH")
483 for path
in paths
.split(":"):
484 executable
= os
.path
.join(path
, "nsupdate")
486 if os
.path
.exists(executable
):
492 scriptlet
= self
.__make
_scriptlet
()
494 # -v enables TCP hence we transfer keys and other data that may
495 # exceed the size of one packet.
496 # -t sets the timeout
497 command
= ["nsupdate", "-v", "-t", "60"]
499 p
= subprocess
.Popen(command
, shell
=True, stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
500 stdout
, stderr
= p
.communicate(scriptlet
)
502 if p
.returncode
== 0:
505 raise DDNSError("nsupdate terminated with error code: %s\n %s" % (p
.returncode
, stderr
))
507 def __make_scriptlet(self
):
510 # Set a different server the update is sent to.
511 server
= self
.get("server", None)
513 scriptlet
.append("server %s" % server
)
515 # Set the DNS zone the host should be added to.
516 zone
= self
.get("zone", None)
518 scriptlet
.append("zone %s" % zone
)
520 key
= self
.get("key", None)
522 secret
= self
.get("secret")
524 scriptlet
.append("key %s %s" % (key
, secret
))
526 ttl
= self
.get("ttl", self
.DEFAULT_TTL
)
528 # Perform an update for each supported protocol.
529 for rrtype
, proto
in (("AAAA", "ipv6"), ("A", "ipv4")):
530 address
= self
.get_address(proto
)
534 scriptlet
.append("update delete %s. %s" % (self
.hostname
, rrtype
))
535 scriptlet
.append("update add %s. %s %s %s" % \
536 (self
.hostname
, ttl
, rrtype
, address
))
538 # Send the actions to the server.
539 scriptlet
.append("send")
540 scriptlet
.append("quit")
542 logger
.debug(_("Scriptlet:"))
543 for line
in scriptlet
:
544 # Masquerade the line with the secret key.
545 if line
.startswith("key"):
546 line
= "key **** ****"
548 logger
.debug(" %s" % line
)
550 return "\n".join(scriptlet
).encode()
553 class DDNSProviderChangeIP(DDNSProvider
):
554 handle
= "changeip.com"
555 name
= "ChangeIP.com"
556 website
= "https://changeip.com"
557 protocols
= ("ipv4",)
559 # Detailed information about the update api can be found here.
560 # http://www.changeip.com/accounts/knowledgebase.php?action=displayarticle&id=34
562 url
= "https://nic.changeip.com/nic/update"
563 can_remove_records
= False
564 supports_token_auth
= False
566 def update_protocol(self
, proto
):
568 "hostname" : self
.hostname
,
569 "myip" : self
.get_address(proto
),
572 # Send update to the server.
574 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
, data
=data
)
576 # Handle error codes.
577 except urllib
.error
.HTTPError
as e
:
579 raise DDNSRequestError(_("Domain not found."))
583 # Handle success message.
584 if response
.code
== 200:
587 # If we got here, some other update error happened.
588 raise DDNSUpdateError(_("Server response: %s") % output
)
591 class DDNSProviderDesecIO(DDNSProtocolDynDNS2
, DDNSProvider
):
594 website
= "https://www.desec.io"
595 protocols
= ("ipv6", "ipv4",)
597 # ipv4 / ipv6 records are automatically removed when the update
598 # request originates from the respectively other protocol and no
599 # address is explicitly provided for the unused protocol.
601 url
= "https://update.dedyn.io"
603 # desec.io sends the IPv6 and IPv4 address in one request
606 data
= DDNSProtocolDynDNS2
.prepare_request_data(self
, "ipv4")
608 # This one supports IPv6
609 myipv6
= self
.get_address("ipv6")
611 # Add update information if we have an IPv6 address.
613 data
["myipv6"] = myipv6
615 self
.send_request(data
)
618 class DDNSProviderDDNSS(DDNSProvider
):
621 website
= "http://www.ddnss.de"
622 protocols
= ("ipv4",)
624 # Detailed information about how to send the update request and possible response
625 # codes can be obtained from here.
626 # http://www.ddnss.de/info.php
627 # http://www.megacomputing.de/2014/08/dyndns-service-response-time/#more-919
629 url
= "http://www.ddnss.de/upd.php"
630 can_remove_records
= False
631 supports_token_auth
= False
633 def update_protocol(self
, proto
):
635 "ip" : self
.get_address(proto
),
636 "host" : self
.hostname
,
639 # Check if a token has been set.
641 data
["key"] = self
.token
643 # Check if username and hostname are given.
644 elif self
.username
and self
.password
:
646 "user" : self
.username
,
647 "pwd" : self
.password
,
650 # Raise an error if no auth details are given.
652 raise DDNSConfigurationError
654 # Send update to the server.
655 response
= self
.send_request(self
.url
, data
=data
)
657 # This provider sends the response code as part of the header.
658 # Get status information from the header.
659 output
= response
.getheader('ddnss-response')
661 # Handle success messages.
662 if output
== "good" or output
== "nochg":
665 # Handle error codes.
666 if output
== "badauth":
667 raise DDNSAuthenticationError
668 elif output
== "notfqdn":
669 raise DDNSRequestError(_("No valid FQDN was given"))
670 elif output
== "nohost":
671 raise DDNSRequestError(_("Specified host does not exist"))
672 elif output
== "911":
673 raise DDNSInternalServerError
674 elif output
== "dnserr":
675 raise DDNSInternalServerError(_("DNS error encountered"))
676 elif output
== "disabled":
677 raise DDNSRequestError(_("Account disabled or locked"))
679 # If we got here, some other update error happened.
680 raise DDNSUpdateError
683 class DDNSProviderDHS(DDNSProvider
):
685 name
= "DHS International"
686 website
= "http://dhs.org/"
687 protocols
= ("ipv4",)
689 # No information about the used update api provided on webpage,
690 # grabed from source code of ez-ipudate.
692 url
= "http://members.dhs.org/nic/hosts"
693 can_remove_records
= False
694 supports_token_auth
= False
696 def update_protocol(self
, proto
):
698 "domain" : self
.hostname
,
699 "ip" : self
.get_address(proto
),
701 "hostcmdstage" : "2",
705 # Send update to the server.
706 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
, data
=data
)
708 # Handle success messages.
709 if response
.code
== 200:
712 # If we got here, some other update error happened.
713 raise DDNSUpdateError
716 class DDNSProviderDNSpark(DDNSProvider
):
717 handle
= "dnspark.com"
719 website
= "http://dnspark.com/"
720 protocols
= ("ipv4",)
722 # Informations to the used api can be found here:
723 # https://dnspark.zendesk.com/entries/31229348-Dynamic-DNS-API-Documentation
725 url
= "https://control.dnspark.com/api/dynamic/update.php"
726 can_remove_records
= False
727 supports_token_auth
= False
729 def update_protocol(self
, proto
):
731 "domain" : self
.hostname
,
732 "ip" : self
.get_address(proto
),
735 # Send update to the server.
736 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
, data
=data
)
738 # Get the full response message.
739 output
= response
.read().decode()
741 # Handle success messages.
742 if output
.startswith("ok") or output
.startswith("nochange"):
745 # Handle error codes.
746 if output
== "unauth":
747 raise DDNSAuthenticationError
748 elif output
== "abuse":
750 elif output
== "blocked":
751 raise DDNSBlockedError
752 elif output
== "nofqdn":
753 raise DDNSRequestError(_("No valid FQDN was given"))
754 elif output
== "nohost":
755 raise DDNSRequestError(_("Invalid hostname specified"))
756 elif output
== "notdyn":
757 raise DDNSRequestError(_("Hostname not marked as a dynamic host"))
758 elif output
== "invalid":
759 raise DDNSRequestError(_("Invalid IP address has been sent"))
761 # If we got here, some other update error happened.
762 raise DDNSUpdateError
765 class DDNSProviderDtDNS(DDNSProvider
):
768 website
= "http://dtdns.com/"
769 protocols
= ("ipv4",)
771 # Information about the format of the HTTPS request is to be found
772 # http://www.dtdns.com/dtsite/updatespec
774 url
= "https://www.dtdns.com/api/autodns.cfm"
775 can_remove_records
= False
776 supports_token_auth
= False
778 def update_protocol(self
, proto
):
780 "ip" : self
.get_address(proto
),
781 "id" : self
.hostname
,
785 # Send update to the server.
786 response
= self
.send_request(self
.url
, data
=data
)
788 # Get the full response message.
789 output
= response
.read().decode()
791 # Remove all leading and trailing whitespace.
792 output
= output
.strip()
794 # Handle success messages.
795 if "now points to" in output
:
798 # Handle error codes.
799 if output
== "No hostname to update was supplied.":
800 raise DDNSRequestError(_("No hostname specified"))
802 elif output
== "The hostname you supplied is not valid.":
803 raise DDNSRequestError(_("Invalid hostname specified"))
805 elif output
== "The password you supplied is not valid.":
806 raise DDNSAuthenticationError
808 elif output
== "Administration has disabled this account.":
809 raise DDNSRequestError(_("Account has been disabled"))
811 elif output
== "Illegal character in IP.":
812 raise DDNSRequestError(_("Invalid IP address has been sent"))
814 elif output
== "Too many failed requests.":
815 raise DDNSRequestError(_("Too many failed requests"))
817 # If we got here, some other update error happened.
818 raise DDNSUpdateError
821 class DDNSProviderDuckDNS(DDNSProvider
):
822 handle
= "duckdns.org"
824 website
= "http://www.duckdns.org/"
825 protocols
= ("ipv6", "ipv4",)
827 # Information about the format of the request is to be found
828 # https://www.duckdns.org/spec.jsp
830 url
= "https://www.duckdns.org/update"
831 can_remove_records
= False
832 supports_token_auth
= True
835 # Raise an error if no auth details are given.
837 raise DDNSConfigurationError
840 "domains" : self
.hostname
,
841 "token" : self
.token
,
844 # Check if we update an IPv4 address.
845 address4
= self
.get_address("ipv4")
847 data
["ip"] = address4
849 # Check if we update an IPv6 address.
850 address6
= self
.get_address("ipv6")
852 data
["ipv6"] = address6
854 # Raise an error if no address is given.
855 if "ip" not in data
and "ipv6" not in data
:
856 raise DDNSConfigurationError
858 # Send update to the server.
859 response
= self
.send_request(self
.url
, data
=data
)
861 # Get the full response message.
862 output
= response
.read().decode()
864 # Remove all leading and trailing whitespace.
865 output
= output
.strip()
867 # Handle success messages.
871 # The provider does not give detailed information
872 # if the update fails. Only a "KO" will be sent back.
874 raise DDNSUpdateError
876 # If we got here, some other update error happened.
877 raise DDNSUpdateError
880 class DDNSProviderDyFi(DDNSProtocolDynDNS2
, DDNSProvider
):
883 website
= "https://www.dy.fi/"
884 protocols
= ("ipv4",)
886 # Information about the format of the request is to be found
887 # https://www.dy.fi/page/clients?lang=en
888 # https://www.dy.fi/page/specification?lang=en
890 url
= "https://www.dy.fi/nic/update"
892 # Please only send automatic updates when your IP address changes,
893 # or once per 5 to 6 days to refresh the address mapping (they will
894 # expire if not refreshed within 7 days).
898 class DDNSProviderDynDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
899 handle
= "dyndns.org"
901 website
= "http://dyn.com/dns/"
902 protocols
= ("ipv4",)
904 # Information about the format of the request is to be found
905 # http://http://dyn.com/support/developers/api/perform-update/
906 # http://dyn.com/support/developers/api/return-codes/
908 url
= "https://members.dyndns.org/nic/update"
911 class DDNSProviderDomainOffensive(DDNSProtocolDynDNS2
, DDNSProvider
):
913 name
= "Domain-Offensive"
914 website
= "https://www.do.de/"
915 protocols
= ("ipv6", "ipv4")
917 # Detailed information about the request and response codes
918 # are available on the providers webpage.
919 # https://www.do.de/wiki/FlexDNS_-_Entwickler
921 url
= "https://ddns.do.de/"
923 class DDNSProviderDynUp(DDNSProvider
):
926 website
= "http://dynup.de/"
927 protocols
= ("ipv4",)
929 # Information about the format of the HTTPS request is to be found
930 # https://dyndnsfree.de/user/hilfe.php
932 url
= "https://dynup.de/dyn.php"
933 can_remove_records
= False
934 supports_token_auth
= False
936 def update_protocol(self
, proto
):
938 "username" : self
.username
,
939 "password" : self
.password
,
940 "hostname" : self
.hostname
,
944 # Send update to the server.
945 response
= self
.send_request(self
.url
, data
=data
)
947 # Get the full response message.
948 output
= response
.read().decode()
950 # Remove all leading and trailing whitespace.
951 output
= output
.strip()
953 # Handle success messages.
954 if output
.startswith("I:OK"):
957 # If we got here, some other update error happened.
958 raise DDNSUpdateError
961 class DDNSProviderDynU(DDNSProtocolDynDNS2
, DDNSProvider
):
964 website
= "http://dynu.com/"
965 protocols
= ("ipv6", "ipv4",)
967 # Detailed information about the request and response codes
968 # are available on the providers webpage.
969 # http://dynu.com/Default.aspx?page=dnsapi
971 url
= "https://api.dynu.com/nic/update"
973 # DynU sends the IPv6 and IPv4 address in one request
976 data
= DDNSProtocolDynDNS2
.prepare_request_data(self
, "ipv4")
978 # This one supports IPv6
979 myipv6
= self
.get_address("ipv6")
981 # Add update information if we have an IPv6 address.
983 data
["myipv6"] = myipv6
985 self
.send_request(data
)
988 class DDNSProviderEasyDNS(DDNSProvider
):
989 handle
= "easydns.com"
991 website
= "http://www.easydns.com/"
992 protocols
= ("ipv4",)
994 # Detailed information about the request and response codes
995 # (API 1.3) are available on the providers webpage.
996 # https://fusion.easydns.com/index.php?/Knowledgebase/Article/View/102/7/dynamic-dns
998 url
= "http://api.cp.easydns.com/dyn/tomato.php"
1000 supports_token_auth
= False
1002 def update_protocol(self
, proto
):
1004 "myip" : self
.get_address(proto
, "-"),
1005 "hostname" : self
.hostname
,
1008 # Send update to the server.
1009 response
= self
.send_request(self
.url
, data
=data
, username
=self
.username
, password
=self
.password
)
1011 # Get the full response message.
1012 output
= response
.read().decode()
1014 # Remove all leading and trailing whitespace.
1015 output
= output
.strip()
1017 # Handle success messages.
1018 if output
.startswith("NOERROR"):
1021 # Handle error codes.
1022 if output
.startswith("NOACCESS"):
1023 raise DDNSAuthenticationError
1025 elif output
.startswith("NOSERVICE"):
1026 raise DDNSRequestError(_("Dynamic DNS is not turned on for this domain"))
1028 elif output
.startswith("ILLEGAL INPUT"):
1029 raise DDNSRequestError(_("Invalid data has been sent"))
1031 elif output
.startswith("TOOSOON"):
1032 raise DDNSRequestError(_("Too frequent update requests have been sent"))
1034 # If we got here, some other update error happened.
1035 raise DDNSUpdateError
1038 class DDNSProviderDomopoli(DDNSProtocolDynDNS2
, DDNSProvider
):
1039 handle
= "domopoli.de"
1040 name
= "domopoli.de"
1041 website
= "http://domopoli.de/"
1042 protocols
= ("ipv4",)
1044 # https://www.domopoli.de/?page=howto#DynDns_start
1046 url
= "http://dyndns.domopoli.de/nic/update"
1049 class DDNSProviderDynsNet(DDNSProvider
):
1052 website
= "http://www.dyns.net/"
1053 protocols
= ("ipv4",)
1054 can_remove_records
= False
1055 supports_token_auth
= False
1057 # There is very detailed informatio about how to send the update request and
1058 # the possible response codes. (Currently we are using the v1.1 proto)
1059 # http://www.dyns.net/documentation/technical/protocol/
1061 url
= "http://www.dyns.net/postscript011.php"
1063 def update_protocol(self
, proto
):
1065 "ip" : self
.get_address(proto
),
1066 "host" : self
.hostname
,
1067 "username" : self
.username
,
1068 "password" : self
.password
,
1071 # Send update to the server.
1072 response
= self
.send_request(self
.url
, data
=data
)
1074 # Get the full response message.
1075 output
= response
.read().decode()
1077 # Handle success messages.
1078 if output
.startswith("200"):
1081 # Handle error codes.
1082 if output
.startswith("400"):
1083 raise DDNSRequestError(_("Malformed request has been sent"))
1084 elif output
.startswith("401"):
1085 raise DDNSAuthenticationError
1086 elif output
.startswith("402"):
1087 raise DDNSRequestError(_("Too frequent update requests have been sent"))
1088 elif output
.startswith("403"):
1089 raise DDNSInternalServerError
1091 # If we got here, some other update error happened.
1092 raise DDNSUpdateError(_("Server response: %s") % output
)
1095 class DDNSProviderEnomCom(DDNSResponseParserXML
, DDNSProvider
):
1098 website
= "http://www.enom.com/"
1099 protocols
= ("ipv4",)
1101 # There are very detailed information about how to send an update request and
1102 # the respone codes.
1103 # http://www.enom.com/APICommandCatalog/
1105 url
= "https://dynamic.name-services.com/interface.asp"
1106 can_remove_records
= False
1107 supports_token_auth
= False
1109 def update_protocol(self
, proto
):
1111 "command" : "setdnshost",
1112 "responsetype" : "xml",
1113 "address" : self
.get_address(proto
),
1114 "domainpassword" : self
.password
,
1115 "zone" : self
.hostname
1118 # Send update to the server.
1119 response
= self
.send_request(self
.url
, data
=data
)
1121 # Get the full response message.
1122 output
= response
.read().decode()
1124 # Handle success messages.
1125 if self
.get_xml_tag_value(output
, "ErrCount") == "0":
1128 # Handle error codes.
1129 errorcode
= self
.get_xml_tag_value(output
, "ResponseNumber")
1131 if errorcode
== "304155":
1132 raise DDNSAuthenticationError
1133 elif errorcode
== "304153":
1134 raise DDNSRequestError(_("Domain not found"))
1136 # If we got here, some other update error happened.
1137 raise DDNSUpdateError
1140 class DDNSProviderEntryDNS(DDNSProvider
):
1141 handle
= "entrydns.net"
1143 website
= "http://entrydns.net/"
1144 protocols
= ("ipv4",)
1146 # Some very tiny details about their so called "Simple API" can be found
1147 # here: https://entrydns.net/help
1148 url
= "https://entrydns.net/records/modify"
1149 can_remove_records
= False
1150 supports_token_auth
= True
1152 def update_protocol(self
, proto
):
1154 "ip" : self
.get_address(proto
),
1157 # Add auth token to the update url.
1158 url
= "%s/%s" % (self
.url
, self
.token
)
1160 # Send update to the server.
1162 response
= self
.send_request(url
, data
=data
)
1164 # Handle error codes
1165 except urllib
.error
.HTTPError
as e
:
1167 raise DDNSAuthenticationError
1170 raise DDNSRequestError(_("An invalid IP address was submitted"))
1174 # Handle success messages.
1175 if response
.code
== 200:
1178 # If we got here, some other update error happened.
1179 raise DDNSUpdateError
1182 class DDNSProviderFreeDNSAfraidOrg(DDNSProvider
):
1183 handle
= "freedns.afraid.org"
1184 name
= "freedns.afraid.org"
1185 website
= "http://freedns.afraid.org/"
1187 # No information about the request or response could be found on the vendor
1188 # page. All used values have been collected by testing.
1189 url
= "https://freedns.afraid.org/dynamic/update.php"
1190 can_remove_records
= False
1191 supports_token_auth
= True
1193 def update_protocol(self
, proto
):
1195 "address" : self
.get_address(proto
),
1198 # Add auth token to the update url.
1199 url
= "%s?%s" % (self
.url
, self
.token
)
1201 # Send update to the server.
1202 response
= self
.send_request(url
, data
=data
)
1204 # Get the full response message.
1205 output
= response
.read().decode()
1207 # Handle success messages.
1208 if output
.startswith("Updated") or "has not changed" in output
:
1211 # Handle error codes.
1212 if output
== "ERROR: Unable to locate this record":
1213 raise DDNSAuthenticationError
1214 elif "is an invalid IP address" in output
:
1215 raise DDNSRequestError(_("Invalid IP address has been sent"))
1217 # If we got here, some other update error happened.
1218 raise DDNSUpdateError
1221 class DDNSProviderItsdns(DDNSProtocolDynDNS2
, DDNSProvider
):
1224 website
= "https://www.inwx.com"
1225 protocols
= ("ipv6", "ipv4")
1227 # Information about the format of the HTTP request is to be found
1228 # here: https://www.inwx.com/en/nameserver2/dyndns (requires login)
1229 # Notice: The URL is the same for: inwx.com|de|at|ch|es
1231 url
= "https://dyndns.inwx.com/nic/update"
1234 class DDNSProviderItsdns(DDNSProtocolDynDNS2
, DDNSProvider
):
1235 handle
= "itsdns.de"
1237 website
= "http://www.itsdns.de/"
1238 protocols
= ("ipv6", "ipv4")
1240 # Information about the format of the HTTP request is to be found
1241 # here: https://www.itsdns.de/dynupdatehelp.htm
1243 url
= "https://www.itsdns.de/update.php"
1246 class DDNSProviderJoker(DDNSProtocolDynDNS2
, DDNSProvider
):
1247 handle
= "joker.com"
1248 name
= "Joker.com Dynamic DNS"
1249 website
= "https://joker.com/"
1250 protocols
= ("ipv4",)
1252 # Information about the request can be found here:
1253 # https://joker.com/faq/content/11/427/en/what-is-dynamic-dns-dyndns.html
1254 # Using DynDNS V2 protocol over HTTPS here
1256 url
= "https://svc.joker.com/nic/update"
1259 class DDNSProviderKEYSYSTEMS(DDNSProvider
):
1260 handle
= "key-systems.net"
1261 name
= "dynamicdns.key-systems.net"
1262 website
= "https://domaindiscount24.com/"
1263 protocols
= ("ipv4",)
1265 # There are only information provided by the domaindiscount24 how to
1266 # perform an update with HTTP APIs
1267 # https://www.domaindiscount24.com/faq/dynamic-dns
1268 # examples: https://dynamicdns.key-systems.net/update.php?hostname=hostname&password=password&ip=auto
1269 # https://dynamicdns.key-systems.net/update.php?hostname=hostname&password=password&ip=213.x.x.x&mx=213.x.x.x
1271 url
= "https://dynamicdns.key-systems.net/update.php"
1272 can_remove_records
= False
1273 supports_token_auth
= False
1275 def update_protocol(self
, proto
):
1276 address
= self
.get_address(proto
)
1278 "hostname" : self
.hostname
,
1279 "password" : self
.password
,
1283 # Send update to the server.
1284 response
= self
.send_request(self
.url
, data
=data
)
1286 # Get the full response message.
1287 output
= response
.read().decode()
1289 # Handle success messages.
1290 if "code = 200" in output
:
1293 # Handle error messages.
1294 if "abuse prevention triggered" in output
:
1295 raise DDNSAbuseError
1296 elif "invalid password" in output
:
1297 raise DDNSAuthenticationError
1298 elif "Authorization failed" in output
:
1299 raise DDNSRequestError(_("Invalid hostname specified"))
1301 # If we got here, some other update error happened.
1302 raise DDNSUpdateError
1305 class DDNSProviderGoogle(DDNSProtocolDynDNS2
, DDNSProvider
):
1306 handle
= "domains.google.com"
1307 name
= "Google Domains"
1308 website
= "https://domains.google.com/"
1309 protocols
= ("ipv4",)
1311 # Information about the format of the HTTP request is to be found
1312 # here: https://support.google.com/domains/answer/6147083?hl=en
1314 url
= "https://domains.google.com/nic/update"
1317 class DDNSProviderLightningWireLabs(DDNSProvider
):
1318 handle
= "dns.lightningwirelabs.com"
1319 name
= "Lightning Wire Labs DNS Service"
1320 website
= "https://dns.lightningwirelabs.com/"
1322 # Information about the format of the HTTPS request is to be found
1323 # https://dns.lightningwirelabs.com/knowledge-base/api/ddns
1325 supports_token_auth
= True
1327 url
= "https://dns.lightningwirelabs.com/update"
1330 # Raise an error if no auth details are given.
1332 raise DDNSConfigurationError
1335 "hostname" : self
.hostname
,
1336 "token" : self
.token
,
1337 "address6" : self
.get_address("ipv6", "-"),
1338 "address4" : self
.get_address("ipv4", "-"),
1341 # Send update to the server.
1342 response
= self
.send_request(self
.url
, data
=data
)
1344 # Handle success messages.
1345 if response
.code
== 200:
1348 # If we got here, some other update error happened.
1349 raise DDNSUpdateError
1352 class DDNSProviderLoopia(DDNSProtocolDynDNS2
, DDNSProvider
):
1353 handle
= "loopia.se"
1355 website
= "https://www.loopia.com"
1356 protocols
= ("ipv4",)
1358 # Information about the format of the HTTP request is to be found
1359 # here: https://support.loopia.com/wiki/About_the_DynDNS_support
1361 url
= "https://dns.loopia.se/XDynDNSServer/XDynDNS.php"
1364 class DDNSProviderMyOnlinePortal(DDNSProtocolDynDNS2
, DDNSProvider
):
1365 handle
= "myonlineportal.net"
1366 name
= "myonlineportal.net"
1367 website
= "https:/myonlineportal.net/"
1369 # Information about the request and response can be obtained here:
1370 # https://myonlineportal.net/howto_dyndns
1372 url
= "https://myonlineportal.net/updateddns"
1374 def prepare_request_data(self
, proto
):
1376 "hostname" : self
.hostname
,
1377 "ip" : self
.get_address(proto
),
1383 class DDNSProviderNamecheap(DDNSResponseParserXML
, DDNSProvider
):
1384 handle
= "namecheap.com"
1386 website
= "http://namecheap.com"
1387 protocols
= ("ipv4",)
1389 # Information about the format of the HTTP request is to be found
1390 # https://www.namecheap.com/support/knowledgebase/article.aspx/9249/0/nc-dynamic-dns-to-dyndns-adapter
1391 # https://community.namecheap.com/forums/viewtopic.php?f=6&t=6772
1393 url
= "https://dynamicdns.park-your-domain.com/update"
1394 can_remove_records
= False
1395 supports_token_auth
= False
1397 def update_protocol(self
, proto
):
1398 # Namecheap requires the hostname splitted into a host and domain part.
1399 host
, domain
= self
.hostname
.split(".", 1)
1401 # Get and store curent IP address.
1402 address
= self
.get_address(proto
)
1406 "password" : self
.password
,
1411 # Send update to the server.
1412 response
= self
.send_request(self
.url
, data
=data
)
1414 # Get the full response message.
1415 output
= response
.read().decode()
1417 # Handle success messages.
1418 if self
.get_xml_tag_value(output
, "IP") == address
:
1421 # Handle error codes.
1422 errorcode
= self
.get_xml_tag_value(output
, "ResponseNumber")
1424 if errorcode
== "304156":
1425 raise DDNSAuthenticationError
1426 elif errorcode
== "316153":
1427 raise DDNSRequestError(_("Domain not found"))
1428 elif errorcode
== "316154":
1429 raise DDNSRequestError(_("Domain not active"))
1430 elif errorcode
in ("380098", "380099"):
1431 raise DDNSInternalServerError
1433 # If we got here, some other update error happened.
1434 raise DDNSUpdateError
1437 class DDNSProviderNOIP(DDNSProtocolDynDNS2
, DDNSProvider
):
1438 handle
= "no-ip.com"
1440 website
= "http://www.noip.com/"
1441 protocols
= ("ipv4",)
1443 # Information about the format of the HTTP request is to be found
1444 # here: http://www.noip.com/integrate/request and
1445 # here: http://www.noip.com/integrate/response
1447 url
= "http://dynupdate.noip.com/nic/update"
1449 def prepare_request_data(self
, proto
):
1450 assert proto
== "ipv4"
1453 "hostname" : self
.hostname
,
1454 "address" : self
.get_address(proto
),
1460 class DDNSProviderNowDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
1461 handle
= "now-dns.com"
1463 website
= "http://now-dns.com/"
1464 protocols
= ("ipv6", "ipv4")
1466 # Information about the format of the request is to be found
1467 # but only can be accessed by register an account and login
1468 # https://now-dns.com/?m=api
1470 url
= "https://now-dns.com/update"
1473 class DDNSProviderNsupdateINFO(DDNSProtocolDynDNS2
, DDNSProvider
):
1474 handle
= "nsupdate.info"
1475 name
= "nsupdate.info"
1476 website
= "http://nsupdate.info/"
1477 protocols
= ("ipv6", "ipv4",)
1479 # Information about the format of the HTTP request can be found
1480 # after login on the provider user interface and here:
1481 # http://nsupdateinfo.readthedocs.org/en/latest/user.html
1483 url
= "https://nsupdate.info/nic/update"
1485 # TODO nsupdate.info can actually do this, but the functionality
1486 # has not been implemented here, yet.
1487 can_remove_records
= False
1489 supports_token_auth
= True
1491 # After a failed update, there will be no retries
1492 # https://bugzilla.ipfire.org/show_bug.cgi?id=10603
1493 holdoff_failure_days
= None
1495 # Nsupdate.info uses the hostname as user part for the HTTP basic auth,
1496 # and for the password a so called secret.
1499 return self
.get("hostname")
1503 return self
.token
or self
.get("secret")
1505 def prepare_request_data(self
, proto
):
1507 "myip" : self
.get_address(proto
),
1513 class DDNSProviderOpenDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
1514 handle
= "opendns.com"
1516 website
= "http://www.opendns.com"
1518 # Detailed information about the update request and possible
1519 # response codes can be obtained from here:
1520 # https://support.opendns.com/entries/23891440
1522 url
= "https://updates.opendns.com/nic/update"
1524 def prepare_request_data(self
, proto
):
1526 "hostname" : self
.hostname
,
1527 "myip" : self
.get_address(proto
),
1533 class DDNSProviderOVH(DDNSProtocolDynDNS2
, DDNSProvider
):
1536 website
= "http://www.ovh.com/"
1537 protocols
= ("ipv4",)
1539 # OVH only provides very limited information about how to
1540 # update a DynDNS host. They only provide the update url
1541 # on the their german subpage.
1543 # http://hilfe.ovh.de/DomainDynHost
1545 url
= "https://www.ovh.com/nic/update"
1547 def prepare_request_data(self
, proto
):
1548 data
= DDNSProtocolDynDNS2
.prepare_request_data(self
, proto
)
1550 "system" : "dyndns",
1556 class DDNSProviderRegfish(DDNSProvider
):
1557 handle
= "regfish.com"
1558 name
= "Regfish GmbH"
1559 website
= "http://www.regfish.com/"
1561 # A full documentation to the providers api can be found here
1562 # but is only available in german.
1563 # https://www.regfish.de/domains/dyndns/dokumentation
1565 url
= "https://dyndns.regfish.de/"
1566 can_remove_records
= False
1567 supports_token_auth
= True
1571 "fqdn" : self
.hostname
,
1574 # Check if we update an IPv6 address.
1575 address6
= self
.get_address("ipv6")
1577 data
["ipv6"] = address6
1579 # Check if we update an IPv4 address.
1580 address4
= self
.get_address("ipv4")
1582 data
["ipv4"] = address4
1584 # Raise an error if none address is given.
1585 if "ipv6" not in data
and "ipv4" not in data
:
1586 raise DDNSConfigurationError
1588 # Check if a token has been set.
1590 data
["token"] = self
.token
1592 # Raise an error if no token and no useranem and password
1594 elif not self
.username
and not self
.password
:
1595 raise DDNSConfigurationError(_("No Auth details specified"))
1597 # HTTP Basic Auth is only allowed if no token is used.
1599 # Send update to the server.
1600 response
= self
.send_request(self
.url
, data
=data
)
1602 # Send update to the server.
1603 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
, data
=data
)
1605 # Get the full response message.
1606 output
= response
.read().decode()
1608 # Handle success messages.
1609 if "100" in output
or "101" in output
:
1612 # Handle error codes.
1613 if "401" or "402" in output
:
1614 raise DDNSAuthenticationError
1615 elif "408" in output
:
1616 raise DDNSRequestError(_("Invalid IPv4 address has been sent"))
1617 elif "409" in output
:
1618 raise DDNSRequestError(_("Invalid IPv6 address has been sent"))
1619 elif "412" in output
:
1620 raise DDNSRequestError(_("No valid FQDN was given"))
1621 elif "414" in output
:
1622 raise DDNSInternalServerError
1624 # If we got here, some other update error happened.
1625 raise DDNSUpdateError
1628 class DDNSProviderSchokokeksDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
1629 handle
= "schokokeks.org"
1631 website
= "http://www.schokokeks.org/"
1632 protocols
= ("ipv4",)
1634 # Information about the format of the request is to be found
1635 # https://wiki.schokokeks.org/DynDNS
1636 url
= "https://dyndns.schokokeks.org/nic/update"
1639 class DDNSProviderSelfhost(DDNSProtocolDynDNS2
, DDNSProvider
):
1640 handle
= "selfhost.de"
1641 name
= "Selfhost.de"
1642 website
= "http://www.selfhost.de/"
1643 protocols
= ("ipv4",)
1645 url
= "https://carol.selfhost.de/nic/update"
1647 def prepare_request_data(self
, proto
):
1648 data
= DDNSProtocolDynDNS2
.prepare_request_data(self
, proto
)
1656 class DDNSProviderServercow(DDNSProvider
):
1657 handle
= "servercow.de"
1658 name
= "servercow.de"
1659 website
= "https://servercow.de/"
1660 protocols
= ("ipv4", "ipv6")
1662 url
= "https://www.servercow.de/dnsupdate/update.php"
1663 can_remove_records
= False
1664 supports_token_auth
= False
1666 def update_protocol(self
, proto
):
1668 "ipaddr" : self
.get_address(proto
),
1669 "hostname" : self
.hostname
,
1670 "username" : self
.username
,
1671 "pass" : self
.password
,
1674 # Send request to provider
1675 response
= self
.send_request(self
.url
, data
=data
)
1678 output
= response
.read().decode()
1680 # Server responds with OK if update was successful
1681 if output
.startswith("OK"):
1685 elif output
.startswith("FAILED - Authentication failed"):
1686 raise DDNSAuthenticationError
1688 # If we got here, some other update error happened
1689 raise DDNSUpdateError(output
)
1692 class DDNSProviderSPDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
1693 handle
= "spdns.org"
1695 website
= "https://www.spdyn.de/"
1697 # Detailed information about request and response codes are provided
1698 # by the vendor. They are using almost the same mechanism and status
1699 # codes as dyndns.org so we can inherit all those stuff.
1701 # http://wiki.securepoint.de/index.php/SPDNS_FAQ
1702 # http://wiki.securepoint.de/index.php/SPDNS_Update-Tokens
1704 url
= "https://update.spdyn.de/nic/update"
1706 supports_token_auth
= True
1710 return self
.get("username") or self
.hostname
1714 return self
.get("password") or self
.token
1717 class DDNSProviderStrato(DDNSProtocolDynDNS2
, DDNSProvider
):
1718 handle
= "strato.com"
1720 website
= "http:/www.strato.com/"
1721 protocols
= ("ipv4",)
1723 # Information about the request and response can be obtained here:
1724 # http://www.strato-faq.de/article/671/So-einfach-richten-Sie-DynDNS-f%C3%BCr-Ihre-Domains-ein.html
1726 url
= "https://dyndns.strato.com/nic/update"
1728 def prepare_request_data(self
, proto
):
1729 data
= DDNSProtocolDynDNS2
.prepare_request_data(self
, proto
)
1732 "backupmx" : "NOCHG"
1738 class DDNSProviderTwoDNS(DDNSProtocolDynDNS2
, DDNSProvider
):
1739 handle
= "twodns.de"
1741 website
= "http://www.twodns.de"
1742 protocols
= ("ipv4",)
1744 # Detailed information about the request can be found here
1745 # http://twodns.de/en/faqs
1746 # http://twodns.de/en/api
1748 url
= "https://update.twodns.de/update"
1750 def prepare_request_data(self
, proto
):
1751 assert proto
== "ipv4"
1754 "ip" : self
.get_address(proto
),
1755 "hostname" : self
.hostname
1761 class DDNSProviderUdmedia(DDNSProtocolDynDNS2
, DDNSProvider
):
1762 handle
= "udmedia.de"
1763 name
= "Udmedia GmbH"
1764 website
= "http://www.udmedia.de"
1765 protocols
= ("ipv4",)
1767 # Information about the request can be found here
1768 # http://www.udmedia.de/faq/content/47/288/de/wie-lege-ich-einen-dyndns_eintrag-an.html
1770 url
= "https://www.udmedia.de/nic/update"
1773 class DDNSProviderVariomedia(DDNSProtocolDynDNS2
, DDNSProvider
):
1774 handle
= "variomedia.de"
1776 website
= "http://www.variomedia.de/"
1777 protocols
= ("ipv6", "ipv4",)
1779 # Detailed information about the request can be found here
1780 # https://dyndns.variomedia.de/
1782 url
= "https://dyndns.variomedia.de/nic/update"
1784 def prepare_request_data(self
, proto
):
1786 "hostname" : self
.hostname
,
1787 "myip" : self
.get_address(proto
),
1793 class DDNSProviderXLhost(DDNSProtocolDynDNS2
, DDNSProvider
):
1794 handle
= "xlhost.de"
1796 website
= "http://xlhost.de/"
1797 protocols
= ("ipv4",)
1799 # Information about the format of the HTTP request is to be found
1800 # here: https://xlhost.de/faq/index_html?topicId=CQA2ELIPO4SQ
1802 url
= "https://nsupdate.xlhost.de/"
1805 class DDNSProviderZoneedit(DDNSProvider
):
1806 handle
= "zoneedit.com"
1808 website
= "http://www.zoneedit.com"
1809 protocols
= ("ipv4",)
1811 supports_token_auth
= False
1813 # Detailed information about the request and the response codes can be
1815 # http://www.zoneedit.com/doc/api/other.html
1816 # http://www.zoneedit.com/faq.html
1818 url
= "https://dynamic.zoneedit.com/auth/dynamic.html"
1820 def update_protocol(self
, proto
):
1822 "dnsto" : self
.get_address(proto
),
1823 "host" : self
.hostname
1826 # Send update to the server.
1827 response
= self
.send_request(self
.url
, username
=self
.username
, password
=self
.password
, data
=data
)
1829 # Get the full response message.
1830 output
= response
.read().decode()
1832 # Handle success messages.
1833 if output
.startswith("<SUCCESS"):
1836 # Handle error codes.
1837 if output
.startswith("invalid login"):
1838 raise DDNSAuthenticationError
1839 elif output
.startswith("<ERROR CODE=\"704\""):
1840 raise DDNSRequestError(_("No valid FQDN was given"))
1841 elif output
.startswith("<ERROR CODE=\"702\""):
1842 raise DDNSRequestError(_("Too frequent update requests have been sent"))
1844 # If we got here, some other update error happened.
1845 raise DDNSUpdateError
1848 class DDNSProviderDNSmadeEasy(DDNSProvider
):
1849 handle
= "dnsmadeeasy.com"
1850 name
= "DNSmadeEasy.com"
1851 website
= "http://www.dnsmadeeasy.com/"
1852 protocols
= ("ipv4",)
1854 # DNS Made Easy Nameserver Provider also offering Dynamic DNS
1855 # Documentation can be found here:
1856 # http://www.dnsmadeeasy.com/dynamic-dns/
1858 url
= "https://cp.dnsmadeeasy.com/servlet/updateip?"
1859 can_remove_records
= False
1860 supports_token_auth
= False
1862 def update_protocol(self
, proto
):
1864 "ip" : self
.get_address(proto
),
1865 "id" : self
.hostname
,
1866 "username" : self
.username
,
1867 "password" : self
.password
,
1870 # Send update to the server.
1871 response
= self
.send_request(self
.url
, data
=data
)
1873 # Get the full response message.
1874 output
= response
.read().decode()
1876 # Handle success messages.
1877 if output
.startswith("success") or output
.startswith("error-record-ip-same"):
1880 # Handle error codes.
1881 if output
.startswith("error-auth-suspend"):
1882 raise DDNSRequestError(_("Account has been suspended"))
1884 elif output
.startswith("error-auth-voided"):
1885 raise DDNSRequestError(_("Account has been revoked"))
1887 elif output
.startswith("error-record-invalid"):
1888 raise DDNSRequestError(_("Specified host does not exist"))
1890 elif output
.startswith("error-auth"):
1891 raise DDNSAuthenticationError
1893 # If we got here, some other update error happened.
1894 raise DDNSUpdateError(_("Server response: %s") % output
)
1897 class DDNSProviderZZZZ(DDNSProvider
):
1900 website
= "https://zzzz.io"
1901 protocols
= ("ipv6", "ipv4",)
1903 # Detailed information about the update request can be found here:
1904 # https://zzzz.io/faq/
1906 # Details about the possible response codes have been provided in the bugtracker:
1907 # https://bugzilla.ipfire.org/show_bug.cgi?id=10584#c2
1909 url
= "https://zzzz.io/api/v1/update"
1910 can_remove_records
= False
1911 supports_token_auth
= True
1913 def update_protocol(self
, proto
):
1915 "ip" : self
.get_address(proto
),
1916 "token" : self
.token
,
1920 data
["type"] = "aaaa"
1922 # zzzz uses the host from the full hostname as part
1923 # of the update url.
1924 host
, domain
= self
.hostname
.split(".", 1)
1926 # Add host value to the update url.
1927 url
= "%s/%s" % (self
.url
, host
)
1929 # Send update to the server.
1931 response
= self
.send_request(url
, data
=data
)
1933 # Handle error codes.
1934 except DDNSNotFound
:
1935 raise DDNSRequestError(_("Invalid hostname specified"))
1937 # Handle success messages.
1938 if response
.code
== 200:
1941 # If we got here, some other update error happened.
1942 raise DDNSUpdateError