fix: bug where some clusters would not show any spots
This commit is contained in:
@@ -18,6 +18,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"hamlog/internal/applog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerConfig is the persisted shape of one cluster node. Mirrors the
|
// ServerConfig is the persisted shape of one cluster node. Mirrors the
|
||||||
@@ -106,6 +108,7 @@ type session struct {
|
|||||||
doneCh chan struct{}
|
doneCh chan struct{}
|
||||||
stopped bool // guards against double-stop on the same session
|
stopped bool // guards against double-stop on the same session
|
||||||
spotsCnt int
|
spotsCnt int
|
||||||
|
dbgN int // diagnostic: how many raw lines logged this connection
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manager owns N sessions, one per enabled server. Safe for concurrent
|
// Manager owns N sessions, one per enabled server. Safe for concurrent
|
||||||
@@ -392,10 +395,31 @@ func (s *session) runOnce() (time.Time, error) {
|
|||||||
return connectedAt, fmt.Errorf("read: %w", err)
|
return connectedAt, fmt.Errorf("read: %w", err)
|
||||||
}
|
}
|
||||||
line = strings.TrimRight(line, "\r\n")
|
line = strings.TrimRight(line, "\r\n")
|
||||||
|
// Strip terminal BELLs (\a) and other control bytes that some nodes
|
||||||
|
// (e.g. F5LEN) append to spot lines — "DX de …0935Z KN04\a\a" — which
|
||||||
|
// would otherwise break the parser's end-of-line anchor. Tabs → spaces.
|
||||||
|
line = strings.Map(func(r rune) rune {
|
||||||
|
if r == '\t' {
|
||||||
|
return ' '
|
||||||
|
}
|
||||||
|
if r < 0x20 || r == 0x7f {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}, line)
|
||||||
if line == "" {
|
if line == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safety net: warn (rate-limited) about DX lines the parser still can't
|
||||||
|
// read, so a future format drift is visible in the log.
|
||||||
|
if strings.Contains(line, "DX de") && s.dbgN < 10 {
|
||||||
|
if _, ok := parseSpot(line); !ok {
|
||||||
|
s.dbgN++
|
||||||
|
applog.Printf("cluster[%s] UNPARSED spot: %q", s.cfg.Name, line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Login on explicit prompt.
|
// Login on explicit prompt.
|
||||||
if !loginSent && s.login != "" && isLoginPrompt(line) {
|
if !loginSent && s.login != "" && isLoginPrompt(line) {
|
||||||
_, _ = conn.Write([]byte(s.login + "\r\n"))
|
_, _ = conn.Write([]byte(s.login + "\r\n"))
|
||||||
|
|||||||
Reference in New Issue
Block a user