Fix live status on CS2: accept RCON output tagged with the end packet's id

CS2 tags a command's output with the id of the empty end packet when both
arrive together, and replies to the end packet with a bare \x00\x01. The
client dropped the output as stale, so the panel reported WebPanelBridge as
missing. Also log each new kind of poll failure once, and recovery.
This commit is contained in:
Astra 2026-09-25 21:27:10 +01:00
parent 4f38daf0e6
commit 10694c69bc
3 changed files with 63 additions and 15 deletions

View file

@ -151,14 +151,23 @@ func (p *Poller) Refresh() Status {
st.Updated = time.Now()
if err != nil {
st = Status{Error: err.Error(), Updated: st.Updated}
// Log each new kind of failure once, so a wrong password or missing plugin shows up in the
// log without repeating every few seconds. ErrDown only repeats the previous failure.
p.mu.RLock()
was := p.current.Online || p.current.Updated.IsZero()
changed := p.current.Online || p.current.Updated.IsZero() || p.current.Error != st.Error
p.mu.RUnlock()
if was && !errors.Is(err, rcon.ErrDown) {
if changed && !errors.Is(err, rcon.ErrDown) {
slog.Warn("game server status unavailable", "err", err)
}
}
p.mu.Lock()
if st.Online && !p.current.Online && !p.current.Updated.IsZero() {
slog.Info("game server status available again")
}
// While backing off, keep the underlying error rather than "retrying shortly".
if errors.Is(err, rcon.ErrDown) && p.current.Error != "" {
st.Error = p.current.Error
}
p.current = st
p.mu.Unlock()
return st