Pull request: dhcpd: imp static lease validation

Closes #2838.
Updates #2834.

Squashed commit of the following:

commit 608dce28cf6bcbaf5a7f0bf499889ec25777e121
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 18 16:49:20 2021 +0300

    dhcpd: fix windows; imp code

commit 5e56eebf6ab85ca5fd0a0278c312674d921a3077
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Mar 17 18:47:54 2021 +0300

    dhcpd: imp static lease validation
This commit is contained in:
Ainar Garipov
2021-03-18 17:07:13 +03:00
parent ffa0afae27
commit eb9526cc92
15 changed files with 392 additions and 121 deletions

View File

@@ -11,8 +11,6 @@ type DHCPServer interface {
ResetLeases(leases []*Lease)
// GetLeases - get leases
GetLeases(flags int) []Lease
// GetLeasesRef - get reference to leases array
GetLeasesRef() []*Lease
// AddStaticLease - add a static lease
AddStaticLease(lease Lease) error
// RemoveStaticLease - remove a static lease
@@ -29,6 +27,8 @@ type DHCPServer interface {
Start() error
// Stop - stop server
Stop()
getLeasesRef() []*Lease
}
// V4ServerConf - server configuration
@@ -68,7 +68,12 @@ type V4ServerConf struct {
subnetMask net.IPMask // value for Option SubnetMask
options []dhcpOption
// Server calls this function when leases data changes
// notify is a way to signal to other components that leases have
// change. notify must be called outside of locked sections, since the
// clients might want to get the new data.
//
// TODO(a.garipov): This is utter madness and must be refactored. It
// just begs for deadlock bugs and other nastiness.
notify func(uint32)
}