From d20ef9d703dd4f4c16d8ce68f6b093d21d1a04ca Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 14 Sep 2016 16:35:41 +0100 Subject: [PATCH] unbound+DHCP: Make sure to only remove old leases and not static hosts Signed-off-by: Michael Tremer --- config/unbound/unbound-dhcp-leases-bridge | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge index f192179ad5..0ef14e1c3e 100644 --- a/config/unbound/unbound-dhcp-leases-bridge +++ b/config/unbound/unbound-dhcp-leases-bridge @@ -338,15 +338,19 @@ class UnboundConfigWriter(object): return ret def update_dhcp_leases(self, leases): - # Strip all non-active or expired leases - leases = [l for l in leases if l.active and not l.expired] + # Cache all expired or inactive leases + expired_leases = [l for l in leases if l.expired or not l.active] - # Find any leases that have expired or do not exist any more + # Find any leases that have expired or do not exist any more + # but are still in the unbound local data removed_leases = [] for fqdn, address in self.existing_leases.items(): - if not fqdn in (l.fqdn for l in leases): + if fqdn in (l.fqdn for l in expired_leases): removed_leases += [fqdn, address] + # Strip all non-active or expired leases + leases = [l for l in leases if l.active and not l.expired] + # Find any leases that have been added new_leases = [l for l in leases if l.fqdn not in self.existing_leases] -- 2.39.5