改进操作日志

This commit is contained in:
GoEdgeLab
2020-11-20 15:32:42 +08:00
parent 60ba3e0a05
commit fc459a50b9
142 changed files with 230 additions and 100 deletions

View File

@@ -90,7 +90,7 @@ func (this *CleanAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "清除缓存,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "清除缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -80,7 +80,7 @@ func (this *CreatePopupAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建缓存策略:%d", createResp.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "创建缓存策略:%d", createResp.CachePolicyId)
this.Success()
}

View File

@@ -30,7 +30,7 @@ func (this *DeleteAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "删除缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -110,7 +110,7 @@ func (this *PreheatAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "预热缓存,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "预热缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -109,7 +109,7 @@ func (this *PurgeAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除缓存,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "删除缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -90,7 +90,7 @@ func (this *StatAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "统计缓存,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "统计缓存,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -58,7 +58,7 @@ func (this *TestReadAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "测试读取,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "测试读取,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -61,7 +61,7 @@ func (this *TestWriteAction) RunPost(params struct {
this.Data["results"] = results
// 创建日志
this.CreateLog(oplogs.LevelInfo, "测试写入,缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "测试写入,缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -106,7 +106,7 @@ func (this *UpdateAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改缓存策略:%d", params.CachePolicyId)
defer this.CreateLog(oplogs.LevelInfo, "修改缓存策略:%d", params.CachePolicyId)
this.Success()
}

View File

@@ -42,7 +42,7 @@ func (this *CreatePopupAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建代理服务分组 %d", createResp.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "创建代理服务分组 %d", createResp.GroupId)
this.Success()
}

View File

@@ -14,7 +14,7 @@ func (this *DeleteAction) RunPost(params struct {
GroupId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除代理服务分组 %d", params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "删除代理服务分组 %d", params.GroupId)
// 检查是否正在使用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithGroupId(this.AdminContext(), &pb.CountAllEnabledServersWithGroupIdRequest{GroupId: params.GroupId})

View File

@@ -14,7 +14,7 @@ func (this *SortAction) RunPost(params struct {
GroupIds []int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改代理分组排序")
defer this.CreateLog(oplogs.LevelInfo, "修改代理分组排序")
_, err := this.RPC().ServerGroupRPC().UpdateServerGroupOrders(this.AdminContext(), &pb.UpdateServerGroupOrdersRequest{GroupIds: params.GroupIds})
if err != nil {

View File

@@ -45,7 +45,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改代理服务分组 %d", params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务分组 %d", params.GroupId)
params.Must.
Field("name", params.Name).

View File

@@ -56,7 +56,7 @@ func (this *IndexAction) RunPost(params struct {
DefaultDomain string
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "保存代理服务全局配置")
defer this.CreateLog(oplogs.LevelInfo, "保存代理服务全局配置")
if len(params.GlobalConfigJSON) == 0 {
this.Fail("错误的配置信息,请刷新当前页面后重试")

View File

@@ -14,7 +14,7 @@ func (this *DeleteAction) RunPost(params struct {
LibraryId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除IP库 %d", params.LibraryId)
defer this.CreateLog(oplogs.LevelInfo, "删除IP库 %d", params.LibraryId)
_, err := this.RPC().IPLibraryRPC().DeleteIPLibrary(this.AdminContext(), &pb.DeleteIPLibraryRequest{IpLibraryId: params.LibraryId})
if err != nil {

View File

@@ -18,7 +18,7 @@ func (this *DownloadAction) RunGet(params struct {
LibraryId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "下载IP库 %d", params.LibraryId)
defer this.CreateLog(oplogs.LevelInfo, "下载IP库 %d", params.LibraryId)
libraryResp, err := this.RPC().IPLibraryRPC().FindEnabledIPLibrary(this.AdminContext(), &pb.FindEnabledIPLibraryRequest{IpLibraryId: params.LibraryId})
if err != nil {

View File

@@ -104,7 +104,7 @@ func (this *UploadPopupAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "上传IP库 %d", createResp.IpLibraryId)
defer this.CreateLog(oplogs.LevelInfo, "上传IP库 %d", createResp.IpLibraryId)
this.Success()
}

View File

@@ -14,7 +14,7 @@ func (this *DeleteAction) RunPost(params struct {
CertId int64
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "删除SSL证书 %d", params.CertId)
defer this.CreateLog(oplogs.LevelInfo, "删除SSL证书 %d", params.CertId)
// 是否正在被使用
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithSSLCertId(this.AdminContext(), &pb.CountAllEnabledServersWithSSLCertIdRequest{CertId: params.CertId})

View File

@@ -19,6 +19,8 @@ func (this *DownloadCertAction) Init() {
func (this *DownloadCertAction) RunGet(params struct {
CertId int64
}) {
defer this.CreateLogInfo("下载SSL证书 %d", params.CertId)
certResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)

View File

@@ -19,6 +19,8 @@ func (this *DownloadKeyAction) Init() {
func (this *DownloadKeyAction) RunGet(params struct {
CertId int64
}) {
defer this.CreateLogInfo("下载SSL密钥 %d", params.CertId)
certResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)

View File

@@ -20,6 +20,8 @@ func (this *DownloadZipAction) Init() {
func (this *DownloadZipAction) RunGet(params struct {
CertId int64
}) {
defer this.CreateLogInfo("下载SSL证书压缩包 %d", params.CertId)
certResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})
if err != nil {
this.ErrorPage(err)

View File

@@ -56,7 +56,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 创建日志
this.CreateLog(oplogs.LevelInfo, "修改SSL证书 %d", params.CertId)
defer this.CreateLog(oplogs.LevelInfo, "修改SSL证书 %d", params.CertId)
// 查询Cert
certConfigResp, err := this.RPC().SSLCertRPC().FindEnabledSSLCertConfig(this.AdminContext(), &pb.FindEnabledSSLCertConfigRequest{CertId: params.CertId})

View File

@@ -115,7 +115,7 @@ func (this *UploadPopupAction) RunPost(params struct {
}
// 创建日志
this.CreateLog(oplogs.LevelInfo, "上传SSL证书 %d", certId)
defer this.CreateLog(oplogs.LevelInfo, "上传SSL证书 %d", certId)
this.Success()
}

View File

@@ -96,7 +96,7 @@ func (this *CreateGroupPopupAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "创建规则分组 %d名称%s", groupId, params.Name)
defer this.CreateLog(oplogs.LevelInfo, "创建规则分组 %d名称%s", groupId, params.Name)
this.Success()
}

View File

@@ -57,7 +57,7 @@ func (this *CreatePopupAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "创建WAF策略 %d", createResp.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "创建WAF策略 %d", createResp.FirewallPolicyId)
this.Success()
}

View File

@@ -14,7 +14,7 @@ func (this *DeleteAction) RunPost(params struct {
FirewallPolicyId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "删除WAF策略 %d", params.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "删除WAF策略 %d", params.FirewallPolicyId)
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithHTTPFirewallPolicyId(this.AdminContext(), &pb.CountAllEnabledServersWithHTTPFirewallPolicyIdRequest{FirewallPolicyId: params.FirewallPolicyId})
if err != nil {

View File

@@ -16,7 +16,7 @@ func (this *DeleteGroupAction) RunPost(params struct {
GroupId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "删除WAF策略 %d 的规则分组 %d", params.FirewallPolicyId, params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "删除WAF策略 %d 的规则分组 %d", params.FirewallPolicyId, params.GroupId)
firewallPolicy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledPolicyConfig(this.AdminContext(), params.FirewallPolicyId)
if err != nil {

View File

@@ -18,7 +18,7 @@ func (this *DeleteSetAction) RunPost(params struct {
SetId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "删除WAF规则分组 %d 中的规则集 %d", params.GroupId, params.SetId)
defer this.CreateLog(oplogs.LevelInfo, "删除WAF规则分组 %d 中的规则集 %d", params.GroupId, params.SetId)
groupConfig, err := models.SharedHTTPFirewallRuleGroupDAO.FindRuleGroupConfig(this.AdminContext(), params.GroupId)
if err != nil {

View File

@@ -72,7 +72,7 @@ func (this *CreateIPPopupAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "在WAF策略 %d 名单中添加IP %d", params.FirewallPolicyId, itemId)
defer this.CreateLog(oplogs.LevelInfo, "在WAF策略 %d 名单中添加IP %d", params.FirewallPolicyId, itemId)
this.Success()
}

View File

@@ -16,7 +16,7 @@ func (this *DeleteIPAction) RunPost(params struct {
ItemId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "从WAF策略 %d 名单中删除IP %d", params.FirewallPolicyId, params.ItemId)
defer this.CreateLog(oplogs.LevelInfo, "从WAF策略 %d 名单中删除IP %d", params.FirewallPolicyId, params.ItemId)
// TODO 判断权限

View File

@@ -67,7 +67,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "WAF策略 %d 设置禁止访问的国家和地区", params.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "WAF策略 %d 设置禁止访问的国家和地区", params.FirewallPolicyId)
policyConfig, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledPolicyConfig(this.AdminContext(), params.FirewallPolicyId)
if err != nil {

View File

@@ -69,7 +69,7 @@ func (this *ProvincesAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "WAF策略 %d 设置禁止访问的省份", params.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "WAF策略 %d 设置禁止访问的省份", params.FirewallPolicyId)
policyConfig, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledPolicyConfig(this.AdminContext(), params.FirewallPolicyId)
if err != nil {

View File

@@ -55,7 +55,7 @@ func (this *UpdateIPPopupAction) RunPost(params struct {
CSRF *actionutils.CSRF
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 名单中的IP %d", params.FirewallPolicyId, params.ItemId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 名单中的IP %d", params.FirewallPolicyId, params.ItemId)
// TODO 校验ItemId所属用户
// TODO 校验IP格式ipFrom/ipTo

View File

@@ -18,7 +18,7 @@ func (this *SortGroupsAction) RunPost(params struct {
GroupIds []int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 中的规则分组中的排序", params.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 中的规则分组中的排序", params.FirewallPolicyId)
firewallPolicy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledPolicyConfig(this.AdminContext(), params.FirewallPolicyId)
if err != nil {

View File

@@ -18,7 +18,7 @@ func (this *SortSetsAction) RunPost(params struct {
SetIds []int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF规则分组 %d 中的规则集排序", params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF规则分组 %d 中的规则集排序", params.GroupId)
groupConfig, err := models.SharedHTTPFirewallRuleGroupDAO.FindRuleGroupConfig(this.AdminContext(), params.GroupId)
if err != nil {

View File

@@ -69,7 +69,7 @@ func (this *UpdateAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 基本信息", params.FirewallPolicyId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF策略 %d 基本信息", params.FirewallPolicyId)
params.Must.
Field("name", params.Name).

View File

@@ -15,7 +15,7 @@ func (this *UpdateGroupOnAction) RunPost(params struct {
IsOn bool
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "设置WAF规则分组 %d 开启状态", params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "设置WAF规则分组 %d 开启状态", params.GroupId)
_, err := this.RPC().HTTPFirewallRuleGroupRPC().UpdateHTTPFirewallRuleGroupIsOn(this.AdminContext(), &pb.UpdateHTTPFirewallRuleGroupIsOnRequest{
FirewallRuleGroupId: params.GroupId,

View File

@@ -49,7 +49,7 @@ func (this *UpdateGroupPopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF规则分组 %d 基本信息", params.GroupId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF规则分组 %d 基本信息", params.GroupId)
params.Must.
Field("name", params.Name).

View File

@@ -15,7 +15,7 @@ func (this *UpdateSetOnAction) RunPost(params struct {
IsOn bool
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF规则集 %d 开启状态", params.SetId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF规则集 %d 开启状态", params.SetId)
_, err := this.RPC().HTTPFirewallRuleSetRPC().UpdateHTTPFirewallRuleSetIsOn(this.AdminContext(), &pb.UpdateHTTPFirewallRuleSetIsOnRequest{
FirewallRuleSetId: params.SetId,

View File

@@ -27,7 +27,7 @@ func (this *UpdateSetPopupAction) RunGet(params struct {
SetId int64
}) {
// 日志
this.CreateLog(oplogs.LevelInfo, "修改WAF规则集 %d 基本信息", params.SetId)
defer this.CreateLog(oplogs.LevelInfo, "修改WAF规则集 %d 基本信息", params.SetId)
this.Data["groupId"] = params.GroupId
this.Data["type"] = params.Type