dhcp

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

Test and Build codecov Go Report Card Go Reference

dhcp

DHCP library and CLI server with multiple backends. All IP addresses are served as DHCP reservations. There are no leases.

Backends

  • Tink gRPC server
    • This backend is the main use case. It pulls hardware data from the Tink gRPC API for use in serving DHCP clients.
  • Tink Kubernetes CRDs
    • This backend is also the main use case. It pulls hardware data from Kubernetes CRDs for use in serving DHCP clients.
  • File based
    • This backend is for mainly for testing and development. It reads a file for hardware data to use in serving DHCP clients. See example.yaml for the data model.
  • Cacher server
    • This backend is mainly for backward compatibility in Boots. It pulls hardware data from the Cacher API for use in serving DHCP clients. It is planned for deprecation in Boots.

Definitions

DHCP Reservation: A fixed IP address that is reserved for a specific client.

DHCP Lease: An IP address, that can potentially change, that is assigned to a client by the DHCP server. The IP is typically pulled from a pool or subnet of available IP addresses.

Documentation

Overview

Package dhcp providers UDP listening and serving functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoConn = &noConnError{}

ErrNoConn is an error im still not sure i want to use.

Functions

func Serve

func Serve(ctx context.Context, c net.PacketConn, h ...Handler) error

Serve will listen for DHCP messages on the given net.PacketConn and call the handler for each.

Types

type Handler

type Handler interface {
	// Handle is used for how to respond to DHCP messages.
	Handle(net.PacketConn, net.Addr, *dhcpv4.DHCPv4)
}

Handler is the interface is responsible for responding to DHCP messages.

type Listener

type Listener struct {
	Addr netip.AddrPort
	// contains filtered or unexported fields
}

Listener is a DHCPv4 server.

func (*Listener) Handler

func (l *Listener) Handler(conn net.PacketConn, peer net.Addr, pkt *dhcpv4.DHCPv4)

Handler is the main handler passed to the server4 function. Internally it allows for multiple handlers to be defined. Each handler in l.handlers then executed for every received packet.

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe(ctx context.Context, h ...Handler) error

ListenAndServe will listen for DHCP messages and call the given handler for each.

func (*Listener) Serve

func (l *Listener) Serve(ctx context.Context, c net.PacketConn) error

Serve will listen for DHCP messages on the given net.PacketConn and call the handler in *Listener for each. If no handler is specified, a Noop handler will be used.

func (*Listener) Shutdown

func (l *Listener) Shutdown() error

Shutdown closes the listener.

Directories

Path Synopsis
backend
file
Package file watches a file for changes and updates the in memory DHCP data.
Package file watches a file for changes and updates the in memory DHCP data.
kube
Package kube is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.
Package kube is a backend implementation that uses the Tinkerbell CRDs to get DHCP data.
noop
Package noop is a backend handler that does nothing.
Package noop is a backend handler that does nothing.
Package data is an interface between DHCP backend implementations and the DHCP server.
Package data is an interface between DHCP backend implementations and the DHCP server.
example
fileBackend
package main is an example of how to use the dhcp package with the file backend.
package main is an example of how to use the dhcp package with the file backend.
kubeBackend
package main is an example of how to use the dhcp package with the kube backend.
package main is an example of how to use the dhcp package with the kube backend.
Package handler holds the interface that backends implement, handlers take in, and the top level dhcp package passes to handlers.
Package handler holds the interface that backends implement, handlers take in, and the top level dhcp package passes to handlers.
noop
Package noop is a handler that does nothing.
Package noop is a handler that does nothing.
reservation
Package reservation is the handler for responding to DHCPv4 messages with only host reservations.
Package reservation is the handler for responding to DHCPv4 messages with only host reservations.
Package otel handles translating DHCP headers and options to otel key/value attributes.
Package otel handles translating DHCP headers and options to otel key/value attributes.

Jump to

Keyboard shortcuts

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