Skip to content

Commit

Permalink
dhcpsvc: imp code, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Sep 27, 2023
1 parent 91a0e45 commit 03b5454
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 0 additions & 2 deletions internal/dhcpd/iprange.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ type ipPredicate func(ip net.IP) (ok bool)

// find finds the first IP address in r for which p returns true. ip is in the
// 16-byte form.
//
// TODO(e.burkov): Use.
func (r *ipRange) find(p ipPredicate) (ip net.IP) {
if r == nil {
return nil
Expand Down
10 changes: 5 additions & 5 deletions internal/dhcpsvc/dhcpsvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ type Interface interface {
// invalid or already exists.
AddLease(l *Lease) (err error)

// EditLease changes an existing DHCP lease. It returns an error if there
// is no lease equal to old or if new is invalid or already exists.
EditLease(old, new *Lease) (err error)
// UpdateStaticLease changes an existing DHCP lease. It returns an error if
// there is no lease equal to old or if new is invalid or already exists.
UpdateStaticLease(old, new *Lease) (err error)

// RemoveLease removes an existing DHCP lease. It returns an error if there
// is no lease equal to l.
Expand Down Expand Up @@ -111,8 +111,8 @@ func (Empty) Leases() (leases []*Lease) { return nil }
// AddLease implements the [Interface] interface for Empty.
func (Empty) AddLease(_ *Lease) (err error) { return nil }

// EditLease implements the [Interface] interface for Empty.
func (Empty) EditLease(_, _ *Lease) (err error) { return nil }
// UpdateStaticLease implements the [Interface] interface for Empty.
func (Empty) UpdateStaticLease(_, _ *Lease) (err error) { return nil }

// RemoveLease implements the [Interface] interface for Empty.
func (Empty) RemoveLease(_ *Lease) (err error) { return nil }
Expand Down
6 changes: 4 additions & 2 deletions internal/dhcpsvc/iprange.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/AdguardTeam/golibs/errors"
)

// ipRange is an inclusive range of IP addresses. A nil range is a range that
// doesn't contain any IP addresses.
// ipRange is an inclusive range of IP addresses. A zero range doesn't contain
// any IP addresses.
//
// It is safe for concurrent use.
type ipRange struct {
Expand Down Expand Up @@ -65,6 +65,8 @@ type ipPredicate func(ip netip.Addr) (ok bool)

// find finds the first IP address in r for which p returns true. It returns an
// empty [netip.Addr] if there are no addresses that satisfy p.
//
// TODO(e.burkov): Use.
func (r ipRange) find(p ipPredicate) (ip netip.Addr) {
for ip = r.start; !r.end.Less(ip); ip = ip.Next() {
if p(ip) {
Expand Down
4 changes: 3 additions & 1 deletion internal/dhcpsvc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ type DHCPServer struct {

// New creates a new DHCP server with the given configuration. It returns an
// error if the given configuration can't be used.
//
// TODO(e.burkov): Use.
func New(conf *Config) (srv *DHCPServer, err error) {
if !conf.Enabled {
// TODO(e.burkov): !! return Empty?
// TODO(e.burkov): Perhaps return [Empty]?
return nil, nil
}

Expand Down

0 comments on commit 03b5454

Please sign in to comment.