smee

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 30 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DHCPModeProxy       DHCPMode = "proxy"
	DHCPModeReservation DHCPMode = "reservation"
	DHCPModeAutoProxy   DHCPMode = "auto-proxy"

	// Defaults consumers can use.
	DefaultTFFTPPort       = 69
	DefaultTFFTPBlockSize  = 512
	DefaultTFFTPSinglePort = true
	DefaultTFFTPTimeout    = 10 * time.Second
	DefaultDHCPPort        = 67
	DefaultSyslogPort      = 514
	DefaultTinkServerPort  = 42113

	IPXEBinaryURI = "/ipxe/binary/"
	IPXEScriptURI = "/ipxe/script/"
	ISOURI        = "/iso/"
)

Variables

This section is empty.

Functions

func MetricsRegistry added in v0.23.0

func MetricsRegistry() *prometheus.Registry

MetricsRegistry returns the Prometheus registry that contains all Smee metrics. It can be used to serve Smee metrics on a dedicated endpoint (e.g. /smee/metrics).

Types

type BackendReader

type BackendReader interface {
	FilterHardware(ctx context.Context, opts data.HardwareFilter) (*tinkerbell.Hardware, error)
}

BackendReader is the interface for getting data from a backend.

type Config

type Config struct {
	// Backend is the backend to use for getting data.
	Backend BackendReader
	// DHCP is the configuration for the DHCP service.
	DHCP DHCP
	// IPXE is the configuration for the iPXE service.
	IPXE IPXE
	// ISO is the configuration for the ISO service.
	ISO ISO
	// OTEL is the configuration for OpenTelemetry.
	OTEL OTEL
	// Syslog is the configuration for the syslog service.
	Syslog Syslog
	// TFTP is the configuration for the TFTP service.
	TFTP TFTP
	// TinkServer is the configuration for the Tinkerbell server.
	TinkServer TinkServer
	// TLS is the configuration for TLS.
	TLS TLS
}

Config is the configuration for the Smee service.

func NewConfig

func NewConfig(c Config, publicIP netip.Addr) *Config

NewConfig is a constructor for the Config struct. It will set default values for the Config struct. Boolean fields are not set-able via c. To set boolean, modify the returned Config struct.

func (*Config) BinaryHandler added in v0.23.0

func (c *Config) BinaryHandler(log logr.Logger) http.Handler

BinaryHandler returns an http.Handler that serves iPXE binaries. Returns nil if the iPXE HTTP binary server is disabled.

func (*Config) ISOHandler added in v0.23.0

func (c *Config) ISOHandler(log logr.Logger) (http.Handler, error)

ISOHandler returns an http.Handler that serves patched ISO images. Returns nil, nil if the ISO server is disabled.

func (*Config) InitMetrics added in v0.23.0

func (c *Config) InitMetrics()

InitMetrics initializes only Smee's Prometheus metrics (DHCP counters, discover/job histograms, etc.) without initializing OpenTelemetry. Use this when OTel has already been initialized at a higher level (e.g. by the consolidated tinkerbell binary) to avoid overwriting the global tracer provider.

func (*Config) ScriptHandler added in v0.23.0

func (c *Config) ScriptHandler(log logr.Logger) http.Handler

ScriptHandler returns an http.Handler that serves iPXE scripts. Returns nil if the iPXE HTTP script server is disabled.

func (*Config) Start

func (c *Config) Start(ctx context.Context, log logr.Logger) error

Start will run Smee non-HTTP services (DHCP, TFTP, syslog). HTTP serving is handled externally by the HTTP server.

func (*Config) Transformer

func (c *Config) Transformer(typ reflect.Type) func(dst, src reflect.Value) error

Transformer for merging the netip.IPPort and logr.Logger structs.

type DHCP

type DHCP struct {
	// Enabled configures whether the DHCP server is enabled.
	Enabled bool
	// EnableNetbootOptions configures whether sending netboot options is enabled.
	EnableNetbootOptions bool
	// Mode determines the behavior of the DHCP server.
	// See the DHCPMode type for valid values.
	Mode DHCPMode
	// BindAddr is the local address to which to bind the DHCP server and listen for DHCP packets.
	BindAddr netip.Addr
	BindPort uint16
	// BindInterface is the local interface to which to bind the DHCP server and listen for DHCP packets.
	BindInterface string
	// IPForPacket is the IP address to use in the DHCP packet for DHCP option 54.
	IPForPacket netip.Addr
	// SyslogIP is the IP address to use in the DHCP packet for DHCP option 7.
	SyslogIP netip.Addr
	// TFTPIP is the IP address to use in the DHCP packet for DHCP option 66.
	TFTPIP netip.Addr
	// TFTPPort is the port to use in the DHCP packet for DHCP option 66.
	TFTPPort uint16
	// IPXEHTTPBinaryURL is the URL to the iPXE binary server serving via HTTP.
	IPXEHTTPBinaryURL *url.URL
	// IPXEHTTPScript is the URL to the iPXE script to use.
	IPXEHTTPScript IPXEHTTPScript
}

type DHCPMode

type DHCPMode string

func (*DHCPMode) Set

func (d *DHCPMode) Set(s string) error

func (DHCPMode) String

func (d DHCPMode) String() string

func (*DHCPMode) Type

func (d *DHCPMode) Type() string

type IPXE

type IPXE struct {
	EmbeddedScriptPatch string
	HTTPBinaryServer    IPXEHTTPBinaryServer
	HTTPScriptServer    IPXEHTTPScriptServer

	// IPXEBinary are the options to use when serving iPXE binaries via TFTP or HTTP.
	IPXEBinary IPXEHTTPBinary
}

type IPXEHTTPBinary added in v0.20.0

type IPXEHTTPBinary struct {
	// InjectMacAddrFormat is the format to use when injecting the mac address into the iPXE binary URL.
	// Valid values are "colon", "dot", "dash", "no-delimiter", and "empty".
	// For example, colon: http://1.2.3.4/ipxe/ipxe.efi -> http://1.2.3.4/ipxe/40:15:ff:89:cc:0e/ipxe.efi
	InjectMacAddrFormat constant.MACFormat
	// IPXEArchMapping will override the default architecture to binary mapping.
	IPXEArchMapping map[iana.Arch]constant.IPXEBinary
}

type IPXEHTTPBinaryServer

type IPXEHTTPBinaryServer struct {
	Enabled bool
}

type IPXEHTTPScript

type IPXEHTTPScript struct {
	URL *url.URL
	// InjectMacAddress will prepend the hardware mac address to the ipxe script URL file name.
	// For example: http://1.2.3.4/my/loc/auto.ipxe -> http://1.2.3.4/my/loc/40:15:ff:89:cc:0e/auto.ipxe
	// Setting this to false is useful when you are not using the auto.ipxe script in Smee.
	InjectMacAddress bool
}

type IPXEHTTPScriptServer

type IPXEHTTPScriptServer struct {
	Enabled         bool
	Retries         int
	RetryDelay      int
	OSIEURL         *url.URL
	TrustedProxies  []string
	ExtraKernelArgs []string
	KernelName      string
	InitrdName      string
}

type ISO

type ISO struct {
	Enabled           bool
	UpstreamURL       *url.URL
	PatchMagicString  string
	StaticIPAMEnabled bool
}

type OTEL

type OTEL struct {
	Endpoint         string
	InsecureEndpoint bool
}

type Syslog

type Syslog struct {
	// BindAddr is the local address to which to bind the syslog server.
	BindAddr netip.Addr
	// BindPort is the local port to which to bind the syslog server.
	BindPort uint16
	// Enabled is a flag to enable or disable the syslog server.
	Enabled bool
}

type TFTP

type TFTP struct {
	// BindAddr is the local address to which to bind the TFTP server.
	BindAddr netip.Addr
	// BindPort is the local port to which to bind the TFTP server.
	BindPort uint16
	// BlockSize is the block size to use when serving TFTP requests.
	BlockSize int
	// SinglePort configures whether to use single-port TFTP mode.
	SinglePort bool
	// Timeout is the timeout for each serving each TFTP request.
	Timeout time.Duration
	// Enabled is a flag to enable or disable the TFTP server.
	Enabled bool
}

type TLS added in v0.22.0

type TLS struct {
	Certs []tls.Certificate
}

type TinkServer

type TinkServer struct {
	UseTLS      bool
	InsecureTLS bool
	AddrPort    string
}

Directories

Path Synopsis
internal
dhcp/handler/proxy
Package proxy implements a DHCP handler that provides proxyDHCP functionality.
Package proxy implements a DHCP handler that provides proxyDHCP functionality.
dhcp/handler/reservation
Package noop is a backend handler that does nothing.
Package noop is a backend handler that does nothing.
dhcp/otel
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.
dhcp/server
Package dhcp providers UDP listening and serving functionality.
Package dhcp providers UDP listening and serving functionality.
ipxe/binary/file
Package binary handles embedding of the iPXE binaries.
Package binary handles embedding of the iPXE binaries.
iso

Jump to

Keyboard shortcuts

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