diff --git a/configuration/tcp_request_rule.go b/configuration/tcp_request_rule.go index 450490a1..35254b32 100644 --- a/configuration/tcp_request_rule.go +++ b/configuration/tcp_request_rule.go @@ -350,6 +350,13 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.SetVar: + rule.Action = models.TCPRequestRuleActionSetDashVar + rule.VarScope = a.VarScope + rule.VarName = a.VarName + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest case *actions.SetVarFmt: rule.Action = models.TCPRequestRuleActionSetDashVarDashFmt rule.VarName = a.VarName @@ -397,12 +404,12 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.Cond = a.Cond rule.CondTest = a.CondTest case *actions.SetPriorityClass: - rule.Action = "set-priority-class" + rule.Action = models.TCPRequestRuleActionSetDashPriorityDashClass rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest case *actions.SetPriorityOffset: - rule.Action = "set-priority-offset" + rule.Action = models.TCPRequestRuleActionSetDashPriorityDashOffset rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest @@ -456,6 +463,16 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest + case *tcp_actions.SetSrc: + rule.Action = models.TCPRequestRuleActionSetDashSrc + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *actions.SetSrcPort: + rule.Action = models.TCPRequestRuleActionSetDashSrcDashPort + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest case *actions.SetVar: rule.Action = models.TCPRequestRuleActionSetDashVar rule.VarScope = a.VarScope @@ -522,11 +539,6 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest - case *actions.SetSrcPort: - rule.Action = models.TCPRequestRuleActionSetDashSrcDashPort - rule.Expr = a.Expr.String() - rule.Cond = a.Cond - rule.CondTest = a.CondTest case *actions.SetTos: rule.Action = models.TCPRequestRuleActionSetDashTos rule.TosValue = a.Value @@ -619,6 +631,36 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.GptValue = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.SetDst: + rule.Action = models.TCPRequestRuleActionSetDashDst + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *actions.SetDstPort: + rule.Action = models.TCPRequestRuleActionSetDashDstDashPort + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *actions.SetMark: + rule.Action = models.TCPRequestRuleActionSetDashMark + rule.MarkValue = a.Value + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *tcp_actions.SetSrc: + rule.Action = models.TCPRequestRuleActionSetDashSrc + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *actions.SetSrcPort: + rule.Action = models.TCPRequestRuleActionSetDashSrcDashPort + rule.Expr = a.Expr.String() + rule.Cond = a.Cond + rule.CondTest = a.CondTest + case *actions.SetTos: + rule.Action = models.TCPRequestRuleActionSetDashTos + rule.TosValue = a.Value + rule.Cond = a.Cond + rule.CondTest = a.CondTest case *actions.SetFcMark: rule.Action = models.TCPRequestRuleActionSetDashFcDashMark rule.Expr = a.Expr.String() @@ -642,6 +684,13 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.VarName = a.Name rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.SetVarFmt: + rule.Action = models.TCPRequestRuleActionSetDashVarDashFmt + rule.VarName = a.VarName + rule.VarFormat = strings.Join(a.Fmt.Expr, " ") + rule.VarScope = a.VarScope + rule.Cond = a.Cond + rule.CondTest = a.CondTest case *actions.SilentDrop: rule.Action = models.TCPRequestRuleActionSilentDashDrop rule.Cond = a.Cond @@ -828,6 +877,25 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashVar: + return &tcp_types.Connection{ + Action: &actions.SetVar{ + VarName: f.VarName, + VarScope: f.VarScope, + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionUnsetDashVar: + return &tcp_types.Connection{ + Action: &actions.UnsetVar{ + Name: f.VarName, + Scope: f.VarScope, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil case models.TCPRequestRuleActionSetDashVarDashFmt: return &tcp_types.Connection{ Action: &actions.SetVarFmt{ @@ -854,6 +922,14 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashDstDashPort: + return &tcp_types.Connection{ + Action: &actions.SetDstPort{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil case models.TCPRequestRuleActionSetDashFcDashMark: return &tcp_types.Connection{ Action: &actions.SetFcMark{ @@ -908,7 +984,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil - case "set-priority-class": + case models.TCPRequestRuleActionSetDashPriorityDashClass: return &tcp_types.Content{ Action: &actions.SetPriorityClass{ Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, @@ -916,7 +992,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil - case "set-priority-offset": + case models.TCPRequestRuleActionSetDashPriorityDashOffset: return &tcp_types.Content{ Action: &actions.SetPriorityOffset{ Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, @@ -972,7 +1048,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionScDashAddDashGpc: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.ScAddGpc{ ID: f.ScIncID, Idx: f.ScIdx, @@ -983,7 +1059,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionScDashIncDashGpc: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.ScIncGpc{ ID: f.ScIncID, Idx: f.ScIdx, @@ -1008,7 +1084,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionScDashSetDashGpt0: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.ScSetGpt0{ ID: f.ScIncID, Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, @@ -1032,6 +1108,14 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashSrc: + return &tcp_types.Content{ + Action: &http_actions.SetSrc{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil case models.TCPRequestRuleActionSetDashVar: return &tcp_types.Content{ Action: &actions.SetVar{ @@ -1095,7 +1179,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashMark: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetMark{ Value: f.MarkValue, Cond: f.Cond, @@ -1103,7 +1187,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashSrcDashPort: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetSrcPort{ Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, Cond: f.Cond, @@ -1111,7 +1195,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashTos: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetTos{ Value: f.TosValue, Cond: f.Cond, @@ -1119,7 +1203,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashVarDashFmt: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetVarFmt{ Fmt: common.Expression{Expr: strings.Split(f.VarFormat, " ")}, VarName: f.VarName, @@ -1129,7 +1213,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashNice: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetNice{ Value: strconv.FormatInt(f.NiceValue, 10), Cond: f.Cond, @@ -1137,7 +1221,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSetDashLogDashLevel: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &actions.SetLogLevel{ Level: f.LogLevel, Cond: f.Cond, @@ -1145,7 +1229,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e }, }, nil case models.TCPRequestRuleActionSwitchDashMode: - return &tcp_types.Connection{ + return &tcp_types.Content{ Action: &tcp_actions.SwitchMode{ Proto: f.SwitchModeProto, Cond: f.Cond, @@ -1294,24 +1378,63 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil - case "sc-inc-gpt0": + case models.TCPRequestRuleActionScDashSetDashGpt0: return &tcp_types.Session{ Action: &actions.ScSetGpt0{ ID: f.ScIncID, - Expr: common.Expression{Expr: []string{f.GptValue}}, + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, Cond: f.Cond, CondTest: f.CondTest, }, }, nil - case models.TCPRequestRuleActionScDashSetDashGpt0: - return &tcp_types.Connection{ - Action: &actions.ScSetGpt0{ - ID: f.ScIncID, + case models.TCPRequestRuleActionSetDashDst: + return &tcp_types.Session{ + Action: &actions.SetDst{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashDstDashPort: + return &tcp_types.Session{ + Action: &actions.SetDstPort{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashSrc: + return &tcp_types.Session{ + Action: &http_actions.SetSrc{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashSrcDashPort: + return &tcp_types.Session{ + Action: &actions.SetSrcPort{ Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, Cond: f.Cond, CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashMark: + return &tcp_types.Session{ + Action: &actions.SetDstPort{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashTos: + return &tcp_types.Session{ + Action: &actions.SetTos{ + Value: f.TosValue, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil case models.TCPRequestRuleActionSetDashVar: return &tcp_types.Session{ Action: &actions.SetVar{ @@ -1331,6 +1454,16 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashVarDashFmt: + return &tcp_types.Session{ + Action: &actions.SetVarFmt{ + Fmt: common.Expression{Expr: strings.Split(f.VarFormat, " ")}, + VarName: f.VarName, + VarScope: f.VarScope, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil case models.TCPRequestRuleActionSilentDashDrop: return &tcp_types.Session{ Action: &actions.SilentDrop{ diff --git a/configuration/tcp_response_rule.go b/configuration/tcp_response_rule.go index b5053f4b..44986798 100644 --- a/configuration/tcp_response_rule.go +++ b/configuration/tcp_response_rule.go @@ -370,6 +370,24 @@ func ParseTCPResponseRule(t types.TCPType) (*models.TCPResponseRule, error) { Cond: a.Cond, CondTest: a.CondTest, }, nil + case *actions.SetVar: + return &models.TCPResponseRule{ + Action: models.TCPResponseRuleActionSetDashVar, + VarScope: a.VarScope, + VarName: a.VarName, + Expr: a.Expr.String(), + Cond: a.Cond, + CondTest: a.CondTest, + }, nil + case *actions.SetVarFmt: + return &models.TCPResponseRule{ + Action: models.TCPResponseRuleActionSetDashVarDashFmt, + VarName: a.VarName, + VarFormat: strings.Join(a.Fmt.Expr, " "), + VarScope: a.VarScope, + Cond: a.Cond, + CondTest: a.CondTest, + }, nil case *actions.UnsetVar: return &models.TCPResponseRule{ Type: models.TCPResponseRuleTypeContent, @@ -384,7 +402,7 @@ func ParseTCPResponseRule(t types.TCPType) (*models.TCPResponseRule, error) { return nil, NewConfError(ErrValidationError, "invalid action") } -func SerializeTCPResponseRule(t models.TCPResponseRule) (types.TCPType, error) { +func SerializeTCPResponseRule(t models.TCPResponseRule) (types.TCPType, error) { //nolint:maintidx switch t.Type { case models.TCPResponseRuleTypeContent: switch t.Action { @@ -534,6 +552,26 @@ func SerializeTCPResponseRule(t models.TCPResponseRule) (types.TCPType, error) { CondTest: t.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashVarDashFmt: + return &tcp_types.Content{ + Action: &actions.SetVarFmt{ + Fmt: common.Expression{Expr: strings.Split(t.VarFormat, " ")}, + VarName: t.VarName, + VarScope: t.VarScope, + Cond: t.Cond, + CondTest: t.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashVar: + return &tcp_types.Content{ + Action: &actions.SetVar{ + VarName: t.VarName, + VarScope: t.VarScope, + Expr: common.Expression{Expr: strings.Split(t.Expr, " ")}, + Cond: t.Cond, + CondTest: t.CondTest, + }, + }, nil case models.TCPResponseRuleActionUnsetDashVar: return &tcp_types.Content{ Action: &actions.UnsetVar{ diff --git a/models/tcp_request_rule.go b/models/tcp_request_rule.go index 554527f8..5f711900 100644 --- a/models/tcp_request_rule.go +++ b/models/tcp_request_rule.go @@ -38,8 +38,8 @@ import ( // swagger:model tcp_request_rule type TCPRequestRule struct { // action - // Enum: [accept attach-srv capture do-resolve expect-netscaler-cip expect-proxy lua reject sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 set-bandwidth-limit set-bc-mark set-bc-tos set-dst-port set-dst set-fc-mark set-fc-tos set-log-level set-mark set-nice set-priority set-src set-src-port set-tos set-var set-var-fmt send-spoe-group silent-drop switch-mode track-sc0 track-sc1 track-sc2 track-sc unset-var use-service] - // +kubebuilder:validation:Enum=accept;attach-srv;capture;do-resolve;expect-netscaler-cip;expect-proxy;lua;reject;sc-add-gpc;sc-inc-gpc;sc-inc-gpc0;sc-inc-gpc1;sc-set-gpt0;set-bandwidth-limit;set-bc-mark;set-bc-tos;set-dst-port;set-dst;set-fc-mark;set-fc-tos;set-log-level;set-mark;set-nice;set-priority;set-src;set-src-port;set-tos;set-var;set-var-fmt;send-spoe-group;silent-drop;switch-mode;track-sc0;track-sc1;track-sc2;track-sc;unset-var;use-service; + // Enum: [accept attach-srv capture do-resolve expect-netscaler-cip expect-proxy lua reject sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 send-spoe-group set-bandwidth-limit set-bc-mark set-bc-tos set-dst-port set-dst set-fc-mark set-fc-tos set-log-level set-mark set-nice set-priority-class set-priority-offset set-src set-src-port set-tos set-var set-var-fmt silent-drop switch-mode track-sc0 track-sc1 track-sc2 track-sc unset-var use-service] + // +kubebuilder:validation:Enum=accept;attach-srv;capture;do-resolve;expect-netscaler-cip;expect-proxy;lua;reject;sc-add-gpc;sc-inc-gpc;sc-inc-gpc0;sc-inc-gpc1;sc-set-gpt0;send-spoe-group;set-bandwidth-limit;set-bc-mark;set-bc-tos;set-dst-port;set-dst;set-fc-mark;set-fc-tos;set-log-level;set-mark;set-nice;set-priority-class;set-priority-offset;set-src;set-src-port;set-tos;set-var;set-var-fmt;silent-drop;switch-mode;track-sc0;track-sc1;track-sc2;track-sc;unset-var;use-service; Action string `json:"action,omitempty"` // bandwidth limit limit @@ -102,11 +102,6 @@ type TCPRequestRule struct { // +kubebuilder:validation:Minimum=-1024 NiceValue int64 `json:"nice_value,omitempty"` - // priority type - // Enum: [class offset] - // +kubebuilder:validation:Enum=class;offset; - PriorityType string `json:"priority_type,omitempty"` - // resolve protocol // Enum: [ipv4 ipv6] // +kubebuilder:validation:Enum=ipv4;ipv6; @@ -215,10 +210,6 @@ func (m *TCPRequestRule) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validatePriorityType(formats); err != nil { - res = append(res, err) - } - if err := m.validateResolveProtocol(formats); err != nil { res = append(res, err) } @@ -249,7 +240,7 @@ var tcpRequestRuleTypeActionPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["accept","attach-srv","capture","do-resolve","expect-netscaler-cip","expect-proxy","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","set-bandwidth-limit","set-bc-mark","set-bc-tos","set-dst-port","set-dst","set-fc-mark","set-fc-tos","set-log-level","set-mark","set-nice","set-priority","set-src","set-src-port","set-tos","set-var","set-var-fmt","send-spoe-group","silent-drop","switch-mode","track-sc0","track-sc1","track-sc2","track-sc","unset-var","use-service"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["accept","attach-srv","capture","do-resolve","expect-netscaler-cip","expect-proxy","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","send-spoe-group","set-bandwidth-limit","set-bc-mark","set-bc-tos","set-dst-port","set-dst","set-fc-mark","set-fc-tos","set-log-level","set-mark","set-nice","set-priority-class","set-priority-offset","set-src","set-src-port","set-tos","set-var","set-var-fmt","silent-drop","switch-mode","track-sc0","track-sc1","track-sc2","track-sc","unset-var","use-service"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -298,6 +289,9 @@ const ( // TCPRequestRuleActionScDashSetDashGpt0 captures enum value "sc-set-gpt0" TCPRequestRuleActionScDashSetDashGpt0 string = "sc-set-gpt0" + // TCPRequestRuleActionSendDashSpoeDashGroup captures enum value "send-spoe-group" + TCPRequestRuleActionSendDashSpoeDashGroup string = "send-spoe-group" + // TCPRequestRuleActionSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" TCPRequestRuleActionSetDashBandwidthDashLimit string = "set-bandwidth-limit" @@ -328,8 +322,11 @@ const ( // TCPRequestRuleActionSetDashNice captures enum value "set-nice" TCPRequestRuleActionSetDashNice string = "set-nice" - // TCPRequestRuleActionSetDashPriority captures enum value "set-priority" - TCPRequestRuleActionSetDashPriority string = "set-priority" + // TCPRequestRuleActionSetDashPriorityDashClass captures enum value "set-priority-class" + TCPRequestRuleActionSetDashPriorityDashClass string = "set-priority-class" + + // TCPRequestRuleActionSetDashPriorityDashOffset captures enum value "set-priority-offset" + TCPRequestRuleActionSetDashPriorityDashOffset string = "set-priority-offset" // TCPRequestRuleActionSetDashSrc captures enum value "set-src" TCPRequestRuleActionSetDashSrc string = "set-src" @@ -346,9 +343,6 @@ const ( // TCPRequestRuleActionSetDashVarDashFmt captures enum value "set-var-fmt" TCPRequestRuleActionSetDashVarDashFmt string = "set-var-fmt" - // TCPRequestRuleActionSendDashSpoeDashGroup captures enum value "send-spoe-group" - TCPRequestRuleActionSendDashSpoeDashGroup string = "send-spoe-group" - // TCPRequestRuleActionSilentDashDrop captures enum value "silent-drop" TCPRequestRuleActionSilentDashDrop string = "silent-drop" @@ -561,48 +555,6 @@ func (m *TCPRequestRule) validateNiceValue(formats strfmt.Registry) error { return nil } -var tcpRequestRuleTypePriorityTypePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["class","offset"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - tcpRequestRuleTypePriorityTypePropEnum = append(tcpRequestRuleTypePriorityTypePropEnum, v) - } -} - -const ( - - // TCPRequestRulePriorityTypeClass captures enum value "class" - TCPRequestRulePriorityTypeClass string = "class" - - // TCPRequestRulePriorityTypeOffset captures enum value "offset" - TCPRequestRulePriorityTypeOffset string = "offset" -) - -// prop value enum -func (m *TCPRequestRule) validatePriorityTypeEnum(path, location string, value string) error { - if err := validate.EnumCase(path, location, value, tcpRequestRuleTypePriorityTypePropEnum, true); err != nil { - return err - } - return nil -} - -func (m *TCPRequestRule) validatePriorityType(formats strfmt.Registry) error { - if swag.IsZero(m.PriorityType) { // not required - return nil - } - - // value enum - if err := m.validatePriorityTypeEnum("priority_type", "body", m.PriorityType); err != nil { - return err - } - - return nil -} - var tcpRequestRuleTypeResolveProtocolPropEnum []interface{} func init() { diff --git a/models/tcp_request_rule_compare.go b/models/tcp_request_rule_compare.go index 834505eb..b4a0980b 100644 --- a/models/tcp_request_rule_compare.go +++ b/models/tcp_request_rule_compare.go @@ -97,10 +97,6 @@ func (s TCPRequestRule) Equal(t TCPRequestRule, opts ...Options) bool { return false } - if s.PriorityType != t.PriorityType { - return false - } - if s.ResolveProtocol != t.ResolveProtocol { return false } @@ -265,10 +261,6 @@ func (s TCPRequestRule) Diff(t TCPRequestRule, opts ...Options) map[string][]int diff["NiceValue"] = []interface{}{s.NiceValue, t.NiceValue} } - if s.PriorityType != t.PriorityType { - diff["PriorityType"] = []interface{}{s.PriorityType, t.PriorityType} - } - if s.ResolveProtocol != t.ResolveProtocol { diff["ResolveProtocol"] = []interface{}{s.ResolveProtocol, t.ResolveProtocol} } diff --git a/models/tcp_request_rule_compare_test.go b/models/tcp_request_rule_compare_test.go index 03c5c0e3..c4b398ce 100644 --- a/models/tcp_request_rule_compare_test.go +++ b/models/tcp_request_rule_compare_test.go @@ -181,7 +181,7 @@ func TestTCPRequestRuleDiffFalse(t *testing.T) { for _, sample := range samples { result := sample.a.Diff(sample.b) - if len(result) != 37-1 { + if len(result) != 36-1 { json := jsoniter.ConfigCompatibleWithStandardLibrary a, err := json.Marshal(&sample.a) if err != nil { @@ -191,7 +191,7 @@ func TestTCPRequestRuleDiffFalse(t *testing.T) { if err != nil { t.Errorf(err.Error()) } - t.Errorf("Expected TCPRequestRule to be different in 37 cases, but it is not (%d) %s %s", len(result), a, b) + t.Errorf("Expected TCPRequestRule to be different in 36 cases, but it is not (%d) %s %s", len(result), a, b) } } } diff --git a/models/tcp_response_rule.go b/models/tcp_response_rule.go index bbe25693..16d3c46a 100644 --- a/models/tcp_response_rule.go +++ b/models/tcp_response_rule.go @@ -38,8 +38,8 @@ import ( // swagger:model tcp_response_rule type TCPResponseRule struct { // action - // Enum: [accept close lua reject sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 send-spoe-group set-bandwidth-limit set-fc-mark set-fc-tos set-log-level set-mark set-nice set-tos silent-drop unset-var] - // +kubebuilder:validation:Enum=accept;close;lua;reject;sc-add-gpc;sc-inc-gpc;sc-inc-gpc0;sc-inc-gpc1;sc-set-gpt0;send-spoe-group;set-bandwidth-limit;set-fc-mark;set-fc-tos;set-log-level;set-mark;set-nice;set-tos;silent-drop;unset-var; + // Enum: [accept close lua reject sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 send-spoe-group set-bandwidth-limit set-fc-mark set-fc-tos set-log-level set-mark set-nice set-tos set-var set-var-fmt silent-drop unset-var] + // +kubebuilder:validation:Enum=accept;close;lua;reject;sc-add-gpc;sc-inc-gpc;sc-inc-gpc0;sc-inc-gpc1;sc-set-gpt0;send-spoe-group;set-bandwidth-limit;set-fc-mark;set-fc-tos;set-log-level;set-mark;set-nice;set-tos;set-var;set-var-fmt;silent-drop;unset-var; Action string `json:"action,omitempty"` // bandwidth limit limit @@ -127,6 +127,9 @@ type TCPResponseRule struct { // +kubebuilder:validation:Enum=content;inspect-delay; Type string `json:"type"` + // var format + VarFormat string `json:"var_format,omitempty"` + // var name // Pattern: ^[^\s]+$ // +kubebuilder:validation:Pattern=`^[^\s]+$` @@ -204,7 +207,7 @@ var tcpResponseRuleTypeActionPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["accept","close","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","send-spoe-group","set-bandwidth-limit","set-fc-mark","set-fc-tos","set-log-level","set-mark","set-nice","set-tos","silent-drop","unset-var"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["accept","close","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","send-spoe-group","set-bandwidth-limit","set-fc-mark","set-fc-tos","set-log-level","set-mark","set-nice","set-tos","set-var","set-var-fmt","silent-drop","unset-var"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -265,6 +268,12 @@ const ( // TCPResponseRuleActionSetDashTos captures enum value "set-tos" TCPResponseRuleActionSetDashTos string = "set-tos" + // TCPResponseRuleActionSetDashVar captures enum value "set-var" + TCPResponseRuleActionSetDashVar string = "set-var" + + // TCPResponseRuleActionSetDashVarDashFmt captures enum value "set-var-fmt" + TCPResponseRuleActionSetDashVarDashFmt string = "set-var-fmt" + // TCPResponseRuleActionSilentDashDrop captures enum value "silent-drop" TCPResponseRuleActionSilentDashDrop string = "silent-drop" diff --git a/models/tcp_response_rule_compare.go b/models/tcp_response_rule_compare.go index ff1e7a96..6a191d71 100644 --- a/models/tcp_response_rule_compare.go +++ b/models/tcp_response_rule_compare.go @@ -121,6 +121,10 @@ func (s TCPResponseRule) Equal(t TCPResponseRule, opts ...Options) bool { return false } + if s.VarFormat != t.VarFormat { + return false + } + if s.VarName != t.VarName { return false } @@ -237,6 +241,10 @@ func (s TCPResponseRule) Diff(t TCPResponseRule, opts ...Options) map[string][]i diff["Type"] = []interface{}{s.Type, t.Type} } + if s.VarFormat != t.VarFormat { + diff["VarFormat"] = []interface{}{s.VarFormat, t.VarFormat} + } + if s.VarName != t.VarName { diff["VarName"] = []interface{}{s.VarName, t.VarName} } diff --git a/models/tcp_response_rule_compare_test.go b/models/tcp_response_rule_compare_test.go index 8ae39544..68b71827 100644 --- a/models/tcp_response_rule_compare_test.go +++ b/models/tcp_response_rule_compare_test.go @@ -181,7 +181,7 @@ func TestTCPResponseRuleDiffFalse(t *testing.T) { for _, sample := range samples { result := sample.a.Diff(sample.b) - if len(result) != 24-1 { + if len(result) != 25-1 { json := jsoniter.ConfigCompatibleWithStandardLibrary a, err := json.Marshal(&sample.a) if err != nil { @@ -191,7 +191,7 @@ func TestTCPResponseRuleDiffFalse(t *testing.T) { if err != nil { t.Errorf(err.Error()) } - t.Errorf("Expected TCPResponseRule to be different in 24 cases, but it is not (%d) %s %s", len(result), a, b) + t.Errorf("Expected TCPResponseRule to be different in 25 cases, but it is not (%d) %s %s", len(result), a, b) } } } diff --git a/specification/build/haproxy_spec.yaml b/specification/build/haproxy_spec.yaml index fbd296f7..f5590ae4 100644 --- a/specification/build/haproxy_spec.yaml +++ b/specification/build/haproxy_spec.yaml @@ -5675,6 +5675,7 @@ definitions: - sc-inc-gpc0 - sc-inc-gpc1 - sc-set-gpt0 + - send-spoe-group - set-bandwidth-limit - set-bc-mark - set-bc-tos @@ -5685,13 +5686,13 @@ definitions: - set-log-level - set-mark - set-nice - - set-priority + - set-priority-class + - set-priority-offset - set-src - set-src-port - set-tos - set-var - set-var-fmt - - send-spoe-group - silent-drop - switch-mode - track-sc0 @@ -5799,7 +5800,8 @@ definitions: - set-dst-port - set-fc-mark - set-fc-tos - - set-priority + - set-priority-class + - set-priority-offset - set-src - set-src-port - set-var @@ -5889,18 +5891,6 @@ definitions: value: content x-display-name: Nice Value x-nullable: false - priority_type: - enum: - - class - - offset - type: string - x-dependency: - action: - required: true - value: set-priority - type: - value: - - content resolve_protocol: enum: - ipv4 @@ -6185,6 +6175,8 @@ definitions: - set-mark - set-nice - set-tos + - set-var + - set-var-fmt - silent-drop - unset-var type: string @@ -6401,6 +6393,15 @@ definitions: - inspect-delay type: string x-nullable: false + var_format: + type: string + x-dependency: + action: + required: true + value: set-var-fmt + type: + value: content + x-display-name: Var Format var_name: pattern: ^[^\s]+$ type: string diff --git a/specification/models/configuration/tcp/request.yaml b/specification/models/configuration/tcp/request.yaml index b95c2ec6..44f8dbeb 100644 --- a/specification/models/configuration/tcp/request.yaml +++ b/specification/models/configuration/tcp/request.yaml @@ -30,6 +30,7 @@ tcp_request_rule: - sc-inc-gpc0 - sc-inc-gpc1 - sc-set-gpt0 + - send-spoe-group - set-bandwidth-limit - set-bc-mark - set-bc-tos @@ -40,13 +41,13 @@ tcp_request_rule: - set-log-level - set-mark - set-nice - - set-priority + - set-priority-class + - set-priority-offset - set-src - set-src-port - set-tos - set-var - set-var-fmt - - send-spoe-group - silent-drop - switch-mode - track-sc0 @@ -170,15 +171,6 @@ tcp_request_rule: type: value: [content] required: true - priority_type: - type: string - enum: [class, offset] - x-dependency: - action: - value: set-priority - required: true - type: - value: [content] var_name: type: string pattern: '^[^\s]+$' @@ -274,7 +266,8 @@ tcp_request_rule: - set-dst-port - set-fc-mark - set-fc-tos - - set-priority + - set-priority-class + - set-priority-offset - set-src - set-src-port - set-var @@ -334,7 +327,7 @@ tcp_request_rule: value: content mark_value: type: string - pattern: '^(0x[0-9A-Fa-f]+|[0-9]+)$' + pattern: "^(0x[0-9A-Fa-f]+|[0-9]+)$" x-display-name: Mark Value x-dependency: action: @@ -356,7 +349,7 @@ tcp_request_rule: value: content tos_value: type: string - pattern: '^(0x[0-9A-Fa-f]+|[0-9]+)$' + pattern: "^(0x[0-9A-Fa-f]+|[0-9]+)$" x-display-name: Tos Value x-dependency: action: diff --git a/specification/models/configuration/tcp/response.yaml b/specification/models/configuration/tcp/response.yaml index f9cede2b..798650e3 100644 --- a/specification/models/configuration/tcp/response.yaml +++ b/specification/models/configuration/tcp/response.yaml @@ -34,6 +34,8 @@ tcp_response_rule: - set-mark - set-nice - set-tos + - set-var + - set-var-fmt - silent-drop - unset-var x-nullable: false @@ -165,7 +167,7 @@ tcp_response_rule: value: content mark_value: type: string - pattern: '^(0x[0-9A-Fa-f]+|[0-9]+)$' + pattern: "^(0x[0-9A-Fa-f]+|[0-9]+)$" x-display-name: Mark Value x-dependency: action: @@ -187,7 +189,7 @@ tcp_response_rule: value: content tos_value: type: string - pattern: '^(0x[0-9A-Fa-f]+|[0-9]+)$' + pattern: "^(0x[0-9A-Fa-f]+|[0-9]+)$" x-display-name: Tos Value x-dependency: action: @@ -212,6 +214,15 @@ tcp_response_rule: value: unset-var type: value: content + var_format: + type: string + x-display-name: Var Format + x-dependency: + action: + value: set-var-fmt + required: true + type: + value: content cond: type: string x-display-name: Condition