Let the config choose protocol 2 or 3, and fall back for one session only.

The default stays v2. A reflector that refuses that version and names the other gets one session of it, then the station announces the configured protocol again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-22 16:28:42 +02:00
co-authored by Cursor
parent 3533b97d00
commit 2c621d4b7f
21 changed files with 361 additions and 82 deletions
+10 -2
View File
@@ -139,7 +139,8 @@ func (s *Station) applyLogging(prev, next loaded) {
func connectionChanged(prev, next loaded) bool {
return prev.host != next.host || prev.port != next.port || prev.callsign != next.callsign ||
prev.authKey != next.authKey || prev.talkGroup != next.talkGroup || prev.certificateDir != next.certificateDir
prev.authKey != next.authKey || prev.talkGroup != next.talkGroup || prev.protocolMajor != next.protocolMajor ||
prev.certificateDir != next.certificateDir
}
func readForm(path string) (ConfigForm, string, bool) {
@@ -147,7 +148,7 @@ func readForm(path string) (ConfigForm, string, bool) {
if err != nil {
form, ferr := templateForm()
if ferr != nil {
form = ConfigForm{CertificateDir: "./funknetz"}
form = ConfigForm{Protocol: "v2", CertificateDir: "./funknetz"}
}
return form, fmt.Errorf("the file could not be read: %w", err).Error(), false
}
@@ -189,6 +190,7 @@ func validateForm(configPath string, form ConfigForm) (loaded, ConfigForm, error
Callsign: cfg.callsign,
AuthKey: cfg.authKey,
TalkGroup: cfg.talkGroup,
Protocol: protocolName(cfg.protocolMajor),
CertificateDir: strings.TrimSpace(form.CertificateDir),
EnableLogging: form.EnableLogging,
LogFile: form.LogFile,
@@ -217,6 +219,10 @@ func shapeFromForm(form ConfigForm) (fileShape, error) {
if err != nil {
return fileShape{}, err
}
protocol, err := jsonValue(form.Protocol)
if err != nil {
return fileShape{}, err
}
dir, err := jsonValue(form.CertificateDir)
if err != nil {
return fileShape{}, err
@@ -235,6 +241,7 @@ func shapeFromForm(form ConfigForm) (fileShape, error) {
Callsign: call,
AuthKey: key,
TalkGroup: tg,
Protocol: protocol,
CertificateDir: dir,
EnableLogging: en,
LogFile: logFile,
@@ -256,6 +263,7 @@ func writeForm(path string, form ConfigForm) error {
Callsign: form.Callsign,
AuthKey: form.AuthKey,
TalkGroup: form.TalkGroup,
Protocol: form.Protocol,
CertificateDir: form.CertificateDir,
EnableLogging: form.EnableLogging,
LogFile: form.LogFile,