Append an optional station log and announce the software after login.

A log path that cannot be written leaves the station on the reflector, and the reflector learns which program joined.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Konrad Neitzel
2026-10-03 19:24:00 +02:00
co-authored by Cursor
parent 6233292931
commit ec5f660fdd
12 changed files with 848 additions and 43 deletions
+24 -4
View File
@@ -5,6 +5,7 @@ package station
import (
"context"
"net"
"os"
"sync"
"time"
@@ -48,6 +49,16 @@ type Station struct {
lastUDPSend time.Time
enc *opus.Encoder
dec *opus.Decoder
logFile *os.File
logPath string
logNotice string
up bool
outage bool
sending bool
sendStart time.Time
talkCall string
talkStart time.Time
}
// New loads the config at opt.ConfigPath. A missing file is created mode 0600
@@ -61,17 +72,26 @@ func New(opt Options) (*Station, error) {
if clock == nil {
clock = wallClock{}
}
detail := "Idle"
if cfg.logNotice != "" {
detail = cfg.logNotice
}
s := &Station{
cfg: cfg,
clock: clock,
wake: make(chan struct{}, 1),
cfg: cfg,
clock: clock,
wake: make(chan struct{}, 1),
logPath: cfg.logPath,
logNotice: cfg.logNotice,
state: State{
Connection: "Disconnected",
Detail: "Idle",
Detail: detail,
Callsign: cfg.callsign,
TalkGroup: cfg.talkGroup,
},
}
if cfg.enableLogging {
s.openLog()
}
return s, nil
}