]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
unbound-dhcp-leases-bridge: Make Leases hashable and equal by IP address
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 May 2024 16:07:23 +0000 (17:07 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 May 2024 16:07:23 +0000 (17:07 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/unbound/unbound-dhcp-leases-bridge

index 604a172def2c4aca52391c155fb2cde8466643cc..c2270fbbd004cdafe3e2d98ebe22bcb2e197bab6 100644 (file)
@@ -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):