app

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 49 Imported by: 0

Documentation

Overview

Package app implements the core functionality shared by cli and api.

Index

Constants

View Source
const (
	MethodArdop  = "ardop"
	MethodTelnet = "telnet"
	MethodPactor = "pactor"
	MethodVaraHF = "varahf"
	MethodVaraFM = "varafm"

	MethodAX25          = "ax25"
	MethodAX25AGWPE     = MethodAX25 + "+agwpe"
	MethodAX25Linux     = MethodAX25 + "+linux"
	MethodAX25SerialTNC = MethodAX25 + "+serial-tnc"

	// TODO: Remove after some release cycles (2023-05-21)
	MethodSerialTNCDeprecated = "serial-tnc"
)
View Source
const (
	PromptKindBusyChannel          = types.PromptKindBusyChannel
	PromptKindMultiSelect          = types.PromptKindMultiSelect
	PromptKindPassword             = types.PromptKindPassword
	PromptKindPreAccountActivation = types.PromptKindPreAccountActivation
	PromptKindAccountActivation    = types.PromptKindAccountActivation
)

Variables

View Source
var ErrNoCmd = fmt.Errorf("no cmd")
View Source
var ErrRateLimited error = errors.New("call was rate-limited")

Functions

func AddAttachment

func AddAttachment(msg *fbb.Message, filename string, contentType string, r io.Reader) error

func DoIfElapsed

func DoIfElapsed(callsign, name string, t time.Duration, fn func() error) error

DoIfElapsed implements a per-callsign rate limited function.

func LoadConfig

func LoadConfig(cfgPath string, fallback cfg.Config) (config cfg.Config, err error)

func ReadConfig

func ReadConfig(path string) (config cfg.Config, err error)

func SetFreq

func SetFreq(rig hamlib.VFO, freq string) (newFreq, oldFreq int, err error)

func SplitFunc

func SplitFunc(c rune) bool

func WriteConfig

func WriteConfig(config cfg.Config, filePath string) error

Types

type ARDOPListener

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

func (*ARDOPListener) BeaconStart

func (l *ARDOPListener) BeaconStart() error

func (ARDOPListener) BeaconStop

func (l ARDOPListener) BeaconStop()

func (ARDOPListener) CurrentFreq

func (l ARDOPListener) CurrentFreq() (Frequency, bool)

func (ARDOPListener) Init

func (l ARDOPListener) Init() (net.Listener, error)

func (ARDOPListener) Name

func (l ARDOPListener) Name() string

type AX25AGWPEListener

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

func (*AX25AGWPEListener) BeaconStart

func (l *AX25AGWPEListener) BeaconStart() error

func (AX25AGWPEListener) BeaconStop

func (l AX25AGWPEListener) BeaconStop()

func (*AX25AGWPEListener) CurrentFreq

func (l *AX25AGWPEListener) CurrentFreq() (Frequency, bool)

func (*AX25AGWPEListener) Init

func (l *AX25AGWPEListener) Init() (net.Listener, error)

func (*AX25AGWPEListener) Name

func (l *AX25AGWPEListener) Name() string

type AX25LinuxListener

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

func (*AX25LinuxListener) BeaconStart

func (l *AX25LinuxListener) BeaconStart() error

func (*AX25LinuxListener) BeaconStop

func (l *AX25LinuxListener) BeaconStop()

func (*AX25LinuxListener) CurrentFreq

func (l *AX25LinuxListener) CurrentFreq() (Frequency, bool)

func (*AX25LinuxListener) Init

func (l *AX25LinuxListener) Init() (net.Listener, error)

func (*AX25LinuxListener) Name

func (l *AX25LinuxListener) Name() string

type App

type App struct {
	OnReload func() error
	// contains filtered or unexported fields
}

func New

func New(opts Options) *App

func (*App) AGWPE

func (a *App) AGWPE() (*agwpe.TNCPort, error)

AGWPE returns the initialized AGWPE TNC, initializing it if necessary.

func (*App) ARDOP

func (a *App) ARDOP() (*ardop.TNC, error)

ARDOP returns the initialized ARDOP modem, initializing it if necessary.

func (*App) AbortActiveConnection

func (a *App) AbortActiveConnection(dirty bool) (ok bool)

func (*App) ActiveListeners

func (a *App) ActiveListeners() []string

func (*App) Close

func (a *App) Close()

func (*App) Config

func (a *App) Config() cfg.Config

func (*App) Connect

func (a *App) Connect(connectStr string) (success bool)

func (*App) EnableWebSocket

func (a *App) EnableWebSocket(ctx context.Context, wsHub WSHub) error

func (*App) Env

func (a *App) Env() []string

func (*App) FormsManager

func (a *App) FormsManager() *forms.Manager

func (*App) GetStatus

func (a *App) GetStatus() types.Status

func (*App) Heard

func (a *App) Heard() map[string][]Heard

func (*App) Listen

func (a *App) Listen(listenStr string)

func (*App) Locator added in v0.19.0

func (a *App) Locator() string

Locator implements forms.LocatorProvider

func (*App) Mailbox

func (a *App) Mailbox() *mailbox.DirHandler

func (*App) Options

func (a *App) Options() Options

func (*App) PromptHub

func (a *App) PromptHub() *PromptHub

func (*App) ReadRMSList

func (a *App) ReadRMSList(ctx context.Context, forceDownload bool, filterFn func(rms RMS) (keep bool)) ([]RMS, error)

func (*App) Reload

func (a *App) Reload() error

func (*App) Run

func (a *App) Run(ctx context.Context, cmd Command, args []string)

func (*App) SetConnectAliases added in v0.19.0

func (a *App) SetConnectAliases(aliases map[string]string) error

func (*App) Unlisten

func (a *App) Unlisten(param string)

func (*App) VARAFM

func (a *App) VARAFM() (*vara.Modem, error)

VARAFM returns the initialized VARA FM modem, initializing it if necessary.

func (*App) VARAHF

func (a *App) VARAHF() (*vara.Modem, error)

VARAHF returns the initialized VARA HF modem, initializing it if necessary.

func (*App) VFOForRig

func (a *App) VFOForRig(rig string) (hamlib.VFO, bool)

func (*App) VFOForTransport

func (a *App) VFOForTransport(transport string) (vfo hamlib.VFO, rigName string, ok bool, err error)

type Band

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

func (Band) Contains

func (b Band) Contains(f Frequency) bool

type Beaconer

type Beaconer interface {
	BeaconStop()
	BeaconStart() error
}

type ByDist

type ByDist []RMS

func (ByDist) Len

func (r ByDist) Len() int

func (ByDist) Less

func (r ByDist) Less(i, j int) bool

func (ByDist) Swap

func (r ByDist) Swap(i, j int)

type ByLinkQuality added in v0.19.0

type ByLinkQuality []RMS

func (ByLinkQuality) Len added in v0.19.0

func (r ByLinkQuality) Len() int

func (ByLinkQuality) Less added in v0.19.0

func (r ByLinkQuality) Less(i, j int) bool

func (ByLinkQuality) Swap added in v0.19.0

func (r ByLinkQuality) Swap(i, j int)

type Command

type Command struct {
	Str        string
	Aliases    []string
	Desc       string
	HandleFunc func(ctx context.Context, app *App, args []string)
	Usage      string
	Options    map[string]string
	Example    string

	LongLived  bool
	MayConnect bool
}

func (Command) PrintUsage

func (cmd Command) PrintUsage()

type EventLogger

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

func NewEventLogger

func NewEventLogger(path string) (*EventLogger, error)

func (*EventLogger) Close

func (l *EventLogger) Close() error

func (*EventLogger) Log

func (l *EventLogger) Log(what string, event map[string]interface{})

func (*EventLogger) LogConn

func (l *EventLogger) LogConn(op string, freq Frequency, conn net.Conn, err error)

type Frequency

type Frequency int // Hz

func (Frequency) Dial

func (f Frequency) Dial(mode string) Frequency

func (Frequency) KHz

func (f Frequency) KHz() float64

func (Frequency) MHz added in v0.19.0

func (f Frequency) MHz() float64

func (Frequency) MarshalJSON

func (f Frequency) MarshalJSON() ([]byte, error)

func (Frequency) String

func (f Frequency) String() string

type Heard

type Heard struct {
	Callsign string    `json:"callsign"`
	Time     time.Time `json:"time"`
}

type JSONFloat64

type JSONFloat64 float64

JSONFloat64 is a float64 which serializes NaN and Inf(+-) as JSON value null

func (JSONFloat64) MarshalJSON

func (f JSONFloat64) MarshalJSON() ([]byte, error)

type JSONURL

type JSONURL struct{ url.URL }

func (JSONURL) MarshalJSON

func (url JSONURL) MarshalJSON() ([]byte, error)

type Listener

type Listener struct {
	*App
	// contains filtered or unexported fields
}

func (*Listener) Close

func (l *Listener) Close() error

func (*Listener) Err

func (l *Listener) Err() error

type ListenerHub

type ListenerHub struct {
	*App
	// contains filtered or unexported fields
}

func NewListenerHub

func NewListenerHub(a *App) *ListenerHub

func (*ListenerHub) Active

func (h *ListenerHub) Active() []TransportListener

func (*ListenerHub) Close

func (h *ListenerHub) Close() error

func (*ListenerHub) Disable

func (h *ListenerHub) Disable(name string) (bool, error)

func (*ListenerHub) Enable

func (h *ListenerHub) Enable(t TransportListener)

func (*ListenerHub) NewListener

func (h *ListenerHub) NewListener(t TransportListener) *Listener

type NotifyMBox

type NotifyMBox struct {
	fbb.MBoxHandler
	*App
}

func (NotifyMBox) GetInboundAnswers

func (m NotifyMBox) GetInboundAnswers(p []fbb.Proposal) []fbb.ProposalAnswer

func (NotifyMBox) ProcessInbound

func (m NotifyMBox) ProcessInbound(msgs ...*fbb.Message) error

type Options

type Options struct {
	IgnoreBusy bool // Move to connect?
	SendOnly   bool // Move to connect?
	RadioOnly  bool

	Robust       bool
	MyCall       string
	Listen       string
	MailboxPath  string
	ConfigPath   string
	PrehooksPath string
	LogPath      string
	EventLogPath string
	FormsPath    string
}

type Prediction added in v0.19.0

type Prediction struct {
	LinkQuality int `json:"link_quality"`

	OutputRaw    string `json:"output_raw"`
	OutputValues any    `json:"output_values"`
}

type Prompt

type Prompt struct {
	types.Prompt
	// contains filtered or unexported fields
}

func (Prompt) Done

func (p Prompt) Done() <-chan struct{}

func (Prompt) Err

func (p Prompt) Err() error

func (Prompt) Respond

func (p Prompt) Respond(val string, err error)

type PromptHub

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

func NewPromptHub

func NewPromptHub() *PromptHub

func (*PromptHub) AddPrompter

func (p *PromptHub) AddPrompter(prompters ...Prompter)

func (*PromptHub) Close

func (p *PromptHub) Close() error

func (*PromptHub) Prompt

func (p *PromptHub) Prompt(ctx context.Context, timeout time.Duration, kind PromptKind, message string, options ...PromptOption) <-chan PromptResponse

func (*PromptHub) Respond

func (p *PromptHub) Respond(id, value string, err error)

type PromptKind

type PromptKind = types.PromptKind

type PromptOption

type PromptOption = types.PromptOption

type PromptResponse

type PromptResponse = types.PromptResponse

type Prompter

type Prompter interface{ Prompt(Prompt) }

type RMS

type RMS struct {
	Callsign   string      `json:"callsign"`
	Gridsquare string      `json:"gridsquare"`
	Distance   JSONFloat64 `json:"distance"`
	Azimuth    JSONFloat64 `json:"azimuth"`
	Modes      string      `json:"modes"`
	Freq       Frequency   `json:"freq"`
	Dial       Frequency   `json:"dial"`
	URL        *JSONURL    `json:"url"`
	Prediction *Prediction `json:"prediction"`
}

func (RMS) IsBand

func (r RMS) IsBand(band string) bool

func (RMS) IsMode

func (r RMS) IsMode(mode string) bool

type RemoteCaller

type RemoteCaller interface {
	RemoteCall() string
}

type StatusUpdate

type StatusUpdate struct{ WSHub }

func (StatusUpdate) UpdateStatus

func (s StatusUpdate) UpdateStatus(stat fbb.Status)

type TelnetListener

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

func (TelnetListener) CurrentFreq

func (l TelnetListener) CurrentFreq() (Frequency, bool)

func (TelnetListener) Init

func (l TelnetListener) Init() (net.Listener, error)

func (TelnetListener) Name

func (l TelnetListener) Name() string

type TransportListener

type TransportListener interface {
	Init() (net.Listener, error)
	Name() string
	CurrentFreq() (Frequency, bool)
}

type VaraFMListener

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

func (VaraFMListener) CurrentFreq

func (l VaraFMListener) CurrentFreq() (Frequency, bool)

func (VaraFMListener) Init

func (l VaraFMListener) Init() (net.Listener, error)

func (VaraFMListener) Name

func (l VaraFMListener) Name() string

type VaraHFListener

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

func (VaraHFListener) CurrentFreq

func (l VaraHFListener) CurrentFreq() (Frequency, bool)

func (VaraHFListener) Init

func (l VaraHFListener) Init() (net.Listener, error)

func (VaraHFListener) Name

func (l VaraHFListener) Name() string

type WSHub

type WSHub interface {
	UpdateStatus()
	WriteProgress(types.Progress)
	WriteNotification(types.Notification)
	Prompt(Prompt)
	NumClients() int
	ClientAddrs() []string
	Close() error
}

Jump to

Keyboard shortcuts

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