Documentation
¶
Overview ¶
Package config holds hamstack's own settings and paths.
Index ¶
- Constants
- Variables
- func BindHost(mode string, lan []string) string
- func Data2GPorts(r Rig) (command, data, kiss, web int)
- func Dir() (string, error)
- func DirewolfPorts(r Rig) (agw, kiss int)
- func IsHFModem(m string) bool
- func MercuryPorts(r Rig) (arq, data, broadcast, ui int)
- func NormalizeBands(in []string) ([]string, error)
- func NormalizeCallsign(s string) string
- func NormalizeGrid(s string) string
- func ParseAccess(s string) (string, error)
- func Save(c Config) error
- func ValidCallsign(s string) bool
- func ValidGrid(s string) bool
- func ValidID(s string) bool
- type AX25
- type Config
- func (c Config) ActiveRigs() []Rig
- func (c Config) ActiveStation() (Station, bool)
- func (c *Config) AddRig(r Rig) error
- func (c *Config) AddSite(s Site) error
- func (c *Config) AddStation(s Station) error
- func (c Config) Components() []string
- func (c Config) EffectiveGrid() string
- func (c Config) Find(id string) (Station, bool)
- func (c Config) GPSAddr() string
- func (c Config) Has(kind string) bool
- func (c Config) Here() (Site, bool)
- func (c Config) NeedsRadio() bool
- func (c Config) NeedsStation() bool
- func (c Config) NetworkAccess(target, fallback string) string
- func (c Config) NextAddr() string
- func (c Config) PatEnabled() bool
- func (c Config) PatHFRig() (Rig, bool)
- func (c Config) PatPacketRig() (Rig, bool)
- func (c *Config) RemoveGPS()
- func (c *Config) RemoveRig(id string) error
- func (c *Config) RemoveSite(id string) error
- func (c *Config) RemoveStation(id string) error
- func (c *Config) RigByID(id string) (*Rig, bool)
- func (c Config) RigByIDValue(id string) (Rig, bool)
- func (c Config) RunsGPSD() bool
- func (c Config) RunsWeb() bool
- func (c Config) ScoreSites(identify func(Rig) (known, present bool)) []SiteScore
- func (c *Config) Set(key, value string) error
- func (c *Config) SetAccess(id, access string) error
- func (c *Config) SetGPS(g GPS) error
- func (c *Config) SetGrid(g string) (where string)
- func (c *Config) SetNetworkAccess(target, mode string) error
- func (c *Config) SetSiteField(id, key, value string) error
- func (c *Config) SetWeb(w WebSettings) error
- func (c Config) SiteByID(id string) (Site, bool)
- func (c *Config) SyncSite()
- func (c *Config) Use(id string) error
- func (c *Config) UseSite(id string) error
- type GPS
- type PacketOpts
- type Rig
- type Site
- type SiteScore
- type Station
- type WebSettings
Constants ¶
const ( RigCtld = "rigctld" // rig control (hamlib): one per rig Mercury = "mercury" // HF modem: one per rig that uses it Direwolf = "direwolf" // VHF/UHF packet soundcard TNC: one per rig that uses it Data2G = "data2g" // HF data modem (VARA-compatible interface), an alternative to Mercury: one per rig that uses it Pat = "pat" // Winlink client: one, shared by all rigs GPSD = "gpsd" // GPS daemon: one, shared by every program that wants a position )
The kinds of service hamstack runs.
const ( RigPortBase = 4532 ArqPortBase = 8300 ArqPortStep = 10 )
Ports. Each rig gets its own so several can run at once: rig control counts up from 4532, and a rig's Mercury modem uses a block of ten from 8300 (ARQ control, data, broadcast and web UI are derived from it, see MercuryPorts).
const ( AccessLocal = "local" // this computer only (127.0.0.1) AccessNetwork = "network" // this computer's LAN address: reachable from the network, not through loopback AccessAll = "all" // every interface (0.0.0.0): the LAN address and loopback )
Who can reach a web UI.
const ( Web = "web" // the dashboard: one HTTPS server VNC = "vnc" // one desktop app on a virtual display, on demand: vnc@APP Desktop = "desktop" // the computer's own desktop, shared to the dashboard, on demand )
The kinds of service that make up the web dashboard.
const Data2GWebPortBase = 8400
Data2GWebPortBase is Data2G's own default web UI port; a rig's is this plus its index.
const GPSPort = 2948
GPSPort is the port of the gpsd hamstack runs. It is not gpsd's standard 2947, so a system-wide gpsd (often already running on a machine that has a GPS) cannot clash with it.
const WebPort = 443
WebPort is the dashboard's default port.
Variables ¶
var Bauds = []int{300, 1200, 2400, 4800, 9600}
Bauds are the modem speeds hamstack offers.
Functions ¶
func BindHost ¶ added in v0.2.0
BindHost resolves a network preference using the current addresses. Without a LAN address it fails closed to loopback, rather than exposing the app on all interfaces.
func Data2GPorts ¶ added in v0.2.0
Data2GPorts returns the ports of a rig's Data2G modem, derived from ArqPort like Mercury's so the two are interchangeable on a rig and rigs never collide: the VARA-style command port (Pat connects here; the data port is the next one), the KISS port and the web UI.
func DirewolfPorts ¶
DirewolfPorts returns the AGW and KISS ports of a rig's Direwolf, derived like Mercury's so rigs never collide. The first rig gets Direwolf's own defaults, 8000 and 8001.
func IsHFModem ¶ added in v0.2.0
IsHFModem reports whether a modem kind is one Pat can use as its VARA HF connection.
func MercuryPorts ¶
MercuryPorts returns the ports of a rig's Mercury modem, all derived from ArqPort so they never collide between rigs: ARQ control, ARQ data, broadcast and the web UI.
func NormalizeBands ¶
NormalizeBands lower-cases, de-duplicates and validates a band list.
func NormalizeCallsign ¶
NormalizeCallsign upper-cases and trims s.
func NormalizeGrid ¶
NormalizeGrid writes a locator in the conventional case: the first pair upper case and the sub-square lower case (FN31pr).
func ParseAccess ¶ added in v0.2.0
ParseAccess reads an access word. It accepts the three names and a few obvious synonyms.
func ValidCallsign ¶
ValidCallsign reports whether s looks like an amateur callsign (optionally with -SSID).
Types ¶
type AX25 ¶
type AX25 struct {
Rig string `json:"rig"` // the rig whose Direwolf is attached
Port string `json:"port"` // the name in /etc/ax25/axports
// The port's settings; zero means the default (the station's callsign, the rig's Direwolf speed, 255, 2).
Call string `json:"call,omitempty"`
Speed int `json:"speed,omitempty"`
Paclen int `json:"paclen,omitempty"`
Window int `json:"window,omitempty"`
}
AX25 says which rig offers its Direwolf to the Linux kernel's AX.25 stack, and under which axports name. That Direwolf is started with -p, which makes it offer a KISS pseudo-terminal that kissattach attaches to.
type Config ¶
type Config struct {
Network map[string]string `json:"network_access,omitempty"`
Rigs []Rig `json:"rigs,omitempty"` // the radios; see Rig
NoPat bool `json:"no_pat,omitempty"` // Pat is part of the setup unless this is set
UI bool `json:"ui"` // Mercury web UI (listens on all interfaces, no auth)
Active string `json:"active"` // id of the active station
Grid string `json:"grid"` // operator's Maidenhead grid square, reused by every program that wants a locator
Stations []Station `json:"stations"`
Sites []Site `json:"sites,omitempty"` // named places; see Site
GPS *GPS `json:"gps,omitempty"` // the position source (gpsd); see GPS
AX25 *AX25 `json:"ax25,omitempty"` // Direwolf offered to the kernel's AX.25 stack; see AX25
Web *WebSettings `json:"web,omitempty"` // the browser dashboard; see WebSettings
CurrentSite string `json:"site,omitempty"` // the site in use
// Read only to upgrade configs from before rigs existed (see migrate); never written back.
LegacyProfile string `json:"profile,omitempty"`
Chosen []string `json:"components,omitempty"`
}
Config is the user's hamstack configuration.
func (Config) ActiveRigs ¶
ActiveRigs are the rigs that are not switched off.
func (Config) ActiveStation ¶
ActiveStation returns the active station, if any.
func (*Config) AddSite ¶
AddSite validates and adds a site. The first one added becomes the current site.
func (*Config) AddStation ¶
AddStation validates and adds a station. The first one added becomes active.
func (Config) Components ¶
Components lists the kinds of service in use, in start order.
func (Config) EffectiveGrid ¶
EffectiveGrid is the grid square that applies now: the current site's, else the default.
func (Config) GPSAddr ¶
GPSAddr is where programs reach gpsd: the configured external gpsd, or hamstack's own on this machine. It is empty when no GPS is set up.
func (Config) NeedsRadio ¶
NeedsRadio reports whether any rig is in use.
func (Config) NeedsStation ¶
NeedsStation reports whether the setup needs a callsign (Pat, or a modem that identifies itself).
func (Config) NetworkAccess ¶ added in v0.2.0
NetworkAccess returns the current site's override, then the machine default.
func (Config) NextAddr ¶
NextAddr returns a localhost address on the lowest port from 8080 that no station uses.
func (Config) PatEnabled ¶
PatEnabled reports whether Pat is part of the setup.
func (Config) PatHFRig ¶
PatHFRig is the rig Pat's HF modem connection uses: the first active rig with an HF modem (Mercury or Data2G, which speak the same interface). Pat has a single HF modem setting, so with several HF rigs this one is wired to Pat.
func (Config) PatPacketRig ¶
PatPacketRig is the rig Pat's packet (AX.25) connections use: the first active rig with Direwolf. Pat has a single AX.25 setting, so with several Direwolf rigs this one is wired to Pat.
func (*Config) RemoveSite ¶
RemoveSite deletes a site. Rigs, stations and the grid are left as they are.
func (*Config) RemoveStation ¶
RemoveStation removes a station; if it was active, the first remaining one becomes active.
func (Config) RigByIDValue ¶
RigByIDValue is RigByID returning a copy.
func (Config) RunsGPSD ¶
RunsGPSD reports whether hamstack runs a gpsd service: a receiver is set up, not switched off, and not provided by a gpsd elsewhere.
func (Config) ScoreSites ¶
ScoreSites compares each site's rigs with what is plugged in. identify reports, for a rig, whether its hardware can be recognised at all and whether it is present; rigs that cannot be recognised (the dummy rig) take no part, so they never make a site look absent.
func (*Config) SetGrid ¶
SetGrid sets the grid square for where you are: the current site's, or the default when there is no current site. It says which it changed.
func (*Config) SetNetworkAccess ¶ added in v0.2.0
func (*Config) SetSiteField ¶
SetSiteField changes one field of a site: name, rigs, station or grid.
func (*Config) SetWeb ¶ added in v0.2.0
func (c *Config) SetWeb(w WebSettings) error
SetWeb validates and saves the dashboard settings.
type GPS ¶
type GPS struct {
Device string `json:"device,omitempty"` // exact receiver device (a /dev/serial/by-id path)
USB string `json:"usb,omitempty"` // USB identity (vid:pid:serial) of the receiver, to find it again after a replug
Addr string `json:"addr,omitempty"` // "host:port" of an existing gpsd; hamstack then runs none
Port int `json:"port,omitempty"` // port of the gpsd hamstack runs (default GPSPort)
Off bool `json:"off,omitempty"` // kept in the config but not run
}
GPS is the position source: a gpsd daemon. Either hamstack runs gpsd itself for a receiver plugged into this machine (Device and USB say which one), or it uses a gpsd that already runs somewhere (Addr).
func (GPS) ListenPort ¶
ListenPort is the port hamstack's gpsd listens on.
type PacketOpts ¶
type PacketOpts struct {
Baud int `json:"baud,omitempty"` // modem speed: 300 (HF), 1200 (VHF packet and APRS, the default), 2400, 4800, 9600
Call string `json:"call,omitempty"` // the callsign (with SSID) to use instead of the station's
TxDelay int `json:"txdelay,omitempty"` // key-up delay in 10 ms units (Direwolf's default is 30)
TxTail int `json:"txtail,omitempty"` // hold-after delay in 10 ms units (default 10)
Persist int `json:"persist,omitempty"` // CSMA persistence 0-255 (default 63)
SlotTime int `json:"slottime,omitempty"` // CSMA slot time in 10 ms units (default 10)
Digipeat bool `json:"digipeat,omitempty"` // repeat other stations' WIDEn-N packets (a transmitting service: see the notice)
}
PacketOpts are the settings of a rig's Direwolf that people change. Zero means "leave it to Direwolf's default", so a rig that never touched them gets exactly the configuration it always had.
func (PacketOpts) ModemBaud ¶
func (o PacketOpts) ModemBaud() int
ModemBaud is the speed to run: 1200 unless set.
type Rig ¶
type Rig struct {
ID string `json:"id"` // short name used on the command line and in unit names
Name string `json:"name,omitempty"`
Profile string `json:"profile"` // radio model: hamlib model, baud, USB ids
CAT string `json:"cat,omitempty"` // exact CAT device (a /dev/serial/by-id path); empty = find it via the profile
CATID string `json:"cat_id,omitempty"` // USB identity (vid:pid:serial) of the CAT device
Audio string `json:"audio,omitempty"` // ALSA card id of its sound card
AudioUSB string `json:"audio_usb,omitempty"` // USB identity of the sound card, to find it again if card numbers change
Modem string `json:"modem,omitempty"` // "", "mercury" or "data2g" (HF), or "direwolf" (VHF/UHF packet)
NoCAT bool `json:"no_cat,omitempty"` // the radio has no CAT control (its profile has no hamlib model): no rigctld
Bands []string `json:"bands,omitempty"` // hf, vhf, uhf
RigPort int `json:"rig_port"` // its rigctld port
ArqPort int `json:"arq_port,omitempty"` // base of its Mercury ports
Off bool `json:"off,omitempty"` // kept in the config but not run (not at this site, or unplugged)
Packet PacketOpts `json:"packet,omitzero"` // Direwolf's settings for this rig; zero values mean Direwolf's own defaults
}
Rig is one physical radio and how it is wired up. A rig is identified by its own name, not by the model, so two radios of the same model are two rigs.
type Site ¶
type Site struct {
Network map[string]string `json:"network_access,omitempty"`
ID string `json:"id"`
Name string `json:"name,omitempty"`
Rigs []string `json:"rigs"` // ids of the rigs that are on at this site; the rest are switched off
Station string `json:"station,omitempty"` // the active station here ("" leaves it as it is)
Grid string `json:"grid,omitempty"` // the grid square here ("" uses the default grid)
}
Site is a named place you operate from (home, the EOC, the club). It records which of your rigs are there, which station is active, and the grid square, so moving between places is one command.
type SiteScore ¶
type SiteScore struct {
Site Site
Known int // rigs whose hardware can be recognised (a saved USB device, or a profile with a pattern)
Present int // of those, how many are plugged in now
Missing []string // ids of the ones that are not
}
SiteScore says how many of a site's identifiable radios are plugged in.
type Station ¶
type Station struct {
ID string `json:"id"` // short name used on the command line
Name string `json:"name"` // optional label, e.g. "Club"
Callsign string `json:"callsign"` // may include an -SSID
PatConfig string `json:"pat_config"` // path of this station's Pat config file
HTTPAddr string `json:"http_addr"` // Pat web UI listen address, e.g. localhost:8081
// Access is who may reach the web UI: AccessLocal, AccessNetwork or AccessAll. Empty means the
// host in HTTPAddr is used as it is (stations from before this setting, or a custom address).
Access string `json:"access,omitempty"`
}
Station is one operating identity: a callsign with its own Pat config and web UI address. Examples: a personal call, a club call, an emergency-communications call.
func (Station) EffectiveAccess ¶ added in v0.2.0
EffectiveAccess is the station's access, worked out from HTTPAddr when Access is not set. It is empty for a custom address that is none of the three.
func (Station) ListenAddr ¶ added in v0.2.0
ListenAddr is the address Pat's web UI should listen on. lan holds this computer's LAN addresses, which "network" needs; with none, it falls back to localhost and ok is false so the caller can warn.
type WebSettings ¶ added in v0.2.0
type WebSettings struct {
Console bool `json:"console,omitempty"` // opt-in authenticated browser terminal with this user's full permissions
Access string `json:"access,omitempty"`
Port int `json:"port,omitempty"` // 0 means WebPort
Cert string `json:"cert,omitempty"` // TLS certificate (PEM, may hold the chain); empty: a self-signed one hamstack makes
Key string `json:"key,omitempty"` // its private key
Off bool `json:"off,omitempty"` // kept in the config but not run
}
WebSettings is the browser dashboard: service status and controls, links to the web UIs, and desktop apps (JS8Call, WSJT-X...) or the whole desktop in the browser through noVNC.
func (WebSettings) EffectiveAccess ¶ added in v0.2.0
func (w WebSettings) EffectiveAccess() string
EffectiveAccess preserves pre-access-setting dashboards, which listened on all interfaces.
func (WebSettings) ListenPort ¶ added in v0.2.0
func (w WebSettings) ListenPort() int
ListenPort is the dashboard's port.