server6

package
v0.0.0-...-4b5a011 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIPv6UDPConn

func NewIPv6UDPConn(iface string, addr *net.UDPAddr) (*net.UDPConn, error)

NewIPv6UDPConn returns a UDPv6-only connection bound to both the interface and port given based on a IPv6 DGRAM socket. As a bonus, you can actually listen on a multicast address instead of being punted to the wildcard

The interface must already be configured.

Types

type DebugLogger

type DebugLogger struct {
	// Printfer is used for actual output of the logger
	Printfer
}

DebugLogger is a wrapper for Printfer to implement interface Logger. DHCP messages are printed in the long format.

func (DebugLogger) PrintMessage

func (d DebugLogger) PrintMessage(prefix string, message *dhcpv6.Message)

PrintMessage prints a DHCP message in the long format via predefined Printfer

func (DebugLogger) Printf

func (d DebugLogger) Printf(format string, v ...interface{})

Printf prints a log message as-is via predefined Printfer

type EmptyLogger

type EmptyLogger struct{}

EmptyLogger prints nothing

func (EmptyLogger) PrintMessage

func (e EmptyLogger) PrintMessage(prefix string, message *dhcpv6.Message)

PrintMessage is just a dummy function that does nothing

func (EmptyLogger) Printf

func (e EmptyLogger) Printf(format string, v ...interface{})

Printf is just a dummy function that does nothing

type Handler

type Handler func(conn net.PacketConn, peer net.Addr, m dhcpv6.DHCPv6)

Handler is a type that defines the handler function to be called every time a valid DHCPv6 message is received

type Logger

type Logger interface {
	// PrintMessage print _all_ DHCP messages
	PrintMessage(prefix string, message *dhcpv6.Message)

	// Printf is use to print the rest debugging information
	Printf(format string, v ...interface{})
}

Logger is a handler which will be used to output logging messages

type Printfer

type Printfer interface {
	// Printf is the function for logging output. Arguments are handled in the manner of fmt.Printf.
	Printf(format string, v ...interface{})
}

Printfer is used for actual output of the logger. For example *log.Logger is a Printfer.

type Server

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

Server represents a DHCPv6 server object

func NewServer

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

NewServer initializes and returns a new Server object, listening on `addr`.

  • If `addr` is a multicast group, the group will be additionally joined
  • If `addr` is the wildcard address on the DHCPv6 server port (`[::]:547), the multicast groups All_DHCP_Relay_Agents_and_Servers(`[ff02::1:2]`) and All_DHCP_Servers(`[ff05::1:3]:547`) will be joined.
  • If `addr` is nil, IPv6 unspec on the DHCP server port is used and the above behaviour applies

If `WithConn` is used with a non-nil address, `addr` and `ifname` have no effect. In such case, joining the multicast group is the caller's responsibility.

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() error

Serve starts the DHCPv6 server. The listener will run in background, and can be interrupted with `Server.Close`.

type ServerOpt

type ServerOpt func(s *Server)

A ServerOpt configures a Server.

func WithConn

func WithConn(conn net.PacketConn) ServerOpt

WithConn configures a server with the given connection.

func WithDebugLogger

func WithDebugLogger() ServerOpt

WithDebugLogger logs multi-line full DHCPv6 messages when sent & received.

func WithLogger

func WithLogger(newLogger Logger) ServerOpt

WithLogger set the logger (see interface Logger).

func WithSummaryLogger

func WithSummaryLogger() ServerOpt

WithSummaryLogger logs one-line DHCPv6 message summaries when sent & received.

type ShortSummaryLogger

type ShortSummaryLogger struct {
	// Printfer is used for actual output of the logger
	Printfer
}

ShortSummaryLogger is a wrapper for Printfer to implement interface Logger. DHCP messages are printed in the short format.

func (ShortSummaryLogger) PrintMessage

func (s ShortSummaryLogger) PrintMessage(prefix string, message *dhcpv6.Message)

PrintMessage prints a DHCP message in the short format via predefined Printfer

func (ShortSummaryLogger) Printf

func (s ShortSummaryLogger) Printf(format string, v ...interface{})

Printf prints a log message as-is via predefined Printfer

Jump to

Keyboard shortcuts

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