|
@@ -7,7 +7,6 @@ import (
|
|
v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
|
|
v1 "github.com/go-nunu/nunu-layout-advanced/api/v1"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/model"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/model"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/repository"
|
|
"github.com/go-nunu/nunu-layout-advanced/internal/repository"
|
|
- "github.com/spf13/cast"
|
|
|
|
"golang.org/x/sync/errgroup"
|
|
"golang.org/x/sync/errgroup"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
@@ -77,7 +76,6 @@ func (s *webForwardingService) require(ctx context.Context,req v1.GlobalRequire)
|
|
func (s *webForwardingService) GetWebForwarding(ctx context.Context, req v1.GetForwardingRequest) (v1.WebForwardingDataRequest, error) {
|
|
func (s *webForwardingService) GetWebForwarding(ctx context.Context, req v1.GetForwardingRequest) (v1.WebForwardingDataRequest, error) {
|
|
var webForwarding model.WebForwarding
|
|
var webForwarding model.WebForwarding
|
|
var backend model.WebForwardingRule
|
|
var backend model.WebForwardingRule
|
|
- var err error
|
|
|
|
g, gCtx := errgroup.WithContext(ctx)
|
|
g, gCtx := errgroup.WithContext(ctx)
|
|
g.Go(func() error {
|
|
g.Go(func() error {
|
|
res, e := s.webForwardingRepository.GetWebForwarding(gCtx, int64(req.Id))
|
|
res, e := s.webForwardingRepository.GetWebForwarding(gCtx, int64(req.Id))
|
|
@@ -106,15 +104,11 @@ func (s *webForwardingService) GetWebForwarding(ctx context.Context, req v1.GetF
|
|
return v1.WebForwardingDataRequest{}, err
|
|
return v1.WebForwardingDataRequest{}, err
|
|
}
|
|
}
|
|
|
|
|
|
- portInt, err := cast.ToIntE(webForwarding.Port)
|
|
|
|
- if err != nil {
|
|
|
|
- return v1.WebForwardingDataRequest{}, err
|
|
|
|
- }
|
|
|
|
return v1.WebForwardingDataRequest{
|
|
return v1.WebForwardingDataRequest{
|
|
Id: webForwarding.Id,
|
|
Id: webForwarding.Id,
|
|
WafWebId: webForwarding.WafWebId,
|
|
WafWebId: webForwarding.WafWebId,
|
|
Tag: webForwarding.Tag,
|
|
Tag: webForwarding.Tag,
|
|
- Port: portInt,
|
|
|
|
|
|
+ Port: webForwarding.Port,
|
|
Domain: webForwarding.Domain,
|
|
Domain: webForwarding.Domain,
|
|
CustomHost: webForwarding.CustomHost,
|
|
CustomHost: webForwarding.CustomHost,
|
|
WafWebLimitId: webForwarding.WebLimitRuleId,
|
|
WafWebLimitId: webForwarding.WebLimitRuleId,
|
|
@@ -189,7 +183,7 @@ func (s *webForwardingService) buildWebForwardingModel(req *v1.WebForwardingData
|
|
HostId: require.HostId,
|
|
HostId: require.HostId,
|
|
WafWebId: ruleId,
|
|
WafWebId: ruleId,
|
|
Tag: require.Tag,
|
|
Tag: require.Tag,
|
|
- Port: strconv.Itoa(req.Port),
|
|
|
|
|
|
+ Port: req.Port,
|
|
Domain: req.Domain,
|
|
Domain: req.Domain,
|
|
CustomHost: req.CustomHost,
|
|
CustomHost: req.CustomHost,
|
|
WafGatewayGroupId: require.WafGatewayGroupId,
|
|
WafGatewayGroupId: require.WafGatewayGroupId,
|
|
@@ -242,13 +236,17 @@ func (s *webForwardingService) prepareWafData(ctx context.Context, req *v1.WebFo
|
|
allowIpListStr := strings.Join(req.WebForwardingData.AllowIpList, "\n")
|
|
allowIpListStr := strings.Join(req.WebForwardingData.AllowIpList, "\n")
|
|
denyIpListStr := strings.Join(req.WebForwardingData.DenyIpList, "\n")
|
|
denyIpListStr := strings.Join(req.WebForwardingData.DenyIpList, "\n")
|
|
|
|
|
|
|
|
+ PortInt, err := strconv.Atoi(req.WebForwardingData.Port)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return v1.GlobalRequire{}, nil, err
|
|
|
|
+ }
|
|
// 3. 创建用于构建 WAF 表单的数据结构
|
|
// 3. 创建用于构建 WAF 表单的数据结构
|
|
formDataBase := v1.WebForwardingDataSend{
|
|
formDataBase := v1.WebForwardingDataSend{
|
|
Tag: require.Tag,
|
|
Tag: require.Tag,
|
|
WafWebId: req.WebForwardingData.WafWebId,
|
|
WafWebId: req.WebForwardingData.WafWebId,
|
|
WafGatewayGroupId: require.WafGatewayGroupId,
|
|
WafGatewayGroupId: require.WafGatewayGroupId,
|
|
WafWebLimitId: require.LimitRuleId,
|
|
WafWebLimitId: require.LimitRuleId,
|
|
- Port: req.WebForwardingData.Port,
|
|
|
|
|
|
+ Port: PortInt,
|
|
Domain: req.WebForwardingData.Domain,
|
|
Domain: req.WebForwardingData.Domain,
|
|
CustomHost: req.WebForwardingData.CustomHost,
|
|
CustomHost: req.WebForwardingData.CustomHost,
|
|
CcCount: req.WebForwardingData.CcCount,
|
|
CcCount: req.WebForwardingData.CcCount,
|