dhcp4d: allow handing out static leases outside of the pool
This commit is contained in:
parent
fd975db6a5
commit
b2db10d68b
@ -187,7 +187,7 @@ func (h *Handler) canLease(reqIP net.IP, hwaddr string) int {
|
||||
}
|
||||
|
||||
leaseNum := dhcp4.IPRange(h.start, reqIP) - 1
|
||||
if leaseNum < 0 || leaseNum >= h.leaseRange {
|
||||
if leaseNum < 0 {
|
||||
return -1
|
||||
}
|
||||
|
||||
@ -195,6 +195,10 @@ func (h *Handler) canLease(reqIP net.IP, hwaddr string) int {
|
||||
defer h.leasesMu.Unlock()
|
||||
l, ok := h.leasesIP[leaseNum]
|
||||
if !ok {
|
||||
if leaseNum >= h.leaseRange {
|
||||
return -1
|
||||
}
|
||||
|
||||
return leaseNum // lease available
|
||||
}
|
||||
|
||||
@ -202,6 +206,10 @@ func (h *Handler) canLease(reqIP net.IP, hwaddr string) int {
|
||||
return leaseNum // lease already owned by requestor
|
||||
}
|
||||
|
||||
if leaseNum >= h.leaseRange {
|
||||
return -1
|
||||
}
|
||||
|
||||
if l.Expired(h.timeNow()) {
|
||||
return leaseNum // lease expired
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user