config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2025 License: ISC Imports: 23 Imported by: 0

Documentation

Overview

Package config contains a convenient structure to pass around configuration data.

Index

Constants

View Source
const (

	// AutomationUser is created on remote systems to allow the
	// FMS to manage them programattically.
	AutomationUser = "gizmo-fms"

	// ViewOnlyUser is created on remote systems to enable
	// debugging and generally make it possible to get into
	// systems.
	ViewOnlyUser = "gizmo-ro"
)

Variables

This section is empty.

Functions

func LoadTeams added in v0.1.9

func LoadTeams(fr io.Reader) (map[int]*Team, error)

LoadTeams returns a map of team numbers to team structs, and is meant to allow loading from any reader, usually a file..

Types

type DSMeta added in v0.1.4

type DSMeta struct {
	Version  string
	Bootmode string
}

DSMeta stores information reported by the Driver's Station metadata feed.

func (DSMeta) BootmodeOK added in v0.1.9

func (d DSMeta) BootmodeOK(bList string) bool

BootmodeOK compares if the boot mode is in the list of accepted bootmodes.

func (DSMeta) VersionOK added in v0.1.9

func (d DSMeta) VersionOK(vList string) bool

VersionOK compares the version against a string containing all permitted versions.

type FMSConfig added in v0.1.9

type FMSConfig struct {

	// Teams contains the information needed to generate
	// configuration for all teams.
	Teams map[int]*Team

	// Fields contains a list of fields that are configured and
	// managed by the system.
	Fields map[int]*Field

	// FMSMac is the mac address of the FMS itself so that it can
	// have a pinned address
	FMSMac string

	// RadioMode is used to determine which radios are active for
	// the field.  This can be 'NONE', 'FIELD', or 'DS'.  'NONE'
	// predicably disables all radios and is really only useful in
	// games where there is a field tether.  'FIELD' operates
	// using the high-power field radio and causes driver's
	// station radios to be disabled, whereas 'DS' is the inverse
	// causing the field radio to be disabled and remotely
	// controlling the DS radios.
	RadioMode string

	AutoUser string
	AutoPass string
	ViewUser string
	ViewPass string

	// This is the actual "admin" user in RouterOS.  Generally
	// nobody should be logged in as this, but its here anyway so
	// its a known value.
	AdminPass string

	Integrations IntegrationSlice

	InfrastructureVisible bool
	InfrastructureSSID    string
	InfrastructurePSK     string

	// There are cases where fixed DNS servers are desirable.
	FixedDNS []string

	AdvancedBGPAS     int
	AdvancedBGPIP     string
	AdvancedBGPPeerIP string
	AdvancedBGPVLAN   int

	// CompatData is used so the HUD can flag team hardware that
	// is out of compliance.
	CompatHardwareVersions string
	CompatFirmwareVersions string
	CompatDSBootmodes      string
	CompatDSVersions       string
	// contains filtered or unexported fields
}

FMSConfig contains all the data that's necessary to setup the FMS and manage the network behind it.

func NewFMSConfig added in v0.1.9

func NewFMSConfig(l hclog.Logger) (*FMSConfig, error)

NewFMSConfig returns a new configuration instance, that has been loaded from the default path if possible.

func (*FMSConfig) Load added in v0.1.9

func (c *FMSConfig) Load() error

Load loads a config file from the given path on disk.

func (*FMSConfig) ReconcileTeams added in v0.1.9

func (c *FMSConfig) ReconcileTeams(t map[int]*Team)

ReconcileTeams updates the configuration's team list to match the one that is provided. This has to be done with care to avoid cycling security keys unnecessarily.

func (*FMSConfig) Save added in v0.1.9

func (c *FMSConfig) Save() error

Save persists a config to the named path, creating it if necessary.

func (*FMSConfig) SortedTeams added in v0.1.9

func (c *FMSConfig) SortedTeams() []*Team

SortedTeams returns a list of teams that are sorted by the team number. This makes it easy to visually scan a team list and know roughly where they should be.

func (*FMSConfig) WizardChangeChannels added in v0.1.9

func (c *FMSConfig) WizardChangeChannels() error

WizardChangeChannels is used to reconfigure the channels each field is assigned to. This function duplicates some of the config in the field configuration step, but this is to avoid any possibility of creating or destroying a field.

func (*FMSConfig) WizardChangeIntegrations added in v0.1.9

func (c *FMSConfig) WizardChangeIntegrations() error

WizardChangeIntegrations can be used to reconfigure what integrations are enabled.

func (*FMSConfig) WizardChangeRadioMode added in v0.1.9

func (c *FMSConfig) WizardChangeRadioMode() error

WizardChangeRadioMode is used to reconfigure the radio mode after it has been initially setup.

func (*FMSConfig) WizardChangeRoster added in v0.1.9

func (c *FMSConfig) WizardChangeRoster() error

WizardChangeRoster is used to change the roster in an FMS Config that already exists. Teams will be loaded then reconciled. Existing teams can have name updated, but wireless parameters will not be changed.

func (*FMSConfig) WizardSurvey added in v0.1.9

func (c *FMSConfig) WizardSurvey(wouldOverwrite bool) error

WizardSurvey runs a step by step config workflow to gather all the information required to generate the software configuration for the FMS.

type Field added in v0.1.9

type Field struct {
	ID  int
	IP  string
	MAC string

	Channel string
}

Field contains the information related to each field.

type GSSConfig added in v0.1.9

type GSSConfig struct {
	Team     int
	NetSSID  string
	NetPSK   string
	ServerIP string
	FieldIP  string
}

GSSConfig holds a number of settings that are unique to each driver station and gizmo pair.

func Load

func Load(path string) (*GSSConfig, error)

Load reads in a config from the path on disk.

type GSSServer added in v0.1.9

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

GSSServer is a binding of the related functions that make up the configuration interface for the Gizmo itself.

func NewGSSServer added in v0.1.9

func NewGSSServer(opts ...Option) *GSSServer

NewGSSServer returns the server instance with the options set

func (*GSSServer) Serve added in v0.1.9

func (s *GSSServer) Serve() error

Serve sits and serves forever until shutdown is called.

type GizmoMeta added in v0.1.4

type GizmoMeta struct {
	HardwareVersion string
	FirmwareVersion string
}

GizmoMeta stores information reported by the Gizmo metadata feed.

func (GizmoMeta) FWVersionOK added in v0.1.9

func (g GizmoMeta) FWVersionOK(fList string) bool

FWVersionOK checks if the firmware version is in the list of known firmware versions.

func (GizmoMeta) HWVersionOK added in v0.1.9

func (g GizmoMeta) HWVersionOK(hList string) bool

HWVersionOK checks if the hardware version is in the list of known hardware versions.

type Integration added in v0.1.9

type Integration int

Integration is an enum type for things that can talk to the Gizmo FMS that may need to be switched on or off.

const (
	// IntegrationPCSM provides API endpoints for the BEST
	// Robotics PCSM to control the match mapping.
	IntegrationPCSM Integration = iota
)

type IntegrationSlice added in v0.1.9

type IntegrationSlice []Integration

IntegrationSlice is used to shadow []int to construct some methods that work on the various integrations.

func IntegrationsFromStrings added in v0.1.9

func IntegrationsFromStrings(s []string) IntegrationSlice

IntegrationsFromStrings parses a list of strings and returns the corresponding integrations.

func (IntegrationSlice) Enabled added in v0.1.9

func (is IntegrationSlice) Enabled(t Integration) bool

Enabled tests to see if a given integration is enabled or not.

func (IntegrationSlice) ToStrings added in v0.1.9

func (is IntegrationSlice) ToStrings() []string

ToStrings converts integrations into a slice of strings.

type Option

type Option func(*GSSServer)

Option configures the server

func WithLogger

func WithLogger(l hclog.Logger) Option

WithLogger sets the logging instance for this config server.

func WithOneshotMode added in v0.1.4

func WithOneshotMode() Option

WithOneshotMode instructs the configserver to exit after a single provisioning cycle.

func WithProvider

func WithProvider(p Provider) Option

WithProvider sets up the config provider that will be used by this server.

type Provider

type Provider func(team int) GSSConfig

Provider hands back the configuration for a given Gizmo. This can either be automatic, or with manual intervention, this WILL stall the config server if it calls other resources!

type Team added in v0.1.9

type Team struct {
	Name     string
	Number   int
	SSID     string
	PSK      string
	VLAN     int
	CIDR     string
	GizmoMAC string
	DSMAC    string
}

Team maintains information about a team from the perspective of the FMS

Jump to

Keyboard shortcuts

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