Skip to content

Commit

Permalink
dhcpd: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneOne1 committed Feb 18, 2021
1 parent 3744338 commit 5262c0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ and this project adheres to

### Fixed

- DHCP lease's `expired` field time format ([#2692]).
- Wrong parsing of DHCP options of the `ip` type ([#2688]).

[#2688]: https://github.com/AdguardTeam/AdGuardHome/issues/2688
[#2692]: https://github.com/AdguardTeam/AdGuardHome/issues/2692



Expand Down
21 changes: 14 additions & 7 deletions internal/dhcpd/dhcpd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import (

const (
defaultDiscoverTime = time.Second * 3
// TODO(e.burkov): Get rid of this useless stuff.
// leaseExpireStatic is used to define the Expiry field for static
// leases.
//
// TODO(e.burkov): Remove it when static leases determining mechanism
// will be improved.
leaseExpireStatic = 1
)

Expand All @@ -40,6 +44,11 @@ type Lease struct {
func (l *Lease) MarshalJSON() ([]byte, error) {
var expiryStr string
if expiry := l.Expiry; expiry.Unix() != leaseExpireStatic {
// The front-end is waiting for RFC 3999 format of the time
// value. It also shouldn't got an Expiry field for static
// leases.
//
// See https://github.com/AdguardTeam/AdGuardHome/issues/2692.
expiryStr = expiry.Format(time.RFC3339)
}

Expand Down Expand Up @@ -256,12 +265,10 @@ const (
LeasesAll = LeasesDynamic | LeasesStatic
)

// Leases returns the list of current DHCP leases (thread-safe)
func (s *Server) Leases(flags int) []Lease {
result := s.srv4.GetLeases(flags)
v6leases := s.srv6.GetLeases(flags)

return append(result, v6leases...)
// Leases returns the list of active IPv4 and IPv6 DHCP leases. It's safe for
// concurrent use.
func (s *Server) Leases(flags int) (leases []Lease) {
return append(s.srv4.GetLeases(flags), s.srv6.GetLeases(flags)...)
}

// FindMACbyIP - find a MAC address by IP address in the currently active DHCP leases
Expand Down

0 comments on commit 5262c0b

Please sign in to comment.