ipxe

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

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 26 Imported by: 1

README

Test and Build codecov Go Report Card Go Reference

ipxe

tftp and http server for ipxe binaries

Usage

go run cmd/ipxe/main.go

Design Philosophy

This repository is designed to be both a library and a command line tool.

Architecture

The following architectural diagram details how this iPXE binary service fits into the greater PXE stack. Architecture.

Documentation

Overview

Package ipxe implements the iPXE tftp and http server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServeHTTP

func ListenAndServeHTTP(ctx context.Context, addr netaddr.IPPort, h *http.Server) error

ListenAndServeHTTP is a patterned after http.ListenAndServe. It listens on the TCP network address srv.Addr and then calls ServeHTTP to handle requests on incoming connections.

ListenAndServeHTTP always returns a non-nil error. After Shutdown or Close, the returned error is http.ErrServerClosed.

func ListenAndServeTFTP

func ListenAndServeTFTP(ctx context.Context, addr netaddr.IPPort, s *tftp.Server) error

ListenAndServeTFTP sets up the listener on the given address and serves TFTP requests.

func ServeHTTP

func ServeHTTP(_ context.Context, conn net.Listener, h *http.Server) error

ServeHTTP is patterned after http.Serve. It accepts incoming connections on the Listener conn and serves them using the Server h.

ServeHTTP always returns a non-nil error and closes conn. After Shutdown or Close, the returned error is http.ErrServerClosed.

func ServeTFTP

func ServeTFTP(_ context.Context, conn net.PacketConn, s *tftp.Server) error

ServeTFTP serves TFTP requests using the given conn and server.

Types

type Config

type Config struct {
	// TFTP holds the details for the TFTP server.
	TFTP TFTP
	// HTTP holds the details for the HTTP server.
	HTTP HTTP
	// Log is the logger to use.
	Log logr.Logger
}

Config holds the details for running the iPXE service.

func (Config) Serve

func (c Config) Serve(ctx context.Context) error

Serve will listen and serve iPXE binaries over TFTP and HTTP. See binary/binary.go for the iPXE files that are served.

type HTTP

type HTTP struct {
	//  Addr is the address:port to listen on.
	Addr netaddr.IPPort
	// Timeout is the timeout for serving HTTP files.
	Timeout time.Duration
}

HTTP is the configuration for the HTTP server.

type HandleHTTP

type HandleHTTP struct {
	Log logr.Logger
}

HandleHTTP is the struct that implements the http.Handler interface.

func (HandleHTTP) Handler

func (s HandleHTTP) Handler(w http.ResponseWriter, req *http.Request)

Handler handles responses to HTTP requests.

type HandleTFTP

type HandleTFTP struct {
	Log logr.Logger
}

HandleTFTP is the struct that implements the TFTP read and write function handlers.

func (HandleTFTP) ReadHandler

func (t HandleTFTP) ReadHandler(filename string, rf io.ReaderFrom) error

ReadHandler handlers TFTP GET requests.

func (HandleTFTP) WriteHandler

func (t HandleTFTP) WriteHandler(filename string, wt io.WriterTo) error

WriteHandler handles TFTP PUT requests. It will always return an error. This library does not support PUT.

type TFTP

type TFTP struct {
	// Addr is the address:port to listen on for TFTP requests.
	Addr netaddr.IPPort
	// Timeout is the timeout for serving TFTP files.
	Timeout time.Duration
}

TFTP is the configuration for the TFTP server.

Directories

Path Synopsis
Package binary holds the embedded ipxe binaries.
Package binary holds the embedded ipxe binaries.
cmd

Jump to

Keyboard shortcuts

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