dhcp

package module
v0.0.0-...-dc2a5bb Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

README

[!IMPORTANT]
This repo is archived as the code has been moved into Smee.

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 lease pools as are normally found in DHCP servers.

Backends

  • 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.

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

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Handle(ctx context.Context, conn *ipv4.PacketConn, d data.Packet)
}

Handler is a type that defines the handler function to be called every time a valid DHCPv4 message is received type Handler func(ctx context.Context, conn net.PacketConn, d data.Packet).

type Server

type Server struct {
	Conn     net.PacketConn
	Handlers []Handler
	Logger   logr.Logger
}

Server represents a DHCPv4 server object.

func NewServer

func NewServer(ifname string, addr *net.UDPAddr, handler ...Handler) (*Server, error)

NewServer initializes and returns a new Server object.

func (*Server) Close

func (s *Server) Close() error

Close sends a termination request to the server, and closes the UDP listener.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve serves requests.

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