mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
IP名单增加代号管理
This commit is contained in:
@@ -4,6 +4,7 @@ package iplists
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/iplists/iplistutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -28,6 +29,7 @@ func (this *CreatePopupAction) RunGet(params struct {
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Name string
|
||||
Code string
|
||||
Type string
|
||||
Description string
|
||||
IsGlobal bool
|
||||
@@ -44,10 +46,27 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Field("name", params.Name).
|
||||
Require("请输入名称")
|
||||
|
||||
if len(params.Code) > 0 {
|
||||
if !iplistutils.ValidateIPListCode(params.Code) {
|
||||
this.FailField("code", "代号格式错误,只能是英文字母、数字、中划线、下划线的组合")
|
||||
return
|
||||
}
|
||||
|
||||
listIdResp, err := this.RPC().IPListRPC().FindIPListIdWithCode(this.AdminContext(), &pb.FindIPListIdWithCodeRequest{Code: params.Code})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if listIdResp.IpListId > 0 {
|
||||
this.FailField("code", "代号'"+params.Code+"'已经被别的名单占用,请更换一个")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().IPListRPC().CreateIPList(this.AdminContext(), &pb.CreateIPListRequest{
|
||||
Type: params.Type,
|
||||
Name: params.Name,
|
||||
Code: "",
|
||||
Code: params.Code,
|
||||
TimeoutJSON: nil,
|
||||
IsPublic: true,
|
||||
Description: params.Description,
|
||||
|
||||
Reference in New Issue
Block a user