server

package
v1.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: BSD-3-Clause Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const BOOTSTRAP_MAC_ADDRESS = "000000000000"
View Source
const DEFAULT_ALPINE_MIRROR = "https://dl-cdn.alpinelinux.org"
View Source
const DEFAULT_BIND_ADDRESS = "127.0.0.1"
View Source
const DEFAULT_DEBIAN_MIRROR = "http://ftp.us.debian.org"

mirrors used by netboot proxy feature

View Source
const DEFAULT_DEBIAN_SECURITY_MIRROR = "http://security.debian.org"
View Source
const DEFAULT_HTTPS_PORT = "4443"
View Source
const DEFAULT_HTTP_PORT = "4444"
View Source
const DEFAULT_ISO_KEY_LIFETIME = 600
View Source
const DEFAULT_MAX_DIST_UPLOAD_MB = 1024
View Source
const DEFAULT_OPENBSD_MIRROR = "https://ftp.openbsd.org"
View Source
const DEFAULT_SERVER_NAME = "localhost"
View Source
const DEFAULT_SHUTDOWN_TIMEOUT_SECONDS = 10
View Source
const DEFAULT_WHITELIST_LIFETIME = 3600
View Source
const GENERATE_IMAGE = true
View Source
const NO_GENERATE_IMAGE = false
View Source
const Version = "1.3.7"

Variables

View Source
var ALPINE_VERSION_PATTERN = regexp.MustCompile(`([0-9][0-9]*)\.([0-9][0-9]*)\.([0-9][0-9]*)$`)
View Source
var APKOVL_PATTERN = regexp.MustCompile(`^([0-9A-Fa-f]{2}[:-]{0,1}){5}([0-9A-Fa-f]{2})\.apkovl\.tar\.gz$`)
View Source
var DIST_DELETE_PATTERNS []*regexp.Regexp = []*regexp.Regexp{
	regexp.MustCompile(`^pub/alpine(/.*)*`),
	regexp.MustCompile(`^pub/debian(/.*)*`),
	regexp.MustCompile(`^pub/OpenBSD(/.*)*`),
	regexp.MustCompile(`^pub/windows(/.*)*`),
}
View Source
var DIST_TREE_PATTERNS []*regexp.Regexp = []*regexp.Regexp{
	regexp.MustCompile(`.*`),
}
View Source
var DIST_UPLOAD_PATTERNS []*regexp.Regexp = []*regexp.Regexp{
	regexp.MustCompile(`^pub/alpine/\d\.\d\.\d/x86_64/[[:word:].-]+`),
	regexp.MustCompile(`^pub/debian/[a-z]+/amd64/[[:word:].-]+`),
	regexp.MustCompile(`^pub/OpenBSD/\d\.\d/packages/amd64/[[:word:].-]+`),
	regexp.MustCompile(`^pub/windows/\d+/x64/[[:word:].-]+`),
}
View Source
var GDL_VERSION_PATTERN = regexp.MustCompile(`^pub/.*/rstms-gdl-(\d+)\.(\d+)\.(\d+).*\.tgz$`)
View Source
var IPXE_PATTERN = regexp.MustCompile(`^([0-9A-Fa-f]{2}[:-]{0,1}){5}([0-9A-Fa-f]{2})\.ipxe$`)
View Source
var InternalShutdownRequest chan struct{}
View Source
var MAC_ISO_PATTERN = regexp.MustCompile(`^([0-9A-Fa-f]{2}[:-]{0,1}){5}([0-9A-Fa-f]{2})\.iso$`)
View Source
var MAC_PATTERN = regexp.MustCompile(`^([0-9A-Fa-f]{2}[:-]{0,1}){5}([0-9A-Fa-f]{2})$`)
View Source
var NORMALIZED_MAC_PATTERN = regexp.MustCompile(`^[0-9a-f]{12}$`)
View Source
var TARBALL_PATTERN = regexp.MustCompile(`^([0-9a-f]{12})\.tgz$`)
View Source
var VERSION_PATTERN = regexp.MustCompile(`^(\d+)\.(\d+)\.(\d+)$`)

Functions

func AppendConfig added in v0.1.9

func AppendConfig(filename string) error

func CheckErr added in v0.0.14

func CheckErr(err error)

func CobraAddCommand added in v0.0.14

func CobraAddCommand(cobraRootCmd, parentCmd, cobraCmd CobraCommand)

func CobraInit added in v0.0.14

func CobraInit(cobraRootCmd CobraCommand)

func ConfigDir added in v0.1.9

func ConfigDir() string

func ConfigEdit added in v0.0.14

func ConfigEdit()

func ConfigInit added in v0.0.14

func ConfigInit(allowClobber bool) string

func ConfigString added in v0.0.14

func ConfigString(header bool) string

func Confirm added in v0.0.14

func Confirm(prompt string) bool

func CreateEFIImage added in v0.1.9

func CreateEFIImage(dstImage, efiBin, autoexec string) error

func DefaultDist added in v1.1.36

func DefaultDist(os string) (string, string, string, error)

func DownloadFileRoot added in v0.0.7

func DownloadFileRoot(root *os.Root, mirrorUrl, requestPath string) (string, []byte, error)

func Expand added in v0.0.14

func Expand(value string) string

func Fatal added in v0.0.3

func Fatal(err error) error

func Fatalf added in v0.0.3

func Fatalf(format string, args ...interface{}) error

func FormatJSON

func FormatJSON(v any) string

func FormatMAC added in v0.1.9

func FormatMAC(mac, separator string) (string, error)

func FormatYAML added in v0.1.9

func FormatYAML(value any) string

func GenerateInitrd added in v0.0.3

func GenerateInitrd(outputName, inputName string, fileNames []string) error

func GetHostnameDetail added in v0.1.9

func GetHostnameDetail() (string, string, string, error)

func HexDump added in v0.0.14

func HexDump(data []byte) string

func HostDomain added in v0.1.9

func HostDomain() (string, error)

func HostFQDN added in v0.1.9

func HostFQDN() (string, error)

func HostShortname added in v0.1.9

func HostShortname() (string, error)

func Init added in v0.0.14

func Init(name, version, configFile string)

func IsDir

func IsDir(path string) bool

func IsDirRoot added in v0.0.7

func IsDirRoot(root *os.Root, pathname string) bool

func IsFile

func IsFile(pathname string) bool

func IsFileRoot added in v0.0.7

func IsFileRoot(root *os.Root, pathname string) bool

func MkdirAllRoot added in v0.0.7

func MkdirAllRoot(root *os.Root, pathname string) error

func OptionInt added in v0.1.4

func OptionInt(cobraCmd CobraCommand, name, flag string, defaultValue int, description string)

func OptionKey added in v0.0.14

func OptionKey(cobraCmd CobraCommand, key string) string

func OptionString added in v0.0.14

func OptionString(cobraCmd CobraCommand, name, flag, defaultValue, description string)

func OptionStringSlice added in v0.1.9

func OptionStringSlice(cobraCmd CobraCommand, name, flag string, defaultValue []string, description string)

func OptionSwitch added in v0.0.14

func OptionSwitch(cobraCmd CobraCommand, name, flag, description string)

func ProgramName added in v0.0.14

func ProgramName() string

func ProgramVersion added in v0.0.14

func ProgramVersion() string

func SemverSort added in v1.2.38

func SemverSort(unsorted []string, pattern *regexp.Regexp) ([]string, error)

semver srot a slice of strings using a regex pattern to parse major, minor, patch groups

func Shutdown added in v0.0.14

func Shutdown()

func TildePath added in v0.0.14

func TildePath(path string) (string, error)

func ViperGet added in v0.1.3

func ViperGet(key string) any

func ViperGetBool added in v0.0.14

func ViperGetBool(key string) bool

func ViperGetInt added in v0.0.14

func ViperGetInt(key string) int

func ViperGetInt64 added in v0.0.14

func ViperGetInt64(key string) int64

func ViperGetString added in v0.0.14

func ViperGetString(key string) string

func ViperGetStringMapString added in v0.1.3

func ViperGetStringMapString(key string) map[string]string

func ViperGetStringSlice added in v0.0.14

func ViperGetStringSlice(key string) []string

func ViperKey added in v0.0.14

func ViperKey(key string) string

func ViperSet added in v0.0.14

func ViperSet(key string, value any)

func ViperSetDefault added in v0.0.14

func ViperSetDefault(key string, value any)

func Warning added in v0.0.7

func Warning(format string, args ...interface{})

Types

type APIClient added in v0.1.3

type APIClient interface {
	Close()
	Get(path string, response interface{}) (string, error)
	Post(path string, request, response interface{}, headers *map[string]string) (string, error)
	Put(path string, request, response interface{}, headers *map[string]string) (string, error)
	Delete(path string, response interface{}) (string, error)
}

func NewAPIClient added in v0.1.3

func NewAPIClient(prefix, url, certFile, keyFile, caFile string, headers *map[string]string) (APIClient, error)

type CobraCommand added in v0.0.14

type CobraCommand interface {
}

type Host

type Host struct {
	Address string `json:"address"`
}

type HostCache

type HostCache struct {
	Name string
	// contains filtered or unexported fields
}

func NewHostCache

func NewHostCache(dir string, httpPort, httpsPort int, proxyEnabled bool) (*HostCache, error)

func (*HostCache) AddHostHandlerTLS added in v0.0.10

func (c *HostCache) AddHostHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) AddIsoKeyHandlerTLS added in v1.1.26

func (c *HostCache) AddIsoKeyHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) AddWhitelistAddressHandlerTLS added in v1.1.23

func (c *HostCache) AddWhitelistAddressHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) AlpineHandler added in v0.0.7

func (c *HostCache) AlpineHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) AlpineHandlerTLS added in v0.0.10

func (c *HostCache) AlpineHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) CheckUploadCache added in v1.2.25

func (c *HostCache) CheckUploadCache(mirror string, w http.ResponseWriter, r *http.Request) bool

func (*HostCache) DebianHandler added in v0.0.3

func (c *HostCache) DebianHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) DebianHandlerTLS added in v0.0.10

func (c *HostCache) DebianHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) DebianSecurityHandler added in v0.0.7

func (c *HostCache) DebianSecurityHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) DebianSecurityHandlerTLS added in v0.0.10

func (c *HostCache) DebianSecurityHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) DeleteDistHandlerTLS added in v1.2.32

func (c *HostCache) DeleteDistHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) DeleteHostHandlerTLS added in v0.0.10

func (c *HostCache) DeleteHostHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) DeleteIsoKeyHandlerTLS added in v1.1.26

func (c *HostCache) DeleteIsoKeyHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) DeleteWhitelistAddressHandlerTLS added in v1.1.23

func (c *HostCache) DeleteWhitelistAddressHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) GDLHandlerTLS added in v0.0.10

func (c *HostCache) GDLHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) GenerateISO added in v0.0.3

func (c *HostCache) GenerateISO(tempDir, url, httpUrl string, config *message.NetbootConfig) (string, []string, error)

Generate a url-customized netboot ISO returning generated iso pathname

func (*HostCache) GetDistHandlerTLS added in v1.2.33

func (c *HostCache) GetDistHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) GetHostSetStatusHandlerTLS added in v1.1.54

func (c *HostCache) GetHostSetStatusHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) HostAddressQueryHandlerTLS added in v0.0.10

func (c *HostCache) HostAddressQueryHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) IPXEHandlerTLS added in v0.0.7

func (c *HostCache) IPXEHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) ISOHandlerTLS added in v1.1.24

func (c *HostCache) ISOHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) ListHostsHandlerTLS added in v0.0.10

func (c *HostCache) ListHostsHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) OpenBSDHandler added in v0.0.3

func (c *HostCache) OpenBSDHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) OpenBSDHandlerTLS added in v0.0.10

func (c *HostCache) OpenBSDHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) PNGHandlerTLS added in v0.0.10

func (c *HostCache) PNGHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) PutBootstrapHandlerTLS added in v1.1.45

func (c *HostCache) PutBootstrapHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) PutHostStatusHandlerTLS added in v1.1.45

func (c *HostCache) PutHostStatusHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) RootHandler added in v0.0.5

func (c *HostCache) RootHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) RootHandlerTLS added in v0.0.10

func (c *HostCache) RootHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) SanBootHandler added in v0.0.10

func (c *HostCache) SanBootHandler(w http.ResponseWriter, r *http.Request)

FIXME: implement high-performance sanboot request handler

func (*HostCache) ShutdownHandlerTLS added in v1.0.35

func (c *HostCache) ShutdownHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) UTCHandler added in v0.0.7

func (c *HostCache) UTCHandler(w http.ResponseWriter, r *http.Request)

func (*HostCache) UTCHandlerTLS added in v0.0.10

func (c *HostCache) UTCHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) UploadDistHandlerTLS added in v1.2.32

func (c *HostCache) UploadDistHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) UploadPackageHandlerTLS added in v0.0.10

func (c *HostCache) UploadPackageHandlerTLS(w http.ResponseWriter, r *http.Request)

func (*HostCache) VersionHandlerTLS added in v0.0.10

func (c *HostCache) VersionHandlerTLS(w http.ResponseWriter, r *http.Request)

type InitFile

type InitFile struct {
	DstName string
	SrcName string
	Mode    fs.FileMode
	UID     int
	GID     int
}

type MkBoot

type MkBoot struct {
	TempDir   string
	IpxeDir   string
	URL       string
	BootFiles *[]string
	Config    *message.NetbootConfig
	ISO       string
}

func NewMkBoot

func NewMkBoot(tempDir, ipxeDir, url string, bootFiles *[]string, config *message.NetbootConfig) *MkBoot

func (*MkBoot) Generate

func (m *MkBoot) Generate() (string, error)

prepare OS-specific boot files in the cache directory named with MAC address

type NetbootServer added in v0.1.3

type NetbootServer struct {
	Name       string
	ServerName string
	Address    string
	HttpsPort  int
	HttpPort   int

	NetbootDir string
	// contains filtered or unexported fields
}

func NewNetbootServer added in v0.1.3

func NewNetbootServer() (*NetbootServer, error)

func (*NetbootServer) GetConfig added in v0.1.3

func (s *NetbootServer) GetConfig() map[string]any

func (*NetbootServer) Run added in v0.1.3

func (s *NetbootServer) Run() error

func (*NetbootServer) Start added in v0.1.3

func (s *NetbootServer) Start() error

func (*NetbootServer) Stop added in v0.1.3

func (s *NetbootServer) Stop() error

type Record added in v0.0.4

type Record struct {
	Header cpio.Header
	Data   []byte
}

type Sendmail added in v0.0.14

type Sendmail interface {
	Send(to, from, subject string, body []byte) error
}

func NewSendmail added in v0.0.14

func NewSendmail(hostname string, port int, username, password, CAFile string) (Sendmail, error)

type Template added in v0.0.11

type Template struct {
	Certs  embed.FS
	Ipxe   embed.FS
	Dist   embed.FS
	Mkboot embed.FS
}

Jump to

Keyboard shortcuts

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