Reviewed-by: Bernhard Bitsch bbitsch@ipfire.org
Am 21.10.2024 um 18:38 schrieb Michael Tremer:
When we import all static leases, their remark will be used as hostname (because WTF?) and might be overwritten if the device is not sending any or even the same hostname.
This patch avoids that static leases will be modified.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
config/unbound/unbound-dhcp-leases-bridge | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/config/unbound/unbound-dhcp-leases-bridge b/config/unbound/unbound-dhcp-leases-bridge index 2cbdaa004..66ea28054 100644 --- a/config/unbound/unbound-dhcp-leases-bridge +++ b/config/unbound/unbound-dhcp-leases-bridge @@ -216,6 +216,11 @@ class UnboundDHCPLeasesBridge(object): # Find the old lease old_lease = self._find_lease(address)
# Don't update fixed leases as they might clear the hostname
if old_lease and old_lease.fixed:
log.debug("Won't update fixed lease %s" % old_lease)
return
# Create a new lease lease = Lease(address, { "client-hostname" : name,
@@ -581,19 +586,20 @@ class FixLeases(object): "client-hostname" : hostname, "starts" : now.strftime("%w %Y/%m/%d %H:%M:%S"), "ends" : "never",
})
}, fixed=True) leases.append(l)
return leases
class Lease(object):
- def __init__(self, ipaddr, properties):
def __init__(self, ipaddr, properties, fixed=False): if not isinstance(ipaddr, ipaddress.IPv4Address): ipaddr = ipaddress.IPv4Address(ipaddr)
self.ipaddr = ipaddr self._properties = properties
self.fixed = fixed
def __repr__(self): return "<%s for %s (%s)>" % (self.__class__.__name__, self.ipaddr, self.hostname)