改进操作日志

This commit is contained in:
刘祥超
2020-11-20 15:32:42 +08:00
parent ad836d70ac
commit 6bca0abc69
142 changed files with 230 additions and 100 deletions

View File

@@ -71,7 +71,7 @@ func (this *AddOriginPopupAction) RunPost(params struct {
this.Data["origin"] = origin
// 创建日志
this.CreateLog(oplogs.LevelInfo, "创建源站 %d", resp.OriginId)
defer this.CreateLog(oplogs.LevelInfo, "创建源站 %d", resp.OriginId)
this.Success()
}

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

View File

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

View File

@@ -25,7 +25,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 记录日志
this.CreateLog(oplogs.LevelInfo, "删除代理服务 %d", params.ServerId)
defer this.CreateLog(oplogs.LevelInfo, "删除代理服务 %d", params.ServerId)
// 执行删除
_, err := this.RPC().ServerRPC().DisableServer(this.AdminContext(), &pb.DisableServerRequest{ServerId: params.ServerId})

View File

@@ -1,6 +1,7 @@
package accessLog
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -59,6 +60,9 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的访问日志设置", params.WebId)
// TODO 检查参数
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{

View File

@@ -2,6 +2,7 @@ package cache
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -39,6 +40,9 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的缓存设置", params.WebId)
// TODO 校验配置
cacheConfig := &serverconfigs.HTTPCacheConfig{}
err := json.Unmarshal(params.CacheJSON, cacheConfig)

View File

@@ -1,6 +1,7 @@
package charset
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
@@ -41,6 +42,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的字符集设置", params.WebId)
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
WebId: params.WebId,
CharsetJSON: params.CharsetJSON,

View File

@@ -2,6 +2,7 @@ package gzip
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -76,6 +77,9 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的GZip配置", params.WebId)
if params.Level < 0 || params.Level > 9 {
this.Fail("请选择正确的压缩级别")
}

View File

@@ -2,6 +2,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
@@ -30,6 +31,13 @@ func (this *CreateDeletePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "添加删除的Header HeaderPolicyId: %d, Name: %s", params.HeaderPolicyId, params.Name)
params.Must.
Field("name", params.Name).
Require("名称不能为空")
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{HeaderPolicyId: params.HeaderPolicyId})
if err != nil {
this.ErrorPage(err)

View File

@@ -2,6 +2,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
@@ -32,6 +33,9 @@ func (this *CreateSetPopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "设置请求HeaderHeaderPolicyId:%d, Name:%s, Value:%s", params.HeaderPolicyId, params.Name, params.Value)
params.Must.
Field("name", params.Name).
Require("请输入Header名称")

View File

@@ -2,6 +2,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
@@ -17,6 +18,8 @@ func (this *DeleteAction) RunPost(params struct {
Type string
HeaderId int64
}) {
defer this.CreateLog(oplogs.LevelInfo, "删除请求HeaderHeaderPolicyId:%d, HeaderId:%d", params.HeaderPolicyId, params.HeaderId)
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{
HeaderPolicyId: params.HeaderPolicyId,
})

View File

@@ -2,6 +2,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
@@ -15,6 +16,9 @@ func (this *DeleteDeletingHeaderAction) RunPost(params struct {
HeaderPolicyId int64
HeaderName string
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "删除需要删除的请求HeaderHeaderPolicyId:%d, HeaderName:%s", params.HeaderPolicyId, params.HeaderName)
policyConfigResp, err := this.RPC().HTTPHeaderPolicyRPC().FindEnabledHTTPHeaderPolicyConfig(this.AdminContext(), &pb.FindEnabledHTTPHeaderPolicyConfigRequest{HeaderPolicyId: params.HeaderPolicyId})
if err != nil {
this.ErrorPage(err)

View File

@@ -2,6 +2,7 @@ package headers
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
@@ -46,6 +47,9 @@ func (this *UpdateSetPopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改设置请求HeaderHeaderPolicyId:%d, Name:%s, Value:%s", params.HeaderId, params.Name, params.Value)
params.Must.
Field("name", params.Name).
Require("请输入Header名称")

View File

@@ -68,7 +68,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 记录日志
this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTP设置", params.ServerId)
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTP设置", params.ServerId)
addresses := []*serverconfigs.NetworkAddressConfig{}
err := json.Unmarshal([]byte(params.Addresses), &addresses)

View File

@@ -79,7 +79,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 记录日志
this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTPS设置", params.ServerId)
defer this.CreateLog(oplogs.LevelInfo, "修改服务 %d 的HTTPS设置", params.ServerId)
addresses := []*serverconfigs.NetworkAddressConfig{}
err := json.Unmarshal([]byte(params.Addresses), &addresses)

View File

@@ -103,7 +103,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 记录日志
this.CreateLog(oplogs.LevelInfo, "修改代理服务 %d 基本信息", params.ServerId)
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务 %d 基本信息", params.ServerId)
params.Must.
Field("name", params.Name).

View File

@@ -57,6 +57,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的访问日志设置", params.WebId)
// TODO 检查参数
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebAccessLog(this.AdminContext(), &pb.UpdateHTTPWebAccessLogRequest{

View File

@@ -37,6 +37,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的缓存设置", params.WebId)
// TODO 校验配置
cacheConfig := &serverconfigs.HTTPCacheConfig{}
err := json.Unmarshal(params.CacheJSON, cacheConfig)

View File

@@ -39,6 +39,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的字符集设置", params.WebId)
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebCharset(this.AdminContext(), &pb.UpdateHTTPWebCharsetRequest{
WebId: params.WebId,
CharsetJSON: params.CharsetJSON,

View File

@@ -75,6 +75,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的Gzip设置", params.WebId)
if params.Level < 0 || params.Level > 9 {
this.Fail("请选择正确的压缩级别")
}

View File

@@ -102,6 +102,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的Header设置", params.WebId)
// TODO 检查配置
switch params.Type {

View File

@@ -35,6 +35,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的通用设置", params.WebId)
// 设置跳转到HTTPS
// TODO 校验设置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebRedirectToHTTPS(this.AdminContext(), &pb.UpdateHTTPWebRedirectToHTTPSRequest{

View File

@@ -47,6 +47,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改路径规则 %d 设置", params.LocationId)
params.Must.
Field("pattern", params.Pattern).
Require("请输入路径匹配规则")

View File

@@ -36,6 +36,8 @@ func (this *IndexAction) RunPost(params struct {
ShutdownJSON string
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的特殊页面设置", params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{

View File

@@ -51,6 +51,8 @@ func (this *SettingAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改路径规则 %d 的反向代理设置", params.LocationId)
// TODO 校验配置
reverseProxyConfig := &serverconfigs.ReverseProxyConfig{}

View File

@@ -35,6 +35,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的统计设置", params.WebId)
// TODO 校验配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.AdminContext(), &pb.UpdateHTTPWebStatRequest{

View File

@@ -53,6 +53,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的WAF设置", params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.AdminContext(), &pb.UpdateHTTPWebFirewallRequest{

View File

@@ -35,6 +35,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的根目录等设置", params.WebId)
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
WebId: params.WebId,

View File

@@ -40,6 +40,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的Websocket设置", params.WebId)
// TODO 检查配置
websocketRef := &serverconfigs.HTTPWebsocketRef{}

View File

@@ -132,7 +132,7 @@ func (this *AddPopupAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "为反向代理服务 %d 添加源站 %d", params.ReverseProxyId, originId)
defer this.CreateLog(oplogs.LevelInfo, "为反向代理服务 %d 添加源站 %d", params.ReverseProxyId, originId)
this.Success()
}

View File

@@ -83,7 +83,7 @@ func (this *DeleteAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "删除反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
defer this.CreateLog(oplogs.LevelInfo, "删除反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
this.Success()
}

View File

@@ -104,7 +104,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
}
// 日志
this.CreateLog(oplogs.LevelInfo, "修改反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
defer this.CreateLog(oplogs.LevelInfo, "修改反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
this.Success()
}

View File

@@ -2,6 +2,7 @@ package pages
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -60,5 +61,8 @@ func (this *CreatePopupAction) RunPost(params struct {
}
this.Data["page"] = pageConfig
// 日志
defer this.CreateLog(oplogs.LevelInfo, "创建特殊页面 %d", pageId)
this.Success()
}

View File

@@ -1,6 +1,7 @@
package pages
import (
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings/webutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
@@ -38,6 +39,9 @@ func (this *IndexAction) RunPost(params struct {
ShutdownJSON string
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改Web %d 的设置", params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebPages(this.AdminContext(), &pb.UpdateHTTPWebPagesRequest{

View File

@@ -2,6 +2,7 @@ package pages
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -46,6 +47,9 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
// 日志
defer this.CreateLog(oplogs.LevelInfo, "修改特殊页面 %d", params.PageId)
params.Must.
Field("status", params.Status).
Require("请输入响应状态码").

View File

@@ -51,6 +51,8 @@ func (this *SettingAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改代理服务 %d 的反向代理设置", params.ServerId)
// TODO 校验配置
reverseProxyConfig := &serverconfigs.ReverseProxyConfig{}

View File

@@ -93,6 +93,8 @@ func (this *UpdateSchedulingPopupAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改反向代理 %d 负载均衡算法", params.ReverseProxyId)
reverseProxyResp, err := this.RPC().ReverseProxyRPC().FindEnabledReverseProxyConfig(this.AdminContext(), &pb.FindEnabledReverseProxyConfigRequest{ReverseProxyId: params.ReverseProxyId})
if err != nil {
this.ErrorPage(err)

View File

@@ -98,5 +98,8 @@ func (this *CreatePopupAction) RunPost(params struct {
return
}
// 日志
defer this.CreateLogInfo("在Web %d 中创建重写规则 %d", params.WebId, createResp.RewriteRuleId)
this.Success()
}

View File

@@ -16,6 +16,8 @@ func (this *DeleteAction) RunPost(params struct {
WebId int64
RewriteRuleId int64
}) {
defer this.CreateLogInfo("从Web %d 中删除重写规则 %d", params.WebId, params.RewriteRuleId)
webConfig, err := webutils.FindWebConfigWithId(this.Parent(), params.WebId)
if err != nil {
this.ErrorPage(err)

View File

@@ -16,6 +16,8 @@ func (this *SortAction) RunPost(params struct {
WebId int64
RewriteRuleIds []int64
}) {
defer this.CreateLogInfo("对Web %d 中的重写规则进行排序", params.WebId)
webConfig, err := webutils.FindWebConfigWithId(this.Parent(), params.WebId)
if err != nil {
this.ErrorPage(err)

View File

@@ -59,6 +59,8 @@ func (this *UpdatePopupAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 中的重写规则 %d", params.WebId, params.RewriteRuleId)
params.Must.
Field("pattern", params.Pattern).
Require("请输入匹配规则").

View File

@@ -49,7 +49,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
// 记录日志
this.CreateLog(oplogs.LevelInfo, "修改代理服务 %d 域名", params.ServerId)
defer this.CreateLog(oplogs.LevelInfo, "修改代理服务 %d 域名", params.ServerId)
serverNames := []*serverconfigs.ServerNameConfig{}
err := json.Unmarshal([]byte(params.ServerNames), &serverNames)

View File

@@ -37,6 +37,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的统计设置", params.WebId)
// TODO 校验配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebStat(this.AdminContext(), &pb.UpdateHTTPWebStatRequest{

View File

@@ -49,6 +49,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改代理服务 %d TCP设置", params.ServerId)
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
if !isOk {
return

View File

@@ -78,6 +78,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改代理服务 %d TLS设置", params.ServerId)
server, _, isOk := serverutils.FindServer(this.Parent(), params.ServerId)
if !isOk {
return

View File

@@ -55,6 +55,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的WAF设置", params.WebId)
// TODO 检查配置
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWebFirewall(this.AdminContext(), &pb.UpdateHTTPWebFirewallRequest{

View File

@@ -38,6 +38,7 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的首页文件名", params.WebId)
_, err := this.RPC().HTTPWebRPC().UpdateHTTPWeb(this.AdminContext(), &pb.UpdateHTTPWebRequest{
WebId: params.WebId,

View File

@@ -41,6 +41,8 @@ func (this *IndexAction) RunPost(params struct {
Must *actions.Must
}) {
defer this.CreateLogInfo("修改Web %d 的Websocket设置", params.WebId)
// TODO 检查配置
websocketRef := &serverconfigs.HTTPWebsocketRef{}