mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-02-17 13:15:37 +08:00
当集群设置不允许记录访问日志时,在网站的访问日志查看页面提醒
This commit is contained in:
50
internal/web/actions/default/servers/server/log/base.go
Normal file
50
internal/web/actions/default/servers/server/log/base.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package log
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
)
|
||||
|
||||
type BaseAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *BaseAction) initClusterAccessLogConfig(serverId int64) bool {
|
||||
this.Data["clusterAccessLogIsOn"] = true
|
||||
var clusterId int64
|
||||
serverResp, err := this.RPC().ServerRPC().FindEnabledUserServerBasic(this.AdminContext(), &pb.FindEnabledUserServerBasicRequest{ServerId: serverId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return false
|
||||
}
|
||||
if serverResp.Server == nil {
|
||||
this.NotFound("Server", serverId)
|
||||
return false
|
||||
}
|
||||
if serverResp.Server.NodeCluster != nil && serverResp.Server.NodeCluster.Id > 0 {
|
||||
clusterId = serverResp.Server.NodeCluster.Id
|
||||
}
|
||||
|
||||
if clusterId > 0 {
|
||||
globalServerConfigResp, err := this.RPC().NodeClusterRPC().FindNodeClusterGlobalServerConfig(this.AdminContext(), &pb.FindNodeClusterGlobalServerConfigRequest{NodeClusterId: clusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return false
|
||||
}
|
||||
|
||||
if len(globalServerConfigResp.GlobalServerConfigJSON) > 0 {
|
||||
var globalServerConfig = serverconfigs.NewGlobalServerConfig()
|
||||
err = json.Unmarshal(globalServerConfigResp.GlobalServerConfigJSON, globalServerConfig)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return false
|
||||
}
|
||||
this.Data["clusterAccessLogIsOn"] = globalServerConfig.HTTPAccessLog.IsOn
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user