# Connection to the core of the program.
self.core = core
+ # Address cache.
+ self.__addresses = {}
+
# Find out on which distribution we are running.
self.distro = self._get_distro_identifier()
logger.debug(_("Running on distribution: %s") % self.distro)
return resp
except urllib2.HTTPError, e:
+ # 400 - Bad request
+ if e.code == 400:
+ raise DDNSRequestError(e.reason)
+
+ # 401 - Authorization Required
+ # 403 - Forbidden
+ elif e.code in (401, 403):
+ raise DDNSAuthenticationError(e.reason)
+
+ # 500 - Internal Server Error
+ elif e.code == 500:
+ raise DDNSInternalServerError(e.reason)
+
# 503 - Service Unavailable
- if e.code == 503:
- raise DDNSServiceUnavailableError
+ elif e.code == 503:
+ raise DDNSServiceUnavailableError(e.reason)
# Raise all other unhandled exceptions.
raise
return authstring
def get_address(self, proto):
+ """
+ Returns the current IP address for
+ the given IP protocol.
+ """
+ try:
+ return self.__addresses[proto]
+
+ # IP is currently unknown and needs to be retrieved.
+ except KeyError:
+ self.__addresses[proto] = address = \
+ self._get_address(proto)
+
+ return address
+
+ def _get_address(self, proto):
assert proto in ("ipv6", "ipv4")
# IPFire 2 does not support IPv6.