优化代码

This commit is contained in:
GoEdgeLab
2023-08-08 14:17:16 +08:00
parent 9f24a6b3ee
commit 1f39947a89
58 changed files with 159 additions and 125 deletions

View File

@@ -5,7 +5,6 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache/cacheutils"
"github.com/iwind/TeaGo/actions"
"net/http"
"reflect"
)
type Helper struct {
@@ -27,11 +26,11 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) {
cachePolicyId := action.ParamInt64("cachePolicyId")
action.Data["cachePolicyId"] = cachePolicyId
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
if parentActionValue.IsValid() {
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
if isOk {
action.Data["cachePolicyName"] = cacheutils.FindCachePolicyNameWithoutError(&parentAction, cachePolicyId)
}
parentActionObj, ok := actionPtr.(interface {
Parent() *actionutils.ParentAction
})
if ok {
var parentAction = parentActionObj.Parent()
action.Data["cachePolicyName"] = cacheutils.FindCachePolicyNameWithoutError(parentAction, cachePolicyId)
}
}

View File

@@ -76,14 +76,6 @@ func (this *IndexAction) RunPost(params struct {
this.Fail("配置校验失败:" + err.Error())
}
// 允许不匹配的域名
allowMismatchDomains := []string{}
for _, domain := range params.AllowMismatchDomains {
if len(domain) > 0 {
allowMismatchDomains = append(allowMismatchDomains, domain)
}
}
// TCP端口范围
if params.TcpAllPortRangeMin < 1024 {
params.TcpAllPortRangeMin = 1024

View File

@@ -31,7 +31,7 @@ func (this *ExportDownloadAction) RunGet(params struct {
if ok {
this.AddHeader("Content-Disposition", "attachment; filename=\"WAF-"+types.String(params.PolicyId)+".json\";")
this.AddHeader("Content-Length", strconv.Itoa(len(data)))
this.Write(data)
_, _ = this.Write(data)
} else {
this.WriteString("找不到要导出的内容")
return

View File

@@ -52,6 +52,10 @@ func (this *SortSetsAction) RunPost(params struct {
FirewallRuleGroupId: params.GroupId,
FirewallRuleSetsJSON: newRefsJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}