2019-12-08 10:18:29 -05:00
|
|
|
package model
|
|
|
|
|
2019-12-10 04:57:57 -05:00
|
|
|
import (
|
2020-12-08 21:27:00 -05:00
|
|
|
"fmt"
|
2020-12-19 09:14:36 -05:00
|
|
|
"html/template"
|
2020-10-24 09:29:05 -04:00
|
|
|
"time"
|
|
|
|
|
2020-11-10 21:07:45 -05:00
|
|
|
pb "github.com/naiba/nezha/proto"
|
2019-12-10 04:57:57 -05:00
|
|
|
)
|
|
|
|
|
2019-12-08 10:18:29 -05:00
|
|
|
type Server struct {
|
|
|
|
Common
|
2021-01-08 08:04:50 -05:00
|
|
|
Name string
|
|
|
|
DisplayIndex int // 展示权重,越大越靠前
|
|
|
|
Secret string `json:"-"`
|
2021-01-12 01:09:25 -05:00
|
|
|
Tag string
|
2021-01-15 11:45:49 -05:00
|
|
|
Host *Host `gorm:"-"`
|
|
|
|
State *HostState `gorm:"-"`
|
2021-01-12 01:09:25 -05:00
|
|
|
LastActive time.Time
|
2019-12-10 04:57:57 -05:00
|
|
|
|
2021-01-15 11:45:49 -05:00
|
|
|
TaskClose chan error `gorm:"-" json:"-"`
|
|
|
|
TaskStream pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"`
|
2019-12-08 10:18:29 -05:00
|
|
|
}
|
2020-12-08 21:27:00 -05:00
|
|
|
|
2020-12-19 09:14:36 -05: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-08 21:27:00 -05:00
|
|
|
}
|