|
@@ -21,7 +21,7 @@ type AidedWebService interface {
|
|
|
ValidateDeletePermission(oldData *model.WebForwarding, hostId int) error
|
|
|
|
|
|
// CDN网站管理
|
|
|
- CreateCdnWebsite(ctx context.Context, req *v1.WebForwardingRequest, require RequireResponse, formData v1.Website) (int64, error)
|
|
|
+ CreateCdnWebsite(ctx context.Context, formData v1.Website) (int64, error)
|
|
|
UpdateCdnConfiguration(ctx context.Context, req *v1.WebForwardingRequest, oldData *model.WebForwarding, tag string, formData v1.Website) error
|
|
|
DeleteCdnServer(ctx context.Context, cdnWebId int) error
|
|
|
|
|
@@ -31,8 +31,8 @@ type AidedWebService interface {
|
|
|
|
|
|
// 功能配置管理
|
|
|
ConfigureWebsocket(ctx context.Context, webId int64) error
|
|
|
- ConfigureProxyProtocol(ctx context.Context, req *v1.WebForwardingRequest, webId int64) error
|
|
|
- ConfigureCCProtection(ctx context.Context, req *v1.WebForwardingRequest, webId int64) error
|
|
|
+ ConfigureProxyProtocol(ctx context.Context, proxy bool, webId int64) error
|
|
|
+ ConfigureCCProtection(ctx context.Context, ccConfig v1.CcConfigRequest, webId int64) error
|
|
|
ConfigureWafFirewall(ctx context.Context, webId int64, groupId int) error
|
|
|
|
|
|
// 异步任务处理
|
|
@@ -48,7 +48,7 @@ type AidedWebService interface {
|
|
|
CleanupDatabaseRecords(ctx context.Context, id int) error
|
|
|
|
|
|
// SSL证书管理
|
|
|
- ProcessSSLCertificate(ctx context.Context, req *v1.WebForwardingRequest, cdnUid int, formData v1.Website) error
|
|
|
+ ProcessSSLCertificate(ctx context.Context, req *v1.WebForwardingRequest, cdnUid int) error
|
|
|
ProcessSSLCertificateUpdate(ctx context.Context, req *v1.WebForwardingRequest, oldData *model.WebForwarding, cdnUid int) error
|
|
|
CleanupSSLCertificate(ctx context.Context, oldData *model.WebForwarding) error
|
|
|
|
|
@@ -474,7 +474,7 @@ func (s *aidedWebService) ValidateWebForwardingRequest(ctx context.Context, req
|
|
|
}
|
|
|
|
|
|
// ProcessSSLCertificate 处理SSL证书
|
|
|
-func (s *aidedWebService) ProcessSSLCertificate(ctx context.Context, req *v1.WebForwardingRequest, cdnUid int, formData v1.Website) error {
|
|
|
+func (s *aidedWebService) ProcessSSLCertificate(ctx context.Context, req *v1.WebForwardingRequest, cdnUid int) error {
|
|
|
if !s.IsHttpsProtocol(req.WebForwardingData.IsHttps) {
|
|
|
return nil // 非HTTPS协议不需要处理SSL证书
|
|
|
}
|
|
@@ -496,7 +496,7 @@ func (s *aidedWebService) ProcessSSLCertificate(ctx context.Context, req *v1.Web
|
|
|
req.WebForwardingData.SslCertId = sslCertId
|
|
|
|
|
|
// 编辑SSL策略
|
|
|
- if err := s.sslCert.EditSslPolicy(ctx, formData.HttpsJSON.SslPolicyRef.SslPolicyId, []int64{sslCertId}, "add"); err != nil {
|
|
|
+ if err := s.sslCert.EditSslPolicy(ctx, req.WebForwardingData.SslPolicyId, []int64{sslCertId}, "add"); err != nil {
|
|
|
return fmt.Errorf("编辑SSL策略失败: %w", err)
|
|
|
}
|
|
|
|
|
@@ -589,7 +589,7 @@ func (s *aidedWebService) ValidateDeletePermission(oldData *model.WebForwarding,
|
|
|
}
|
|
|
|
|
|
// CreateCdnWebsite 创建CDN网站
|
|
|
-func (s *aidedWebService) CreateCdnWebsite(ctx context.Context, req *v1.WebForwardingRequest, require RequireResponse, formData v1.Website) (int64, error) {
|
|
|
+func (s *aidedWebService) CreateCdnWebsite(ctx context.Context, formData v1.Website) (int64, error) {
|
|
|
formDataSend, err := s.BulidFormData(ctx, formData)
|
|
|
if err != nil {
|
|
|
return 0, fmt.Errorf("构建表单数据失败: %w", err)
|
|
@@ -806,8 +806,8 @@ func (s *aidedWebService) ConfigureWebsocket(ctx context.Context, webId int64) e
|
|
|
}
|
|
|
|
|
|
// ConfigureProxyProtocol 配置代理协议
|
|
|
-func (s *aidedWebService) ConfigureProxyProtocol(ctx context.Context, req *v1.WebForwardingRequest, webId int64) error {
|
|
|
- if req.WebForwardingData.Proxy {
|
|
|
+func (s *aidedWebService) ConfigureProxyProtocol(ctx context.Context, proxy bool, webId int64) error {
|
|
|
+ if proxy {
|
|
|
if err := s.proxy.EditProxy(ctx, webId, v1.ProxyProtocolJSON{
|
|
|
IsOn: true,
|
|
|
Version: proxyProtocolVersion,
|
|
@@ -819,8 +819,8 @@ func (s *aidedWebService) ConfigureProxyProtocol(ctx context.Context, req *v1.We
|
|
|
}
|
|
|
|
|
|
// ConfigureCCProtection 配置CC防护
|
|
|
-func (s *aidedWebService) ConfigureCCProtection(ctx context.Context, req *v1.WebForwardingRequest, webId int64) error {
|
|
|
- if err := s.cc.EditCcConfig(ctx, webId, req.WebForwardingData.CcConfig); err != nil {
|
|
|
+func (s *aidedWebService) ConfigureCCProtection(ctx context.Context, ccConfig v1.CcConfigRequest, webId int64) error {
|
|
|
+ if err := s.cc.EditCcConfig(ctx, webId, ccConfig); err != nil {
|
|
|
return fmt.Errorf("配置CC防护失败: %w", err)
|
|
|
}
|
|
|
return nil
|
|
@@ -1065,13 +1065,7 @@ func (s *aidedWebService) ProcessSSLCertificateUpdate(ctx context.Context, req *
|
|
|
|
|
|
// 如果证书ID为0
|
|
|
if oldData.SslCertId == 0 {
|
|
|
- err := s.ProcessSSLCertificate(ctx, req, cdnUid, v1.Website{
|
|
|
- HttpsJSON: v1.TypeJSON{
|
|
|
- SslPolicyRef: v1.SslPolicyRef{
|
|
|
- SslPolicyId: req.WebForwardingData.SslPolicyId,
|
|
|
- },
|
|
|
- },
|
|
|
- })
|
|
|
+ err := s.ProcessSSLCertificate(ctx, req, cdnUid)
|
|
|
if err != nil {
|
|
|
return fmt.Errorf("处理SSL证书失败: %w", err)
|
|
|
}
|