Documentation ¶
Overview ¶
Package pxe aims to implement the PXE specification.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultHTTPClient is the default HTTP FileScheme. // // It is not recommended to use this for HTTPS. We recommend creating an // http.Client that accepts only a private pool of certificates. DefaultHTTPClient = NewHTTPClient(http.DefaultClient) // DefaultTFTPClient is the default TFTP FileScheme. DefaultTFTPClient = NewTFTPClient() // DefaultSchemes are the schemes supported by PXE by default. DefaultSchemes = Schemes{ "tftp": DefaultTFTPClient, "http": DefaultHTTPClient, "file": &LocalFileClient{}, } )
var ( // ErrDefaultEntryNotFound is returned when the configuration file // names a default label that is not part of the configuration. ErrDefaultEntryNotFound = errors.New("default label not found in configuration") )
var ( // ErrNoSuchScheme is returned by Schemes.GetFile and // Schemes.LazyGetFile if there is no registered FileScheme // implementation for the given URL scheme. ErrNoSuchScheme = errors.New("no such scheme") )
Functions ¶
func LazyGetFile ¶
LazyGetFile calls LazyGetFile on DefaultSchemes. See Schemes.LazyGetFile.
func RegisterScheme ¶
func RegisterScheme(scheme string, fs FileScheme)
RegisterScheme calls DefaultSchemes.Register.
Types ¶
type Config ¶
type Config struct { // Entries is a map of label name -> label configuration. Entries map[string]*boot.LinuxImage // DefaultEntry is the default label key to use. // // If DefaultEntry is non-empty, the label is guaranteed to exist in // `Entries`. DefaultEntry string // contains filtered or unexported fields }
Config encapsulates a parsed Syslinux configuration file.
See http://www.syslinux.org/wiki/index.php?title=Config for the configuration file specification.
TODO: Tear apart parser internals from Config.
func NewConfig ¶
NewConfig returns a new PXE parser using working directory `wd` and default schemes.
See NewConfigWithSchemes for more details.
func NewConfigWithSchemes ¶
NewConfigWithSchemes returns a new PXE parser using working directory `wd` and schemes `s`.
If a path encountered in a configuration file is relative instead of a full URL, `wd` is used as the "working directory" of that relative path; the resulting URL is roughly `wd.String()/path`.
`s` is used to get files referred to by URLs.
func ParseConfigFile ¶
ParseConfigFile parses a PXE/Syslinux configuration as specified in http://www.syslinux.org/wiki/index.php?title=Config
Currently, only the APPEND, INCLUDE, KERNEL, LABEL, DEFAULT, and INITRD directives are partially supported.
`wd` is the default scheme, host, and path for any files named as a relative path. The default path for config files is assumed to be `wd.Path`/pxelinux.cfg/.
func (*Config) AppendFile ¶
AppendFile parses the config file downloaded from `url` and adds it to `c`.
func (*Config) FindConfigFile ¶
FindConfigFile probes for config files based on the Mac and IP given.
func (*Config) GetFile ¶
GetFile parses `url` relative to the config's working directory and returns an io.Reader for the requested url.
If url is just a relative path and not a full URL, c.wd is used as the "working directory" of that relative path; the resulting URL is roughly path.Join(wd.String(), url).
type FileScheme ¶
type FileScheme interface { // GetFile returns a reader that gives the contents of `u`. // // It may do so by downloading `u` and placing it in a buffer, or by // returning an io.ReaderAt that downloads the file. GetFile(u *url.URL) (io.ReaderAt, error) }
FileScheme represents the implementation of a URL scheme and gives access to downloading files of that scheme.
For example, an http FileScheme implementation would download files using the HTTP protocol.
func NewTFTPClient ¶
func NewTFTPClient(opts ...tftp.ClientOpt) FileScheme
NewTFTPClient returns a new TFTP client based on the given tftp.ClientOpt.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient implements FileScheme for HTTP files.
func NewHTTPClient ¶
func NewHTTPClient(c *http.Client) *HTTPClient
NewHTTPClient returns a new HTTP FileScheme based on the given http.Client.
type LocalFileClient ¶
type LocalFileClient struct{}
LocalFileClient implements FileScheme for files on disk.
type Schemes ¶
type Schemes map[string]FileScheme
Schemes is a map of URL scheme identifier -> implementation that can download a file for that scheme.
func (Schemes) GetFile ¶
GetFile downloads the file with the given `u`. `u.Scheme` is used to select the FileScheme via `s`.
If `s` does not contain a FileScheme for `u.Scheme`, ErrNoSuchScheme is returned.
func (Schemes) LazyGetFile ¶
LazyGetFile returns a reader that will download the file given by `u` when Read is called, based on `u`s scheme. See Schemes.GetFile for more details.
func (Schemes) Register ¶
func (s Schemes) Register(scheme string, fs FileScheme)
Register registers a scheme identified by `scheme` to be `fs`.
type TFTPClient ¶
type TFTPClient struct {
// contains filtered or unexported fields
}
TFTPClient implements FileScheme for TFTP files.