Ver código fonte

refactor(waf): 优化配置代理协议功能

- 修改 ConfigureProxyProtocol 方法参数名,使用 cdnWebId 替代 webId- 简化 WebForwarding 更新逻辑,直接使用新参数
fusu 1 dia atrás
pai
commit
69cfba71c4

+ 3 - 3
internal/service/api/waf/aidedweb.go

@@ -31,7 +31,7 @@ type AidedWebService interface {
 	
 	// 功能配置管理
 	ConfigureWebsocket(ctx context.Context, webId int64) error
-	ConfigureProxyProtocol(ctx context.Context, proxy bool, webId int64) error
+	ConfigureProxyProtocol(ctx context.Context, proxy bool, cdnWebId int64) error
 	ConfigureCCProtection(ctx context.Context, ccConfig v1.CcConfigRequest, webId int64) error
 	ConfigureWafFirewall(ctx context.Context, webId int64, groupId int) error
 	
@@ -806,8 +806,8 @@ func (s *aidedWebService) ConfigureWebsocket(ctx context.Context, webId int64) e
 }
 
 // ConfigureProxyProtocol 配置代理协议
-func (s *aidedWebService) ConfigureProxyProtocol(ctx context.Context, proxy bool, webId int64) error {
-	if err := s.proxy.EditProxy(ctx, webId, v1.ProxyProtocolJSON{
+func (s *aidedWebService) ConfigureProxyProtocol(ctx context.Context, proxy bool, cdnWebId int64) error {
+	if err := s.proxy.EditProxy(ctx, cdnWebId, v1.ProxyProtocolJSON{
 		IsOn:    proxy,
 		Version: proxyProtocolVersion,
 	}); err != nil {

+ 2 - 4
internal/service/api/waf/webforwarding.go

@@ -246,10 +246,8 @@ func (s *webForwardingService) EditWebForwarding(ctx context.Context, req *v1.We
 	}
 
 	// 5. 更新Proxy Protocol配置
-	if oldData.Proxy != req.WebForwardingData.Proxy {
-		if err := s.aidedWeb.ConfigureProxyProtocol(ctx, req.WebForwardingData.Proxy, int64(oldData.CdnWebId)); err != nil {
-			return err
-		}
+	if err := s.aidedWeb.ConfigureProxyProtocol(ctx, req.WebForwardingData.Proxy, int64(oldData.CdnWebId)); err != nil {
+		return err
 	}
 
 	// 6. 更新CC防护配置