dhcpserver

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Directives = []string{
	"log",
	"database",
	"interface",
	"gotify",
	"mqtt",
	"option",
	"servername",
	"next-server",
	"lease",
	"static",
	"range",
}

Directives that we register at caddy

View Source
var (
	// ErrNoResponse is returned by plugins if no response should be sent to the client
	// This may be used for DHCPRELEASE messages or by middleware handlers that filtered
	// the request. It's not an actual error
	ErrNoResponse = errors.New("no response should be sent")
)

Functions

func Ack

func Ack(msg *dhcpv4.DHCPv4) bool

Ack checks if msg is a DHCPACK

func Decline

func Decline(msg *dhcpv4.DHCPv4) bool

Decline checks if msg is a DHCPDECLINE

func Discover

func Discover(msg *dhcpv4.DHCPv4) bool

Discover checks if msg is a DHCPDISCOVER

func GetPeer

func GetPeer(ctx context.Context) net.Addr

GetPeer returns the peer address associated with ctx

func Inform

func Inform(msg *dhcpv4.DHCPv4) bool

Inform checks if msg is a DHCPINFORM

func Nak

func Nak(msg *dhcpv4.DHCPv4) bool

Nak checks if msg is a DHCPNAK

func Offer

func Offer(msg *dhcpv4.DHCPv4) bool

Offer checks if msg is a DHCPOFFER

func Release

func Release(msg *dhcpv4.DHCPv4) bool

Release checks if msg is DHCPRELEASE

func Request

func Request(msg *dhcpv4.DHCPv4) bool

Request checks if msg is a DHCPREQUEST

func WithPeer

func WithPeer(ctx context.Context, peer net.Addr) context.Context

WithPeer associates a peer addr with the ctx

Types

type Config

type Config struct {
	// IP is the IP address of the interface we are listening on. This is required
	// to select the right subnet configuration when listening and serving multiple
	// subnets
	IP net.IP

	// Network is the network of the subnet
	Network net.IPNet

	// Interface is the network interface where the subnet should be served. This
	// is required to select the right subnet configuration when listening and serving
	// multiple subnets
	Interface net.Interface

	// Database is the lease database that is queried for new leases and reservations
	Database lease.Database

	// Options holds a map of DHCP options that should be set
	Options map[dhcpv4.OptionCode]dhcpv4.OptionValue

	// LeaseTime is the default lease time to use for new IP address leases
	LeaseTime time.Duration
	// contains filtered or unexported fields
}

Config configures a DHCP server subnet

func GetConfig

func GetConfig(c *caddy.Controller) *Config

GetConfig gets the Config that corresponds to c if none exist nil is returned

func (*Config) AddPlugin

func (cfg *Config) AddPlugin(p plugin.Plugin)

AddPlugin adds a new plugin to the middleware chain

type PeerKey

type PeerKey struct{}

PeerKey is the key used to associate a net.Addr with a context.Context

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents an instance of a server which serves DHCP clients on a particular interface. Each Server may serve multiple IP subnets on the same interface picking the first defined one as the default. The other subnets may be either queried directly by requesting an IP address located there or by the use of DHCP relay agents

func NewServer

func NewServer(cfg *Config) (*Server, error)

NewServer returns a new DHCPv4 server that compiles all plugins in to it

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen does nothing as TCP is not supported. It implements the caddy.TCPServer interface

func (*Server) ListenPacket

func (s *Server) ListenPacket() (net.PacketConn, error)

ListenPacket starts listening for DHCP request messages via UDP/Raw sockets This implements the caddy.UDPServer interface

func (*Server) OnStartupComplete

func (s *Server) OnStartupComplete()

OnStartupComplete is called when all serves of the same instance have been started. It implements the caddy.AfterStarup interface

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve is a NO-OP as TCP is not supported by dhcpserver. It implements the caddy.TCPServer interface

func (*Server) ServePacket

func (s *Server) ServePacket(c net.PacketConn) error

ServePacket starts the server with an existing PacketConn. It blocks until the server stops. This implements the caddy.UDPServer interface

Jump to

Keyboard shortcuts

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