dhcp4d

package
v0.0.0-...-07f1eb8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dhcp4d implements a DHCPv4 server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	LeasePeriod time.Duration

	// Leases is called whenever a new lease is handed out
	Leases func([]*Lease, *Lease)
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(dir string, iface *net.Interface, ifaceName string, conn net.PacketConn) (*Handler, error)

func (*Handler) ServeDHCP

func (h *Handler) ServeDHCP(p dhcp4.Packet, msgType dhcp4.MessageType, options dhcp4.Options) dhcp4.Packet

ServeDHCP is always called from the same goroutine, so no locking is required.

func (*Handler) SetHostname

func (h *Handler) SetHostname(hwaddr, hostname string) error

func (*Handler) SetLeases

func (h *Handler) SetLeases(leases []*Lease)

SetLeases overwrites the leases database with the specified leases, typically loaded from persistent storage. There is no locking, so SetLeases must be called before Serve.

type Lease

type Lease struct {
	Num              int       `json:"num"` // relative to Handler.start
	Addr             net.IP    `json:"addr"`
	HardwareAddr     string    `json:"hardware_addr"`
	Hostname         string    `json:"hostname"`
	HostnameOverride string    `json:"hostname_override"`
	Expiry           time.Time `json:"expiry"`
	LastACK          time.Time `json:"last_ack"`
}

func (*Lease) Active

func (l *Lease) Active(at time.Time) bool

func (*Lease) Expired

func (l *Lease) Expired(at time.Time) bool

Jump to

Keyboard shortcuts

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