diff --git a/internal/db/models/http_access_log_policy_dao.go b/internal/db/models/http_access_log_policy_dao.go index cdabbfef..bdb6f863 100644 --- a/internal/db/models/http_access_log_policy_dao.go +++ b/internal/db/models/http_access_log_policy_dao.go @@ -118,13 +118,13 @@ func (this *HTTPAccessLogPolicyDAO) ComposeAccessLogPolicyConfig(policyId int64) } // 条件 - if IsNotNull(policy.CondGroups) { - condGroups := []*shared.HTTPRequestCondGroup{} - err = json.Unmarshal([]byte(policy.CondGroups), &condGroups) + if IsNotNull(policy.Conds) { + condsConfig := &shared.HTTPRequestCondsConfig{} + err = json.Unmarshal([]byte(policy.Conds), condsConfig) if err != nil { return nil, err } - config.CondGroups = condGroups + config.Conds = condsConfig } return config, nil diff --git a/internal/db/models/http_access_log_policy_model.go b/internal/db/models/http_access_log_policy_model.go index a2690280..b4fef975 100644 --- a/internal/db/models/http_access_log_policy_model.go +++ b/internal/db/models/http_access_log_policy_model.go @@ -12,7 +12,7 @@ type HTTPAccessLogPolicy struct { IsOn uint8 `field:"isOn"` // 是否启用 Type string `field:"type"` // 存储类型 Options string `field:"options"` // 存储选项 - CondGroups string `field:"condGroups"` // 请求条件 + Conds string `field:"conds"` // 请求条件 } type HTTPAccessLogPolicyOperator struct { @@ -26,7 +26,7 @@ type HTTPAccessLogPolicyOperator struct { IsOn interface{} // 是否启用 Type interface{} // 存储类型 Options interface{} // 存储选项 - CondGroups interface{} // 请求条件 + Conds interface{} // 请求条件 } func NewHTTPAccessLogPolicyOperator() *HTTPAccessLogPolicyOperator { diff --git a/internal/db/models/http_cache_policy_model.go b/internal/db/models/http_cache_policy_model.go index c5da28c9..0c1817b0 100644 --- a/internal/db/models/http_cache_policy_model.go +++ b/internal/db/models/http_cache_policy_model.go @@ -16,7 +16,7 @@ type HTTPCachePolicy struct { SkipCacheControlValues string `field:"skipCacheControlValues"` // 忽略的cache-control SkipSetCookie uint8 `field:"skipSetCookie"` // 是否忽略Set-Cookie Header EnableRequestCachePragma uint8 `field:"enableRequestCachePragma"` // 是否支持客户端的Pragma: no-cache - CondGroups string `field:"condGroups"` // 请求条件 + Conds string `field:"conds"` // 请求条件 CreatedAt uint64 `field:"createdAt"` // 创建时间 State uint8 `field:"state"` // 状态 } @@ -36,7 +36,7 @@ type HTTPCachePolicyOperator struct { SkipCacheControlValues interface{} // 忽略的cache-control SkipSetCookie interface{} // 是否忽略Set-Cookie Header EnableRequestCachePragma interface{} // 是否支持客户端的Pragma: no-cache - CondGroups interface{} // 请求条件 + Conds interface{} // 请求条件 CreatedAt interface{} // 创建时间 State interface{} // 状态 } diff --git a/internal/db/models/http_firewall_policy_model.go b/internal/db/models/http_firewall_policy_model.go index 13702ce6..69de8b56 100644 --- a/internal/db/models/http_firewall_policy_model.go +++ b/internal/db/models/http_firewall_policy_model.go @@ -12,7 +12,7 @@ type HTTPFirewallPolicy struct { Name string `field:"name"` // 名称 Inbound string `field:"inbound"` // 入站规则 Outbound string `field:"outbound"` // 出站规则 - CondGroups string `field:"condGroups"` // 条件 + Conds string `field:"conds"` // 条件 } type HTTPFirewallPolicyOperator struct { @@ -26,7 +26,7 @@ type HTTPFirewallPolicyOperator struct { Name interface{} // 名称 Inbound interface{} // 入站规则 Outbound interface{} // 出站规则 - CondGroups interface{} // 条件 + Conds interface{} // 条件 } func NewHTTPFirewallPolicyOperator() *HTTPFirewallPolicyOperator { diff --git a/internal/db/models/http_gzip_dao.go b/internal/db/models/http_gzip_dao.go index 6553dd8b..c9754fd1 100644 --- a/internal/db/models/http_gzip_dao.go +++ b/internal/db/models/http_gzip_dao.go @@ -107,20 +107,20 @@ func (this *HTTPGzipDAO) ComposeGzipConfig(gzipId int64) (*serverconfigs.HTTPGzi } config.Level = types.Int8(gzip.Level) - if IsNotNull(gzip.CondGroups) { - groups := []*shared.HTTPRequestCondGroup{} - err = json.Unmarshal([]byte(gzip.CondGroups), &groups) + if IsNotNull(gzip.Conds) { + condsConfig := &shared.HTTPRequestCondsConfig{} + err = json.Unmarshal([]byte(gzip.Conds), condsConfig) if err != nil { return nil, err } - config.CondGroups = groups + config.Conds = condsConfig } return config, nil } // 创建Gzip -func (this *HTTPGzipDAO) CreateGzip(level int, minLengthJSON []byte, maxLengthJSON []byte, condGroupsJSON []byte) (int64, error) { +func (this *HTTPGzipDAO) CreateGzip(level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) (int64, error) { op := NewHTTPGzipOperator() op.State = HTTPGzipStateEnabled op.IsOn = true @@ -131,8 +131,8 @@ func (this *HTTPGzipDAO) CreateGzip(level int, minLengthJSON []byte, maxLengthJS if len(maxLengthJSON) > 0 { op.MaxLength = JSONBytes(maxLengthJSON) } - if len(condGroupsJSON) > 0 { - op.CondGroups = JSONBytes(condGroupsJSON) + if len(condsJSON) > 0 { + op.Conds = JSONBytes(condsJSON) } _, err := this.Save(op) if err != nil { @@ -142,7 +142,7 @@ func (this *HTTPGzipDAO) CreateGzip(level int, minLengthJSON []byte, maxLengthJS } // 修改Gzip -func (this *HTTPGzipDAO) UpdateGzip(gzipId int64, level int, minLengthJSON []byte, maxLengthJSON []byte, condGroupsJSON []byte) error { +func (this *HTTPGzipDAO) UpdateGzip(gzipId int64, level int, minLengthJSON []byte, maxLengthJSON []byte, condsJSON []byte) error { if gzipId <= 0 { return errors.New("invalid gzipId") } @@ -155,8 +155,8 @@ func (this *HTTPGzipDAO) UpdateGzip(gzipId int64, level int, minLengthJSON []byt if len(maxLengthJSON) > 0 { op.MaxLength = JSONBytes(maxLengthJSON) } - if len(condGroupsJSON) > 0 { - op.CondGroups = JSONBytes(condGroupsJSON) + if len(condsJSON) > 0 { + op.Conds = JSONBytes(condsJSON) } _, err := this.Save(op) return err diff --git a/internal/db/models/http_gzip_model.go b/internal/db/models/http_gzip_model.go index 7a9441c7..00f5bc1a 100644 --- a/internal/db/models/http_gzip_model.go +++ b/internal/db/models/http_gzip_model.go @@ -2,29 +2,29 @@ package models // Gzip配置 type HTTPGzip struct { - Id uint32 `field:"id"` // ID - AdminId uint32 `field:"adminId"` // 管理员ID - UserId uint32 `field:"userId"` // 用户ID - IsOn uint8 `field:"isOn"` // 是否启用 - Level uint32 `field:"level"` // 压缩级别 - MinLength string `field:"minLength"` // 可压缩最小值 - MaxLength string `field:"maxLength"` // 可压缩最大值 - State uint8 `field:"state"` // 状态 - CreatedAt uint64 `field:"createdAt"` // 创建时间 - CondGroups string `field:"condGroups"` // 条件 + Id uint32 `field:"id"` // ID + AdminId uint32 `field:"adminId"` // 管理员ID + UserId uint32 `field:"userId"` // 用户ID + IsOn uint8 `field:"isOn"` // 是否启用 + Level uint32 `field:"level"` // 压缩级别 + MinLength string `field:"minLength"` // 可压缩最小值 + MaxLength string `field:"maxLength"` // 可压缩最大值 + State uint8 `field:"state"` // 状态 + CreatedAt uint64 `field:"createdAt"` // 创建时间 + Conds string `field:"conds"` // 条件 } type HTTPGzipOperator struct { - Id interface{} // ID - AdminId interface{} // 管理员ID - UserId interface{} // 用户ID - IsOn interface{} // 是否启用 - Level interface{} // 压缩级别 - MinLength interface{} // 可压缩最小值 - MaxLength interface{} // 可压缩最大值 - State interface{} // 状态 - CreatedAt interface{} // 创建时间 - CondGroups interface{} // 条件 + Id interface{} // ID + AdminId interface{} // 管理员ID + UserId interface{} // 用户ID + IsOn interface{} // 是否启用 + Level interface{} // 压缩级别 + MinLength interface{} // 可压缩最小值 + MaxLength interface{} // 可压缩最大值 + State interface{} // 状态 + CreatedAt interface{} // 创建时间 + Conds interface{} // 条件 } func NewHTTPGzipOperator() *HTTPGzipOperator { diff --git a/internal/db/models/http_location_model.go b/internal/db/models/http_location_model.go index 95b971fb..abf4c30a 100644 --- a/internal/db/models/http_location_model.go +++ b/internal/db/models/http_location_model.go @@ -17,7 +17,7 @@ type HTTPLocation struct { ReverseProxy string `field:"reverseProxy"` // 反向代理 UrlPrefix string `field:"urlPrefix"` // URL前缀 IsBreak uint8 `field:"isBreak"` // 是否终止匹配 - CondGroups string `field:"condGroups"` // 匹配条件 + Conds string `field:"conds"` // 匹配条件 } type HTTPLocationOperator struct { @@ -36,7 +36,7 @@ type HTTPLocationOperator struct { ReverseProxy interface{} // 反向代理 UrlPrefix interface{} // URL前缀 IsBreak interface{} // 是否终止匹配 - CondGroups interface{} // 匹配条件 + Conds interface{} // 匹配条件 } func NewHTTPLocationOperator() *HTTPLocationOperator { diff --git a/internal/db/models/http_rewrite_rule_model.go b/internal/db/models/http_rewrite_rule_model.go index 91c38423..546b855d 100644 --- a/internal/db/models/http_rewrite_rule_model.go +++ b/internal/db/models/http_rewrite_rule_model.go @@ -16,6 +16,7 @@ type HTTPRewriteRule struct { ProxyHost string `field:"proxyHost"` // 代理的主机名 IsBreak uint8 `field:"isBreak"` // 是否终止解析 WithQuery uint8 `field:"withQuery"` // 是否保留URI参数 + Conds string `field:"conds"` // 匹配条件 } type HTTPRewriteRuleOperator struct { @@ -33,6 +34,7 @@ type HTTPRewriteRuleOperator struct { ProxyHost interface{} // 代理的主机名 IsBreak interface{} // 是否终止解析 WithQuery interface{} // 是否保留URI参数 + Conds interface{} // 匹配条件 } func NewHTTPRewriteRuleOperator() *HTTPRewriteRuleOperator { diff --git a/internal/rpc/services/service_http_access_log_policy.go b/internal/rpc/services/service_http_access_log_policy.go index 90624abf..80b2a617 100644 --- a/internal/rpc/services/service_http_access_log_policy.go +++ b/internal/rpc/services/service_http_access_log_policy.go @@ -31,7 +31,7 @@ func (this *HTTPAccessLogPolicyService) FindAllEnabledHTTPAccessLogPolicies(ctx IsOn: policy.IsOn == 1, Type: policy.Name, OptionsJSON: []byte(policy.Options), - CondsJSON: []byte(policy.CondGroups), + CondsJSON: []byte(policy.Conds), }) } diff --git a/internal/rpc/services/sevice_http_gzip.go b/internal/rpc/services/sevice_http_gzip.go index 13933479..efbd1854 100644 --- a/internal/rpc/services/sevice_http_gzip.go +++ b/internal/rpc/services/sevice_http_gzip.go @@ -42,7 +42,7 @@ func (this *HTTPGzipService) CreateHTTPGzip(ctx context.Context, req *pb.CreateH } } - gzipId, err := models.SharedHTTPGzipDAO.CreateGzip(int(req.Level), minLengthJSON, maxLengthJSON, req.CondGroupsJSON) + gzipId, err := models.SharedHTTPGzipDAO.CreateGzip(int(req.Level), minLengthJSON, maxLengthJSON, req.CondsJSON) if err != nil { return nil, err } @@ -100,7 +100,7 @@ func (this *HTTPGzipService) UpdateHTTPGzip(ctx context.Context, req *pb.UpdateH } } - err = models.SharedHTTPGzipDAO.UpdateGzip(req.GzipId, int(req.Level), minLengthJSON, maxLengthJSON, req.CondGroupsJSON) + err = models.SharedHTTPGzipDAO.UpdateGzip(req.GzipId, int(req.Level), minLengthJSON, maxLengthJSON, req.CondsJSON) if err != nil { return nil, err }