###############################################################################
# #
# ddns - A dynamic DNS client for IPFire #
-# Copyright (C) 2014 IPFire development team #
+# Copyright (C) 2014-2017 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 #
def log_failure(self, hostname, exception):
if exception:
message = "%s: %s" % (exception.__class__.__name__, exception.reason)
+ error_type = exception.genre
else:
message = None
+ error_type = "failure"
logger.debug("Logging failed update for %s: %s" % (hostname, message or ""))
- return self.add_update(hostname, "failure", message=message)
+ return self.add_update(hostname, error_type, message=message)
def last_update(self, hostname, status=None):
"""
# is tried after the last one has failed.
holdoff_failure_days = 0.5
+ # holdoff time for rate-limited updates - Number of minutes no update
+ # is tried after the last one has been sent.
+ holdoff_rate-limited_minutes = 30
+
# True if the provider is able to remove records, too.
# Required to remove AAAA records if IPv6 is absent again.
can_remove_records = True
@property
def has_failure(self):
"""
- Returns True when the last update has failed and no retry
- should be performed, yet.
+ Returns True when the last update has not failed or rate-limited and
+ no retry should be performed, yet.
"""
last_status = self.db.last_update_status(self.hostname)
- # Return False if the last update has not failed.
- if not last_status == "failure":
+ # Return False if the last update has failed or has been rate-limited.
+ if not (last_status == "failure" or last_status == "rate-limited"):
return False
# If there is no holdoff time, we won't update ever again.
# Determine when the holdoff time ends
last_update = self.db.last_update(self.hostname, status=last_status)
- holdoff_end = last_update + datetime.timedelta(days=self.holdoff_failure_days)
+
+ # Calculate holdoff end, based on the last status (failure or rate-limited)
+ if last_status == "failure"
+ holdoff_end = last_update + datetime.timedelta(days=self.holdoff_failure_days)
+ else:
+ holdoff_end = last_update + datetime.timedelta(minutes=self.holdoff_rate-limited_minutes)
now = datetime.datetime.utcnow()
if now < holdoff_end: