Documentation
¶
Overview ¶
Package dhcp reads and changes a unit's DHCP server: the address pools of each network and the static leases (address reservations).
Index ¶
- func AddPool(ctx context.Context, c *amplifi.Client, p Pool) error
- func AddStaticLease(ctx context.Context, c *amplifi.Client, l StaticLease) error
- func DeletePools(ctx context.Context, c *amplifi.Client, names ...string) error
- func DeleteStaticLeases(ctx context.Context, c *amplifi.Client, macs ...amplifi.MAC) error
- func UpdatePool(ctx context.Context, c *amplifi.Client, name string, u PoolUpdate) error
- func UpdateStaticLease(ctx context.Context, c *amplifi.Client, mac amplifi.MAC, u StaticLeaseUpdate) error
- type Pool
- type PoolUpdate
- type StaticLease
- type StaticLeaseUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPool ¶
AddPool adds pool p, named after its network interface such as "lan". Zero and empty fields are left to the router, except Ignore.
func AddStaticLease ¶
AddStaticLease reserves l.IP for l.MAC.
func DeletePools ¶
DeletePools deletes pools by name.
func DeleteStaticLeases ¶
DeleteStaticLeases removes the leases for the given MACs.
func UpdatePool ¶
UpdatePool changes the pool called name. It reads all pools, applies u to that one and writes them all back.
func UpdateStaticLease ¶
func UpdateStaticLease(ctx context.Context, c *amplifi.Client, mac amplifi.MAC, u StaticLeaseUpdate) error
UpdateStaticLease changes the lease for mac. It reads all leases, applies u to that one and writes them all back.
Types ¶
type Pool ¶
type Pool struct {
Name string `json:"name"`
Interface string `json:"interface"`
Ignore bool `json:"ignore"`
Offset int `json:"offset"`
Length int `json:"length"`
LeaseTime int `json:"lease_time"`
DHCP4Mode string `json:"dhcp4_mode,omitempty"`
DHCP6Mode string `json:"dhcp6_mode,omitempty"`
RAMode string `json:"ra_mode,omitempty"`
NDPMode string `json:"ndp_mode,omitempty"`
}
Pool is the DHCP server configuration of one network (GetDhcpPools). Addresses are handed out from Offset to Offset+Length-1 within the network's subnet. Modes are "disabled", "server", "relay" or "hybrid". LeaseTime is the router's raw value; its unit is unconfirmed, probably seconds.
type PoolUpdate ¶
type PoolUpdate struct {
Interface *string
Ignore *bool
Offset *int
Length *int
LeaseTime *int
DHCP4Mode *string
DHCP6Mode *string
RAMode *string
NDPMode *string
}
PoolUpdate lists the pool settings to change; nil fields are left as they are. Modes are as in Pool.
type StaticLease ¶
type StaticLease struct {
MAC amplifi.MAC `json:"mac"`
IP netip.Addr `json:"ip"`
Name string `json:"name"`
Description string `json:"description"`
}
StaticLease is a fixed address reservation (DhcpStaticLease).
func StaticLeases ¶
StaticLeases lists the static leases, sorted by name then MAC.