fix(udp): OpsLog was re-tuning its own rig from its own broadcasts

Reported as JTDX "Fake It" causing CAT disconnections. Fake It is not the
cause — it is what made an existing loop fire, and a regression of mine from
this morning is what closed that loop.

The station has an inbound remote-call row and an outbound N1MM RadioInfo row
on the same port, 2241, so every RadioInfo datagram OpsLog sends arrives
straight back on the loopback. The remote-call parser strips XML tags and takes
the last token as the callsign: for a RadioInfo that is
<ActiveRadioNr>1</ActiveRadioNr>, i.e. "1" — and <Freq> became a tune request
for the frequency the rig was already on.

That was harmless only while <Freq> was misread. It is in tens of Hz, the parser
assumed MHz, every echoed tune failed "out of the 11-digit CAT range", and the
loop died on the error. Teaching it the unit (331db58) closed the loop.

Fake It shifts the dial for each over rather than using split, so every
transmission changed the state twice — and each change published a RadioInfo,
which came back as a set, which changed the state again. The log shows the dial
oscillating 24915000/24915500 three times in 200 ms, then "timeout answering
IF;" and the shared link down. Every over, all morning.

Two guards, because one was not enough to be sure: a RadioInfo payload is never
a remote-call request, and a callsign has a letter in it — so the next program
to broadcast its state on that port cannot drive the rig either. Reload also
names an inbound and an outbound row sharing a port, which is the arrangement
that permitted this and which no settings panel shows.
This commit is contained in:
2026-08-16 12:25:41 +02:00
parent 423cf1f998
commit 9f8e3c73d9
3 changed files with 133 additions and 3 deletions
+55 -1
View File
@@ -423,6 +423,25 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) {
// Strip every angle-bracket tag, normalise whitespace, take the
// last non-empty token. Upper-case for downstream consistency.
text := string(pkt)
// NEVER act on an N1MM RadioInfo datagram.
//
// It is not a spot click, it is a radio TELLING the world where it is —
// and on a station where an inbound remote-call row and an outbound
// RadioInfo row share a port, the one OpsLog just sent arrives straight
// back on the loopback. The tag-stripping below then reads its last token,
// <ActiveRadioNr>1</ActiveRadioNr>, as the callsign "1", and <Freq> as a
// tune request — for the frequency the rig is already on.
//
// That was harmless only for as long as <Freq> was misread: in tens of Hz
// it looks like a wild number, every tune failed "out of the CAT range",
// and the loop died there. Reading the unit correctly closed it. With
// WSJT-X/JTDX "Fake It", which shifts the dial for each over, every
// transmission then produced a burst of sets echoing between OpsLog and
// itself until the rig stopped answering IF; and the shared CAT link
// dropped. Reported as Fake It causing CAT disconnections.
if low := strings.ToLower(text); strings.Contains(low, "<radioinfo") {
return
}
// Optional tune request: <FREQ>MHz and <MODE>str ride along with the
// callsign so a DXHunter spot click can drive OpsLog's CAT. Extract
// (and cut) them BEFORE the generic tag-stripping below, which would
@@ -454,7 +473,16 @@ func (s *Server) handle(pkt []byte, remote *net.UDPAddr) {
if len(parts) == 0 {
return
}
ev.DXCall = strings.ToUpper(parts[len(parts)-1])
call := strings.ToUpper(parts[len(parts)-1])
// A callsign has a letter in it. Without this, any status XML that ends
// in a number is read as a station — the RadioInfo above was exactly
// that, and refusing it by shape as well as by name means the next
// program to broadcast its state on this port cannot drive the rig
// either.
if !strings.ContainsAny(call, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") {
return
}
ev.DXCall = call
case ServiceN1MM:
adifText, ok, err := ParseN1MM(pkt)
if err != nil {
@@ -598,10 +626,36 @@ func (m *Manager) Reload(ctx context.Context) []string {
m.inbound[c.ID] = srv
m.mu.Unlock()
}
warnSharedPorts(cfgs)
applog.Printf("udp: Reload done — %d server(s) running, %d error(s)", len(m.inbound), len(errs))
return errs
}
// warnSharedPorts names an inbound and an outbound row sitting on the same
// port, because that is a loop: what OpsLog sends there, OpsLog receives.
//
// It is how a station ended up re-tuning its own rig from its own RadioInfo
// broadcasts. The parser refuses that particular payload now, but the
// arrangement stays wrong for anything else that lands on the port, and it is
// invisible in a settings panel that shows one row at a time.
func warnSharedPorts(cfgs []Config) {
in := map[int]string{}
for _, c := range cfgs {
if c.Enabled && c.Direction != Outbound {
in[c.Port] = c.Name
}
}
for _, c := range cfgs {
if !c.Enabled || c.Direction != Outbound {
continue
}
if name, ok := in[c.Port]; ok {
applog.Printf("udp: %q sends on port %d and %q listens on it — OpsLog will receive its own messages there; give one of the two another port",
c.Name, c.Port, name)
}
}
}
// Outbound returns the active outbound configs matching a service type.
// Used by the QSO save path to push notifications to listeners.
func (m *Manager) Outbound(service ServiceType) []Config {