midlayer

package
v3.8.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

midlayer contains the DHCP server code for DigitalRebar Provision. It has the responsibility for providing the actual data manipulate for the DHCP Protocol.

Index

Constants

View Source
const (
	PLUGIN_CREATED     int = 1
	PLUGIN_STARTED     int = 2
	PLUGIN_CONFIGED    int = 3
	PLUGIN_STOPPED     int = 4
	PLUGIN_REMOVED     int = 5
	PLUGIN_CONFIGURING int = 6
	PLUGIN_SHOULD_STOP int = 7
)

Variables

This section is empty.

Functions

func CleanUpStore

func CleanUpStore(st store.Store) error

func MacStrategy

func MacStrategy(p dhcp.Packet, options dhcp.Options) string

func OsUdpProtoCheck

func OsUdpProtoCheck() string

func ReverseProxy

func ReverseProxy(pc *PluginController) gin.HandlerFunc

func ServeStatic

func ServeStatic(listenAt string, responder http.Handler, logger logger.Logger, pubs *backend.Publishers) (*http.Server, error)

Types

type Actions

type Actions struct {
	// contains filtered or unexported fields
}

func NewActions

func NewActions() *Actions

func (*Actions) Add

func (ma *Actions) Add(model_aa models.AvailableAction, plugin *RunningPlugin) error

func (*Actions) Get

func (ma *Actions) Get(ob, name string) (AvailableActions, bool)

func (*Actions) GetSpecific

func (ma *Actions) GetSpecific(ob, name, plugin string) (*AvailableAction, bool)

func (*Actions) List

func (ma *Actions) List(ob string) []AvailableActions

func (*Actions) Remove

func (ma *Actions) Remove(aa models.AvailableAction, plugin *RunningPlugin) error

func (*Actions) Run

func (ma *Actions) Run(rt *backend.RequestTracker, ob string, maa *models.Action) (interface{}, error)

type AvailableAction

type AvailableAction struct {
	models.AvailableAction

	Plugin *RunningPlugin
	// contains filtered or unexported fields
}

func (*AvailableAction) Release

func (aa *AvailableAction) Release()

func (*AvailableAction) Reserve

func (aa *AvailableAction) Reserve() error

func (*AvailableAction) Unload

func (aa *AvailableAction) Unload()

type AvailableActions

type AvailableActions []*AvailableAction

type DataStack

type DataStack struct {
	store.StackedStore
	// contains filtered or unexported fields
}

func DefaultDataStack

func DefaultDataStack(dataRoot, backendType, localContent, defaultContent, saasDir, fileRoot string) (*DataStack, error)

func (*DataStack) AddReplacePluginLayer

func (d *DataStack) AddReplacePluginLayer(
	name string,
	newStore store.Store,
	logger logger.Logger,
	fixup FixerUpper) (*DataStack, error, error)

func (*DataStack) AddReplaceSAAS

func (d *DataStack) AddReplaceSAAS(
	name string,
	newStore store.Store,
	logger logger.Logger,
	fixup FixerUpper) (*DataStack, error, error)

func (*DataStack) Clone

func (d *DataStack) Clone() *DataStack

func (*DataStack) RemovePluginLayer

func (d *DataStack) RemovePluginLayer(name string, logger logger.Logger) (*DataStack, error, error)

func (*DataStack) RemoveSAAS

func (d *DataStack) RemoveSAAS(name string, logger logger.Logger) (*DataStack, error, error)

type DhcpHandler

type DhcpHandler struct {
	logger.Logger
	// contains filtered or unexported fields
}

DhcpHandler is responsible for listening to incoming DHCP packets, building a DhcpRequest for each one, then kicking that reqest off to handle the packet.

func (*DhcpHandler) NewRequest

func (h *DhcpHandler) NewRequest(buf []byte, cm *ipv4.ControlMessage, srcAddr net.Addr) *DhcpRequest

func (*DhcpHandler) Serve

func (h *DhcpHandler) Serve() error

func (*DhcpHandler) Shutdown

func (h *DhcpHandler) Shutdown(ctx context.Context) error

type DhcpRequest

type DhcpRequest struct {
	logger.Logger
	// contains filtered or unexported fields
}

DhcpRequest records all the information needed to handle a single in-flight DHCP request. One of these is created for every incoming DHCP packet.

func (*DhcpRequest) FakeLease

func (dhr *DhcpRequest) FakeLease(req net.IP) (*backend.Lease, *backend.Subnet, *backend.Reservation)

FakeLease is a helper function for fetching a fake lease from the backend. We use fake leases when handling ProxyDHCP and binl requests, as we don't actually want to allocate an IP address or anything crazy like that.

func (*DhcpRequest) MarshalText

func (dhr *DhcpRequest) MarshalText() ([]byte, error)

func (*DhcpRequest) PrintIncoming

func (dhr *DhcpRequest) PrintIncoming() string

func (*DhcpRequest) PrintOutgoing

func (dhr *DhcpRequest) PrintOutgoing(p dhcp.Packet) string

func (*DhcpRequest) Process

func (dhr *DhcpRequest) Process() dhcp.Packet

Process is responsible for checking basic sanity of an incoming DHCP packet, handing it off to ServeDHCP or ServeBinl, and performing some common post-processing if we have an outgoing packet to send.

func (*DhcpRequest) Request

func (dhr *DhcpRequest) Request(locks ...string) *backend.RequestTracker

Request is a shorthand function for creating a RequestTracker to interact with the backend.

func (*DhcpRequest) Run

func (dhr *DhcpRequest) Run()

Run processes an incoming DhcpRequest and sends the resulting packet (if any) back out over the same interface it came in on.

func (*DhcpRequest) ServeBinl

func (dhr *DhcpRequest) ServeBinl(msgType dhcp.MessageType) dhcp.Packet

ServeBinl is responsible for handling ProxyDHCP Request messages and binl Discover messages. Both of those come in on port 4011.

func (*DhcpRequest) ServeDHCP

func (dhr *DhcpRequest) ServeDHCP(msgType dhcp.MessageType) dhcp.Packet

ServeDHCP is responsible for handling regular DHCP traffic as well as ProxyDHCP DISCOVER messages -- essentially everything that comes in on port 67.

func (*DhcpRequest) Strategy

func (dhr *DhcpRequest) Strategy(name string) StrategyFunc

func (*DhcpRequest) UnmarshalText

func (dhr *DhcpRequest) UnmarshalText(buf []byte) error

type FixerUpper

type FixerUpper func(*DataStack, store.Store) error

FixerUpper takes a the datastack and a store.Store that is to be added to the passed stack. FixerUpper is responsible for making sure that it can integrate the new store into the stack, making whatever changes are needed to the current datastack to make inclusion possible. It must take care to scan and detect if it will not be able to maek changes, because any changes it has to make to items in the data stack will be live and not possible to undo after FixerUpper returns.

type ObjectCommands

type ObjectCommands map[string]AvailableActions

type ObjectsCommands

type ObjectsCommands map[string]ObjectCommands

type PluginClient

type PluginClient struct {
	logger.Logger
	// contains filtered or unexported fields
}

func NewPluginClient

func NewPluginClient(pc *PluginController, pluginCommDir, plugin, provider string, l logger.Logger, apiURL, staticURL, token, path string) (answer *PluginClient, theErr error)

func (*PluginClient) Action

func (pc *PluginClient) Action(rt *backend.RequestTracker, a *models.Action) (interface{}, error)

func (*PluginClient) Config

func (pc *PluginClient) Config(params map[string]interface{}) error

func (*PluginClient) Publish

func (pc *PluginClient) Publish(e *models.Event) error

func (*PluginClient) Release

func (pc *PluginClient) Release()

func (*PluginClient) Reserve

func (pc *PluginClient) Reserve() error

func (*PluginClient) Stop

func (pc *PluginClient) Stop() error

func (*PluginClient) Unload

func (pc *PluginClient) Unload()

type PluginController

type PluginController struct {
	logger.Logger

	AvailableProviders map[string]*models.PluginProvider

	Actions *Actions
	// contains filtered or unexported fields
}

func InitPluginController

func InitPluginController(pluginDir, pluginCommDir string, dt *backend.DataTracker, pubs *backend.Publishers) (pc *PluginController, err error)

* Create contoller and start an event listener.

func (*PluginController) GetPluginProvider

func (pc *PluginController) GetPluginProvider(name string) *models.PluginProvider

func (*PluginController) GetPluginProviders

func (pc *PluginController) GetPluginProviders() []*models.PluginProvider

func (*PluginController) Publish

func (pc *PluginController) Publish(e *models.Event) error

func (*PluginController) Release

func (pc *PluginController) Release()

func (*PluginController) RemovePluginProvider

func (pc *PluginController) RemovePluginProvider(name string) error

func (*PluginController) Request

func (pc *PluginController) Request(locks ...string) *backend.RequestTracker

func (*PluginController) Reserve

func (pc *PluginController) Reserve() error

This never gets unloaded.

func (*PluginController) Shutdown

func (pc *PluginController) Shutdown(ctx context.Context) error

func (*PluginController) StartController

func (pc *PluginController) StartController() error

func (*PluginController) StartPlugins

func (pc *PluginController) StartPlugins()

func (*PluginController) StartRouter

func (pc *PluginController) StartRouter(apiGroup *gin.RouterGroup)

func (*PluginController) Unload

func (pc *PluginController) Unload()

func (*PluginController) UploadPluginProvider

func (pc *PluginController) UploadPluginProvider(c *gin.Context, fileRoot, name string) (*models.PluginProviderUploadInfo, *models.Error)

type RunningPlugin

type RunningPlugin struct {
	Plugin   *models.Plugin
	Provider *models.PluginProvider
	Client   *PluginClient
	// contains filtered or unexported fields
}

type Service

type Service interface {
	Shutdown(context.Context) error
}

func ServeTftp

func ServeTftp(listen string, responder func(string, net.IP) (io.Reader, error),
	log logger.Logger, pubs *backend.Publishers) (Service, error)

func StartDhcpHandler

func StartDhcpHandler(dhcpInfo *backend.DataTracker,
	log logger.Logger,
	dhcpIfs string,
	dhcpPort int,
	pubs *backend.Publishers,
	proxyOnly bool,
	fakePinger bool) (Service, error)

type Strategy

type Strategy struct {
	Name     string
	GenToken StrategyFunc
}

type StrategyFunc

type StrategyFunc func(p dhcp.Packet, options dhcp.Options) string

type TftpHandler

type TftpHandler struct {
	// contains filtered or unexported fields
}

func (*TftpHandler) Shutdown

func (h *TftpHandler) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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