Documentation ¶
Index ¶
- Variables
- func Execute()
- type Controller
- func (ctrl *Controller) DeleteFile(c context.Context, name string) error
- func (ctrl *Controller) Devices() []*web.DeviceInfo
- func (ctrl *Controller) HandlePacket(c context.Context, id string, packet []byte)
- func (ctrl *Controller) ListFiles(c context.Context) (*web.FileList, error)
- func (ctrl *Controller) MergeFiles(c context.Context, name string, srcs ...string) error
- func (ctrl *Controller) PauseFile(c context.Context) error
- func (ctrl *Controller) PlayFile(c context.Context, name string) error
- func (ctrl *Controller) RecordFile(c context.Context, name string) error
- func (ctrl *Controller) ResumeFile(c context.Context) error
- func (ctrl *Controller) Run(c context.Context) error
- func (ctrl *Controller) SetDefaultFile(c context.Context, name string) error
- func (ctrl *Controller) SetProxyForwarding(c context.Context, forward bool) error
- func (ctrl *Controller) Shutdown(c context.Context, restart bool) error
- func (ctrl *Controller) Status() web.ControllerStatus
- func (ctrl *Controller) Stop(c context.Context) error
- func (ctrl *Controller) Strips(c context.Context, deviceName string) ([]web.Strip, error)
- func (ctrl *Controller) SystemState(c context.Context) *web.SystemState
- type SystemControl
Constants ¶
This section is empty.
Variables ¶
var DefaultSystemControl = &SystemControl{ ValidateAccess: func(c context.Context) error { sudo, shutdown, err := getSudoShutdownCommands() if err != nil { return err } err = runCommand(c, false, sudo, "--non-interactive", "--list", "--", shutdown) if err != nil { return errors.Wrap(err, "user does not have permission") } return nil }, Shutdown: func(c context.Context) error { sudo, shutdown, err := getSudoShutdownCommands() if err != nil { return err } return runCommand(c, true, sudo, "--non-interactive", "--", shutdown, "--poweroff", "now") }, Restart: func(c context.Context) error { sudo, shutdown, err := getSudoShutdownCommands() if err != nil { return err } err = runCommand(c, true, sudo, "--non-interactive", "--", shutdown, "--reboot", "now") if err != nil { return errors.Wrap(err, "user does not have permission") } return nil }, }
DefaultSystemControl implements SystemControl, returning an error for each command.
Functions ¶
Types ¶
type Controller ¶
type Controller struct { // Storage manages the underlying storage filesystem. Storage *storage.S // Router is the router to use for packet routing. Router *device.Router // DiscoveryRegistry is a registry of discovered devices. DiscoveryRegistry *discovery.Registry // ProxyManager manages the device proxy state. ProxyManager *proxy.Manager // Snapshots, if not nil, is the snapshot manager for registered devices. Snapshots *device.SnapshotManager // ShutdownFunc is a function that can be called to shutdown the system, // cancelling its outer Context. ShutdownFunc context.CancelFunc // PlaybackMaxLagAge is the MaxLagAge value to provide to our Player. PlaybackMaxLagAge time.Duration // AutoResumeDelay, if >0, is the amount of time after (a) the Controller has // been paused, and (b) the ProxyManager has received a packet, after which // the Controller will automatically resume. AutoResumeDelay time.Duration // contains filtered or unexported fields }
Controller controls the operational state of the application.
func (*Controller) DeleteFile ¶
func (ctrl *Controller) DeleteFile(c context.Context, name string) error
DeleteFile implements web.ControllerProxy.
func (*Controller) Devices ¶
func (ctrl *Controller) Devices() []*web.DeviceInfo
Devices implements web.ControllerProxy.
func (*Controller) HandlePacket ¶
func (ctrl *Controller) HandlePacket(c context.Context, id string, packet []byte)
HandlePacket offers a captured packet to the controller for handling.
func (*Controller) MergeFiles ¶
MergeFiles implements web.ControllerProxy.
func (*Controller) PauseFile ¶
func (ctrl *Controller) PauseFile(c context.Context) error
PauseFile implements web.ControllerProxy.
func (*Controller) PlayFile ¶
func (ctrl *Controller) PlayFile(c context.Context, name string) error
PlayFile implements web.ControllerProxy.
func (*Controller) RecordFile ¶
func (ctrl *Controller) RecordFile(c context.Context, name string) error
RecordFile implements web.ControllerProxy.
func (*Controller) ResumeFile ¶
func (ctrl *Controller) ResumeFile(c context.Context) error
ResumeFile implements web.ControllerProxy.
func (*Controller) Run ¶
func (ctrl *Controller) Run(c context.Context) error
Run runs the Controller until its Context is cancelled.
func (*Controller) SetDefaultFile ¶
func (ctrl *Controller) SetDefaultFile(c context.Context, name string) error
SetDefaultFile implements web.ControllerProxy.
func (*Controller) SetProxyForwarding ¶
func (ctrl *Controller) SetProxyForwarding(c context.Context, forward bool) error
SetProxyForwarding enables or disables Controller-level block on proxy forwarding.
func (*Controller) Shutdown ¶
func (ctrl *Controller) Shutdown(c context.Context, restart bool) error
Shutdown implements web.ControllerProxy.
func (*Controller) Status ¶
func (ctrl *Controller) Status() web.ControllerStatus
Status implements web.ControllerProxy.
func (*Controller) Stop ¶
func (ctrl *Controller) Stop(c context.Context) error
Stop implements web.ControllerProxy.
func (*Controller) SystemState ¶
func (ctrl *Controller) SystemState(c context.Context) *web.SystemState
SystemState implements web.ControllerProxy.
type SystemControl ¶
type SystemControl struct { // ValidateAccess attempts to validate whether or not the current user has // access to system commands. It will return an error if they do not. ValidateAccess func(context.Context) error // Shutdown issues a shutdown command. Shutdown func(context.Context) error // Restart issues a restart command. Restart func(context.Context) error }
SystemControl is a control to the local system.