From: Michael Tremer Date: Fri, 10 May 2024 16:07:23 +0000 (+0100) Subject: unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address X-Git-Tag: v2.29-core188~10^2~86^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=edcea3e1c9c484097060831c99ac2445b457491c;p=ipfire-2.x.git unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address Signed-off-by: Michael Tremer --- diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge index 604a172def..c2270fbbd0 100644 --- a/config/unbound/unbound-dhcp-leases-bridge +++ b/config/unbound/unbound-dhcp-leases-bridge @@ -488,20 +488,25 @@ class Lease(object): self._properties = properties def __repr__(self): - return "<%s %s for %s (%s)>" % (self.__class__.__name__, - self.ipaddr, self.hwaddr, self.hostname) + return "<%s for %s (%s)>" % (self.__class__.__name__, self.ipaddr, self.hostname) def __eq__(self, other): - return self.ipaddr == other.ipaddr and self.hwaddr == other.hwaddr + if isinstance(other, self.__class__): + return self.ipaddr == other.ipaddr + + return NotImplemented def __gt__(self, other): - if not self.ipaddr == other.ipaddr: - return + if isinstance(other, self.__class__): + if not self.ipaddr == other.ipaddr: + return NotImplemented - if not self.hwaddr == other.hwaddr: - return + return self.time_starts > other.time_starts + + return NotImplemented - return self.time_starts > other.time_starts + def __hash__(self): + return hash(self.ipaddr) @property def binding_state(self):