mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-21 20:45:33 +03:00
42c7cd6f8e
Updates #4923. Squashed commit of the following: commit0e40b41aa1
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Jul 10 15:28:16 2024 +0300 dhcpsvc: imp code, docs commit5463fdde47
Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Jul 9 20:31:20 2024 +0300 dhcpsvc: imp ifaces
46 lines
832 B
Go
46 lines
832 B
Go
package dhcpsvc
|
|
|
|
import (
|
|
"net"
|
|
"net/netip"
|
|
"slices"
|
|
"time"
|
|
)
|
|
|
|
// Lease is a DHCP lease.
|
|
//
|
|
// TODO(e.burkov): Consider moving it to [agh], since it also may be needed in
|
|
// [websvc].
|
|
//
|
|
// TODO(e.burkov): Add validation method.
|
|
type Lease struct {
|
|
// IP is the IP address leased to the client.
|
|
IP netip.Addr
|
|
|
|
// Expiry is the expiration time of the lease.
|
|
Expiry time.Time
|
|
|
|
// Hostname of the client.
|
|
Hostname string
|
|
|
|
// HWAddr is the physical hardware address (MAC address).
|
|
HWAddr net.HardwareAddr
|
|
|
|
// IsStatic defines if the lease is static.
|
|
IsStatic bool
|
|
}
|
|
|
|
// Clone returns a deep copy of l.
|
|
func (l *Lease) Clone() (clone *Lease) {
|
|
if l == nil {
|
|
return nil
|
|
}
|
|
|
|
return &Lease{
|
|
Expiry: l.Expiry,
|
|
Hostname: l.Hostname,
|
|
HWAddr: slices.Clone(l.HWAddr),
|
|
IP: l.IP,
|
|
IsStatic: l.IsStatic,
|
|
}
|
|
}
|