dhcp

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPool

func AddPool(ctx context.Context, c *amplifi.Client, p Pool) error

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

func AddStaticLease(ctx context.Context, c *amplifi.Client, l StaticLease) error

AddStaticLease reserves l.IP for l.MAC.

func DeletePools

func DeletePools(ctx context.Context, c *amplifi.Client, names ...string) error

DeletePools deletes pools by name.

func DeleteStaticLeases

func DeleteStaticLeases(ctx context.Context, c *amplifi.Client, macs ...amplifi.MAC) error

DeleteStaticLeases removes the leases for the given MACs.

func UpdatePool

func UpdatePool(ctx context.Context, c *amplifi.Client, name string, u PoolUpdate) error

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.

func Pools

func Pools(ctx context.Context, c *amplifi.Client) ([]Pool, error)

Pools lists the DHCP pools, sorted by name.

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

func StaticLeases(ctx context.Context, c *amplifi.Client) ([]StaticLease, error)

StaticLeases lists the static leases, sorted by name then MAC.

type StaticLeaseUpdate

type StaticLeaseUpdate struct {
	IP          *netip.Addr
	Name        *string
	Description *string
}

StaticLeaseUpdate lists the lease fields to change; nil fields are left as they are.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL