🐛 quickfix: nil point

This commit is contained in:
naiba 2021-01-18 13:45:06 +08:00
parent 769b61843e
commit c5379a0092
5 changed files with 5 additions and 6 deletions

View File

@ -205,7 +205,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
## 变更日志
最新:`dashboard 0.2.5` `agent 0.2.5`,只记录最后一次更新导致必须更新面板的说明。
最新:`dashboard 0.2.6` `agent 0.2.5`,只记录最后一次更新导致必须更新面板的说明。
- `dashboard 0.2.0` `agent 0.2.0` **重大更新**

View File

@ -198,8 +198,8 @@ func doTask(task *pb.Task) {
}
case model.MonitorTypeICMPPing:
pinger, err := ping.NewPinger(task.GetData())
pinger.SetPrivileged(true)
if err == nil {
pinger.SetPrivileged(true)
pinger.Count = 10
pinger.Timeout = time.Second * 20
err = pinger.Run() // Blocks until finished.

View File

@ -17,7 +17,7 @@ type Server struct {
Host *Host `gorm:"-"`
State *HostState `gorm:"-"`
LastActive *time.Time `gorm:"-"`
LastActive time.Time `gorm:"-"`
TaskClose chan error `gorm:"-" json:"-"`
TaskStream pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"`

View File

@ -27,7 +27,7 @@ var ServerLock sync.RWMutex
var SortedServerList []*model.Server
var SortedServerLock sync.RWMutex
var Version = "v0.2.5"
var Version = "v0.2.6"
func ReSortServer() {
ServerLock.RLock()

View File

@ -88,8 +88,7 @@ func (s *NezhaHandler) ReportSystemState(c context.Context, r *pb.State) (*pb.Re
state := model.PB2State(r)
dao.ServerLock.RLock()
defer dao.ServerLock.RUnlock()
now := time.Now()
dao.ServerList[clientID].LastActive = &now
dao.ServerList[clientID].LastActive = time.Now()
dao.ServerList[clientID].State = &state
return &pb.Receipt{Proced: true}, nil
}