2019-12-08 23:18:29 +08:00
|
|
|
package model
|
|
|
|
|
2019-12-10 17:57:57 +08:00
|
|
|
import (
|
2020-12-09 10:27:00 +08:00
|
|
|
"fmt"
|
2020-12-19 22:14:36 +08:00
|
|
|
"html/template"
|
2020-10-24 21:29:05 +08:00
|
|
|
"time"
|
|
|
|
|
2020-11-11 10:07:45 +08:00
|
|
|
pb "github.com/naiba/nezha/proto"
|
2019-12-10 17:57:57 +08:00
|
|
|
)
|
|
|
|
|
2019-12-08 23:18:29 +08:00
|
|
|
// Server ..
|
|
|
|
type Server struct {
|
|
|
|
Common
|
|
|
|
Name string
|
2020-12-07 20:47:13 +08:00
|
|
|
Secret string `json:"-"`
|
2019-12-09 18:14:31 +08:00
|
|
|
|
2020-12-19 23:11:16 +08:00
|
|
|
Host *Host `gorm:"-"`
|
|
|
|
State *State `gorm:"-"`
|
2020-10-24 21:29:05 +08:00
|
|
|
LastActive time.Time
|
2019-12-10 17:57:57 +08:00
|
|
|
|
|
|
|
Stream pb.NezhaService_HeartbeatServer `gorm:"-" json:"-"`
|
|
|
|
StreamClose chan<- error `gorm:"-" json:"-"`
|
2019-12-08 23:18:29 +08:00
|
|
|
}
|
2020-12-09 10:27:00 +08:00
|
|
|
|
2020-12-19 22:14:36 +08:00
|
|
|
func (s Server) Marshal() template.JS {
|
|
|
|
return template.JS(fmt.Sprintf(`{"ID":%d,"Name":"%s","Secret":"%s"}`, s.ID, s.Name, s.Secret))
|
2020-12-09 10:27:00 +08:00
|
|
|
}
|