mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 04:30:05 +00:00
feat: edit server config online (#980)
* feat: edit server config online * clean * refactor * generate template * fix deadlocks * fix
This commit is contained in:
@@ -32,12 +32,20 @@ type Server struct {
|
||||
GeoIP *GeoIP `gorm:"-" json:"geoip,omitempty"`
|
||||
LastActive time.Time `gorm:"-" json:"last_active,omitempty"`
|
||||
|
||||
TaskStream pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"`
|
||||
TaskStream pb.NezhaService_RequestTaskServer `gorm:"-" json:"-"`
|
||||
ConfigCache chan any `gorm:"-" json:"-"`
|
||||
|
||||
PrevTransferInSnapshot int64 `gorm:"-" json:"-"` // 上次数据点时的入站使用量
|
||||
PrevTransferOutSnapshot int64 `gorm:"-" json:"-"` // 上次数据点时的出站使用量
|
||||
}
|
||||
|
||||
func InitServer(s *Server) {
|
||||
s.Host = &Host{}
|
||||
s.State = &HostState{}
|
||||
s.GeoIP = &GeoIP{}
|
||||
s.ConfigCache = make(chan any, 1)
|
||||
}
|
||||
|
||||
func (s *Server) CopyFromRunningServer(old *Server) {
|
||||
s.Host = old.Host
|
||||
s.State = old.State
|
||||
|
||||
@@ -24,6 +24,8 @@ const (
|
||||
TaskTypeNAT
|
||||
TaskTypeReportHostInfoDeprecated
|
||||
TaskTypeFM
|
||||
TaskTypeReportConfig
|
||||
TaskTypeApplyConfig
|
||||
)
|
||||
|
||||
type TerminalTask struct {
|
||||
@@ -127,5 +129,12 @@ func (m *Service) AfterFind(tx *gorm.DB) error {
|
||||
|
||||
// IsServiceSentinelNeeded 判断该任务类型是否需要进行服务监控 需要则返回true
|
||||
func IsServiceSentinelNeeded(t uint64) bool {
|
||||
return t != TaskTypeCommand && t != TaskTypeTerminalGRPC && t != TaskTypeUpgrade && t != TaskTypeKeepalive
|
||||
switch t {
|
||||
case TaskTypeCommand, TaskTypeTerminalGRPC, TaskTypeUpgrade,
|
||||
TaskTypeKeepalive, TaskTypeNAT, TaskTypeFM,
|
||||
TaskTypeReportConfig, TaskTypeApplyConfig:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user