mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
修复内存数据更新
This commit is contained in:
parent
a8e02fc9bb
commit
af146872fe
2
go.mod
2
go.mod
@ -22,5 +22,7 @@ require (
|
||||
github.com/spf13/viper v1.6.1
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 // indirect
|
||||
google.golang.org/grpc v1.25.1
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc // indirect
|
||||
)
|
||||
|
@ -10,8 +10,8 @@ type Server struct {
|
||||
Name string
|
||||
Secret string
|
||||
|
||||
Host Host
|
||||
State State
|
||||
Host *Host
|
||||
State *State
|
||||
|
||||
Stream pb.NezhaService_HeartbeatServer `gorm:"-" json:"-"`
|
||||
StreamClose chan<- error `gorm:"-" json:"-"`
|
||||
|
@ -21,9 +21,10 @@ func (s *NezhaHandler) ReportState(c context.Context, r *pb.State) (*pb.Receipt,
|
||||
if clientID, err = s.Auth.Check(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
state := model.PB2State(r)
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
dao.ServerList[clientID].State = model.PB2State(r)
|
||||
dao.ServerList[clientID].State = &state
|
||||
return &pb.Receipt{Proced: true}, nil
|
||||
}
|
||||
|
||||
@ -61,8 +62,9 @@ func (s *NezhaHandler) Register(c context.Context, r *pb.Host) (*pb.Receipt, err
|
||||
if clientID, err = s.Auth.Check(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
host := model.PB2Host(r)
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
dao.ServerList[clientID].Host = model.PB2Host(r)
|
||||
dao.ServerList[clientID].Host = &host
|
||||
return &pb.Receipt{Proced: true}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user