handler

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package handler provides functions for responding to specific client requests by the ePoxy boot server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCannotAccessHost indicates that the request should not be allowed.
	ErrCannotAccessHost = fmt.Errorf("Caller cannot access host")
)

Functions

This section is empty.

Types

type Config

type Config interface {
	Save(host *storage.Host) error
	Load(name string) (*storage.Host, error)
}

Config provides access to Host records.

type Env

type Env struct {
	// Config provides access to Host records.
	Config Config
	// ServerAddr is the host:port of the public service. Used to generate absolute URLs.
	ServerAddr string
	// AllowForwardedRequests changes how the ePoxy server evaluates and applies
	// the Host IP whitelist to incoming requests. Typically, the ePoxy server
	// allows an operation when the request "remote address" matches the target Host
	// IP. AllowForwardedRequests should be false unless the ePoxy server runs
	// in a trusted environment like AppEngine. When AllowForwardedRequests is true,
	// then the ePoxy server substitutes the value in the "X-Forwarded-For" request
	// header for the request "remote address".
	AllowForwardedRequests bool
	// Project is the GCP project name in which the server is running.
	Project string
	// StoragePrefixURL is the target URL prefix for storage proxy requests.
	StoragePrefixURL string
}

Env holds data necessary for executing handler functions.

func (*Env) GenerateJSONConfig

func (env *Env) GenerateJSONConfig(rw http.ResponseWriter, req *http.Request)

GenerateJSONConfig creates and returns a JSON serialized nextboot.Config suitable for responding to stage2 or stage3 requests.

func (*Env) GenerateStage1IPXE

func (env *Env) GenerateStage1IPXE(rw http.ResponseWriter, req *http.Request)

GenerateStage1IPXE creates the stage1 iPXE script for booting machines.

func (*Env) GenerateStage1JSON

func (env *Env) GenerateStage1JSON(rw http.ResponseWriter, req *http.Request)

GenerateStage1JSON creates the stage1 JSON epoxy_client script for booting machines.

func (*Env) HandleExtension

func (env *Env) HandleExtension(rw http.ResponseWriter, req *http.Request)

HandleExtension handles client requests to ePoxy extension URLs. The handler creates and sends a request to the extension service registered for the operation.

func (*Env) HandleStorageProxy

func (env *Env) HandleStorageProxy(rw http.ResponseWriter, req *http.Request)

HandleStorageProxy creates a pass-through proxy for GET requests by concatenating the request "path" to the environment's StoragePrefixURL.

func (*Env) ReceiveReport

func (env *Env) ReceiveReport(rw http.ResponseWriter, req *http.Request)

ReceiveReport handles the last step of a boot sequence when the epoxy client reports success or failure. In both cases, the session ids are invalidated. In all cases, epoxy_client is expected to report the server's public host key.

Jump to

Keyboard shortcuts

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