* commit 'ef789acee4ef990d9f93fa7f718f819b5bdea03d': * control: DHCP: don't return expired leases
This commit is contained in:
commit
8defb3b39e
|
@ -517,10 +517,17 @@ func (s *Server) handleDecline(p dhcp4.Packet, options dhcp4.Options) dhcp4.Pack
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leases returns the list of current DHCP leases (thread-safe)
|
// Leases returns the list of current DHCP leases (thread-safe)
|
||||||
func (s *Server) Leases() []*Lease {
|
func (s *Server) Leases() []Lease {
|
||||||
|
var result []Lease
|
||||||
|
now := time.Now().Unix()
|
||||||
s.RLock()
|
s.RLock()
|
||||||
result := s.leases
|
for _, lease := range s.leases {
|
||||||
|
if lease.Expiry.Unix() > now {
|
||||||
|
result = append(result, *lease)
|
||||||
|
}
|
||||||
|
}
|
||||||
s.RUnlock()
|
s.RUnlock()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue