fix: add nil check for ReportSystemState (#583)

This commit is contained in:
UUBulb 2024-12-13 22:27:30 +08:00 committed by GitHub
parent a24f452b65
commit 864cfbb375
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -103,6 +103,12 @@ func (s *NezhaHandler) ReportSystemState(stream pb.NezhaService_ReportSystemStat
state := model.PB2State(state)
singleton.ServerLock.RLock()
if singleton.ServerList[clientID] == nil {
singleton.ServerLock.RUnlock()
return nil
}
singleton.ServerList[clientID].LastActive = time.Now()
singleton.ServerList[clientID].State = &state
// 应对 dashboard 重启的情况,如果从未记录过,先打点,等到小时时间点时入库