daemon: fixed issue in dhcp server subnet line using wrong address

This commit is contained in:
Blake Harnden 2021-04-23 14:00:05 -07:00
parent dcf402ae04
commit 4830538053
2 changed files with 12 additions and 16 deletions

View file

@ -155,7 +155,7 @@ class DhcpService(ConfigService):
index = (ip4.size - 2) / 2
rangelow = ip4[index]
rangehigh = ip4[-2]
subnets.append((ip4.ip, ip4.netmask, rangelow, rangehigh, str(ip4.ip)))
subnets.append((ip4.cidr.ip, ip4.netmask, rangelow, rangehigh, ip4.ip))
return dict(subnets=subnets)

View file

@ -248,15 +248,11 @@ ddns-update-style none;
"""
if ip.size == 1:
return ""
address = str(ip.ip)
if netaddr.valid_ipv6(address):
return ""
else:
# divide the address space in half
index = (ip.size - 2) / 2
rangelow = ip[index]
rangehigh = ip[-2]
return """
# divide the address space in half
index = (ip.size - 2) / 2
rangelow = ip[index]
rangehigh = ip[-2]
return """
subnet %s netmask %s {
pool {
range %s %s;
@ -265,12 +261,12 @@ subnet %s netmask %s {
}
}
""" % (
ip.ip,
ip.netmask,
rangelow,
rangehigh,
address,
)
ip.cidr.ip,
ip.netmask,
rangelow,
rangehigh,
ip.ip,
)
class DhcpClientService(UtilService):