mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +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
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package log
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
@@ -11,7 +10,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type HistoryAction struct {
 | 
			
		||||
	actionutils.ParentAction
 | 
			
		||||
	BaseAction
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *HistoryAction) Init() {
 | 
			
		||||
@@ -56,6 +55,11 @@ func (this *HistoryAction) RunGet(params struct {
 | 
			
		||||
	this.Data["nodeId"] = params.NodeId
 | 
			
		||||
	this.Data["partition"] = params.Partition
 | 
			
		||||
 | 
			
		||||
	// 检查集群全局设置
 | 
			
		||||
	if !this.initClusterAccessLogConfig(params.ServerId) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var day = params.Day
 | 
			
		||||
	var ipList = []string{}
 | 
			
		||||
	var wafMaps = []maps.Map{}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package log
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/actions"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
@@ -10,7 +9,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type IndexAction struct {
 | 
			
		||||
	actionutils.ParentAction
 | 
			
		||||
	BaseAction
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *IndexAction) Init() {
 | 
			
		||||
@@ -36,6 +35,11 @@ func (this *IndexAction) RunGet(params struct {
 | 
			
		||||
	this.Data["clusterId"] = params.ClusterId
 | 
			
		||||
	this.Data["nodeId"] = params.NodeId
 | 
			
		||||
 | 
			
		||||
	// 检查集群全局设置
 | 
			
		||||
	if !this.initClusterAccessLogConfig(params.ServerId) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 记录最近使用
 | 
			
		||||
	_, err := this.RPC().LatestItemRPC().IncreaseLatestItem(this.AdminContext(), &pb.IncreaseLatestItemRequest{
 | 
			
		||||
		ItemType: "server",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package log
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"github.com/iwind/TeaGo/maps"
 | 
			
		||||
@@ -9,7 +8,7 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type TodayAction struct {
 | 
			
		||||
	actionutils.ParentAction
 | 
			
		||||
	BaseAction
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *TodayAction) Init() {
 | 
			
		||||
@@ -50,6 +49,11 @@ func (this *TodayAction) RunGet(params struct {
 | 
			
		||||
	this.Data["partition"] = params.Partition
 | 
			
		||||
	this.Data["day"] = timeutil.Format("Ymd")
 | 
			
		||||
 | 
			
		||||
	// 检查集群全局设置
 | 
			
		||||
	if !this.initClusterAccessLogConfig(params.ServerId) {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
 | 
			
		||||
		Partition:         params.Partition,
 | 
			
		||||
		RequestId:         params.RequestId,
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,12 @@
 | 
			
		||||
 | 
			
		||||
{$template "/left_menu_with_menu"}
 | 
			
		||||
<div class="right-box with-menu">
 | 
			
		||||
    <!-- 集群设置提醒 -->
 | 
			
		||||
    <div v-if="!clusterAccessLogIsOn">
 | 
			
		||||
        <div class="margin"></div>
 | 
			
		||||
        <warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
	<first-menu>
 | 
			
		||||
		<menu-item :href="path + '?' + query()" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
 | 
			
		||||
		<menu-item :href="path + '?' + query('hasError=1')" :active="hasError > 0">错误日志</menu-item>
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,12 @@
 | 
			
		||||
 | 
			
		||||
{$template "/left_menu_with_menu"}
 | 
			
		||||
<div class="right-box with-menu">
 | 
			
		||||
    <!-- 集群设置提醒 -->
 | 
			
		||||
    <div v-if="!clusterAccessLogIsOn">
 | 
			
		||||
        <div class="margin"></div>
 | 
			
		||||
        <warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <form method="get" class="ui form small" :action="path" autocomplete="off">
 | 
			
		||||
        <input type="hidden" name="serverId" :value="serverId"/>
 | 
			
		||||
        <http-access-log-search-box :v-ip="ip" :v-domain="domain" :v-keyword="keyword"  :v-cluster-id="clusterId" :v-node-id="nodeId"></http-access-log-search-box>
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,12 @@
 | 
			
		||||
 | 
			
		||||
{$template "/left_menu_with_menu"}
 | 
			
		||||
<div class="right-box with-menu">
 | 
			
		||||
    <!-- 集群设置提醒 -->
 | 
			
		||||
    <div v-if="!clusterAccessLogIsOn">
 | 
			
		||||
        <div class="margin"></div>
 | 
			
		||||
        <warning-message>当前集群已经设置不允许网站记录访问日志,可以在"集群设置" -- "网站设置"中修改此选项。</warning-message>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
	<first-menu>
 | 
			
		||||
		<menu-item :href="path + '?' + query()" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
 | 
			
		||||
		<menu-item :href="path + '?' + query('hasError=1')" :active="hasError > 0">错误日志</menu-item>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user