Speak protocol 3.0 and fall back to 2.0 only when that is the reflector's maximum.

A reflector that has moved to 3.0 will not accept a station that always announces 2.0, and a 2.x reflector still needs one explicit plaintext session.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-07 14:24:00 +02:00
co-authored by Cursor
parent 0930d4b727
commit 3d1a2a1669
24 changed files with 3180 additions and 244 deletions
+22
View File
@@ -2,9 +2,11 @@ package station_test
import (
"context"
"errors"
"net"
"os"
"strconv"
"syscall"
"testing"
"time"
@@ -30,6 +32,9 @@ func TestConnectsToLabReflector(t *testing.T) {
t.Skipf("lab reflector not listening on %s: %v", addr, err)
}
conn.Close()
if !labUDPReachable() {
t.Skipf("lab UDP port %s is not reachable", addr)
}
path := writeConfigFile(t, configJSON(t, labHost, labPort, labCallsign, labAuthKey, labTalkGroup))
st, err := station.New(station.Options{ConfigPath: path})
@@ -54,3 +59,20 @@ func TestConnectsToLabReflector(t *testing.T) {
t.Fatalf("talkGroup = %d, want %d", state.TalkGroup, labTalkGroup)
}
}
func labUDPReachable() bool {
peer := &net.UDPAddr{IP: net.ParseIP(labHost), Port: labPort}
conn, err := net.DialUDP("udp", nil, peer)
if err != nil {
return false
}
defer conn.Close()
_, _ = conn.Write([]byte{0})
_ = conn.SetReadDeadline(time.Now().Add(200 * time.Millisecond))
_, err = conn.Read(make([]byte, 1))
if err == nil {
return true
}
var op *net.OpError
return !errors.As(err, &op) || !errors.Is(op.Err, syscall.ECONNREFUSED)
}