From 784a622cc38ee7fca9c12102f2faf30fafe29b4e Mon Sep 17 00:00:00 2001 From: Marko Juraga Date: Tue, 26 Mar 2024 14:23:41 +0100 Subject: [PATCH] BUG/MEDIUM: tcp_request_rule: add all missing actions --- configuration/tcp_request_rule.go | 190 +++++++++++++++--- configuration/tcp_response_rule.go | 40 +++- models/tcp_request_rule.go | 130 +++++------- models/tcp_response_rule.go | 33 ++- specification/build/haproxy_spec.yaml | 68 ++++--- .../models/configuration/tcp/request.yaml | 68 +++++-- .../models/configuration/tcp/response.yaml | 36 +++- 7 files changed, 405 insertions(+), 160 deletions(-) diff --git a/configuration/tcp_request_rule.go b/configuration/tcp_request_rule.go index e32d146e..5287aa3d 100644 --- a/configuration/tcp_request_rule.go +++ b/configuration/tcp_request_rule.go @@ -340,6 +340,20 @@ 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 + rule.VarFormat = strings.Join(a.Fmt.Expr, " ") + rule.VarScope = a.VarScope + rule.Cond = a.Cond + rule.CondTest = a.CondTest case *actions.UnsetVar: rule.Action = models.TCPRequestRuleActionUnsetDashVar rule.VarScope = a.Scope @@ -380,12 +394,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 @@ -439,6 +453,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 @@ -485,11 +509,6 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro rule.MarkValue = a.Value 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 @@ -576,6 +595,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.SetVar: rule.Action = models.TCPRequestRuleActionSetDashVar rule.VarScope = a.VarScope @@ -589,6 +638,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 @@ -775,6 +831,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{ @@ -801,6 +876,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 } return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", f.Action)) case models.TCPRequestRuleTypeContent: @@ -839,7 +922,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, " ")}, @@ -847,7 +930,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, " ")}, @@ -903,7 +986,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, @@ -914,7 +997,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, @@ -939,7 +1022,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, " ")}, @@ -963,6 +1046,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{ @@ -1026,7 +1117,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, @@ -1034,7 +1125,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, @@ -1042,7 +1133,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, @@ -1050,7 +1141,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, @@ -1060,7 +1151,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, @@ -1068,7 +1159,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, @@ -1076,7 +1167,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, @@ -1184,24 +1275,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{ @@ -1221,6 +1351,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 f977e2f5..6f910c42 100644 --- a/configuration/tcp_response_rule.go +++ b/configuration/tcp_response_rule.go @@ -187,7 +187,7 @@ func ParseTCPResponseRules(backend string, p parser.Parser) (models.TCPResponseR return tcpResRules, nil } -func ParseTCPResponseRule(t types.TCPType) (*models.TCPResponseRule, error) { +func ParseTCPResponseRule(t types.TCPType) (*models.TCPResponseRule, error) { //nolint:maintidx switch v := t.(type) { case *tcp_types.InspectDelay: return &models.TCPResponseRule{ @@ -353,6 +353,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, @@ -517,6 +535,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 a5d87af6..27237feb 100644 --- a/models/tcp_request_rule.go +++ b/models/tcp_request_rule.go @@ -39,7 +39,7 @@ import ( type TCPRequestRule struct { // action - // Enum: [accept capture do-resolve expect-netscaler-cip expect-proxy reject sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 send-spoe-group set-dst-port set-dst set-priority set-src set-var silent-drop track-sc0 track-sc1 track-sc2 track-sc unset-var use-service lua set-bandwidth-limit set-src-port set-mark set-tos set-var-fmt set-log-level set-nice switch-mode] + // 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 @@ -95,10 +95,6 @@ type TCPRequestRule struct { // Minimum: -1024 NiceValue int64 `json:"nice_value,omitempty"` - // priority type - // Enum: [class offset] - PriorityType string `json:"priority_type,omitempty"` - // resolve protocol // Enum: [ipv4 ipv6] ResolveProtocol string `json:"resolve_protocol,omitempty"` @@ -199,10 +195,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) } @@ -233,7 +225,7 @@ var tcpRequestRuleTypeActionPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["accept","capture","do-resolve","expect-netscaler-cip","expect-proxy","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","send-spoe-group","set-dst-port","set-dst","set-priority","set-src","set-var","silent-drop","track-sc0","track-sc1","track-sc2","track-sc","unset-var","use-service","lua","set-bandwidth-limit","set-src-port","set-mark","set-tos","set-var-fmt","set-log-level","set-nice","switch-mode"]`), &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 { @@ -246,6 +238,9 @@ const ( // TCPRequestRuleActionAccept captures enum value "accept" TCPRequestRuleActionAccept string = "accept" + // TCPRequestRuleActionAttachDashSrv captures enum value "attach-srv" + TCPRequestRuleActionAttachDashSrv string = "attach-srv" + // TCPRequestRuleActionCapture captures enum value "capture" TCPRequestRuleActionCapture string = "capture" @@ -258,6 +253,9 @@ const ( // TCPRequestRuleActionExpectDashProxy captures enum value "expect-proxy" TCPRequestRuleActionExpectDashProxy string = "expect-proxy" + // TCPRequestRuleActionLua captures enum value "lua" + TCPRequestRuleActionLua string = "lua" + // TCPRequestRuleActionReject captures enum value "reject" TCPRequestRuleActionReject string = "reject" @@ -279,24 +277,63 @@ const ( // TCPRequestRuleActionSendDashSpoeDashGroup captures enum value "send-spoe-group" TCPRequestRuleActionSendDashSpoeDashGroup string = "send-spoe-group" + // TCPRequestRuleActionSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" + TCPRequestRuleActionSetDashBandwidthDashLimit string = "set-bandwidth-limit" + + // TCPRequestRuleActionSetDashBcDashMark captures enum value "set-bc-mark" + TCPRequestRuleActionSetDashBcDashMark string = "set-bc-mark" + + // TCPRequestRuleActionSetDashBcDashTos captures enum value "set-bc-tos" + TCPRequestRuleActionSetDashBcDashTos string = "set-bc-tos" + // TCPRequestRuleActionSetDashDstDashPort captures enum value "set-dst-port" TCPRequestRuleActionSetDashDstDashPort string = "set-dst-port" // TCPRequestRuleActionSetDashDst captures enum value "set-dst" TCPRequestRuleActionSetDashDst string = "set-dst" - // TCPRequestRuleActionSetDashPriority captures enum value "set-priority" - TCPRequestRuleActionSetDashPriority string = "set-priority" + // TCPRequestRuleActionSetDashFcDashMark captures enum value "set-fc-mark" + TCPRequestRuleActionSetDashFcDashMark string = "set-fc-mark" + + // TCPRequestRuleActionSetDashFcDashTos captures enum value "set-fc-tos" + TCPRequestRuleActionSetDashFcDashTos string = "set-fc-tos" + + // TCPRequestRuleActionSetDashLogDashLevel captures enum value "set-log-level" + TCPRequestRuleActionSetDashLogDashLevel string = "set-log-level" + + // TCPRequestRuleActionSetDashMark captures enum value "set-mark" + TCPRequestRuleActionSetDashMark string = "set-mark" + + // TCPRequestRuleActionSetDashNice captures enum value "set-nice" + TCPRequestRuleActionSetDashNice string = "set-nice" + + // 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" + // TCPRequestRuleActionSetDashSrcDashPort captures enum value "set-src-port" + TCPRequestRuleActionSetDashSrcDashPort string = "set-src-port" + + // TCPRequestRuleActionSetDashTos captures enum value "set-tos" + TCPRequestRuleActionSetDashTos string = "set-tos" + // TCPRequestRuleActionSetDashVar captures enum value "set-var" TCPRequestRuleActionSetDashVar string = "set-var" + // TCPRequestRuleActionSetDashVarDashFmt captures enum value "set-var-fmt" + TCPRequestRuleActionSetDashVarDashFmt string = "set-var-fmt" + // TCPRequestRuleActionSilentDashDrop captures enum value "silent-drop" TCPRequestRuleActionSilentDashDrop string = "silent-drop" + // TCPRequestRuleActionSwitchDashMode captures enum value "switch-mode" + TCPRequestRuleActionSwitchDashMode string = "switch-mode" + // TCPRequestRuleActionTrackDashSc0 captures enum value "track-sc0" TCPRequestRuleActionTrackDashSc0 string = "track-sc0" @@ -314,33 +351,6 @@ const ( // TCPRequestRuleActionUseDashService captures enum value "use-service" TCPRequestRuleActionUseDashService string = "use-service" - - // TCPRequestRuleActionLua captures enum value "lua" - TCPRequestRuleActionLua string = "lua" - - // TCPRequestRuleActionSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" - TCPRequestRuleActionSetDashBandwidthDashLimit string = "set-bandwidth-limit" - - // TCPRequestRuleActionSetDashSrcDashPort captures enum value "set-src-port" - TCPRequestRuleActionSetDashSrcDashPort string = "set-src-port" - - // TCPRequestRuleActionSetDashMark captures enum value "set-mark" - TCPRequestRuleActionSetDashMark string = "set-mark" - - // TCPRequestRuleActionSetDashTos captures enum value "set-tos" - TCPRequestRuleActionSetDashTos string = "set-tos" - - // TCPRequestRuleActionSetDashVarDashFmt captures enum value "set-var-fmt" - TCPRequestRuleActionSetDashVarDashFmt string = "set-var-fmt" - - // TCPRequestRuleActionSetDashLogDashLevel captures enum value "set-log-level" - TCPRequestRuleActionSetDashLogDashLevel string = "set-log-level" - - // TCPRequestRuleActionSetDashNice captures enum value "set-nice" - TCPRequestRuleActionSetDashNice string = "set-nice" - - // TCPRequestRuleActionSwitchDashMode captures enum value "switch-mode" - TCPRequestRuleActionSwitchDashMode string = "switch-mode" ) // prop value enum @@ -530,48 +540,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_response_rule.go b/models/tcp_response_rule.go index d2ca2283..40fcf449 100644 --- a/models/tcp_response_rule.go +++ b/models/tcp_response_rule.go @@ -39,7 +39,7 @@ import ( type TCPResponseRule struct { // action - // Enum: [accept reject lua set-bandwidth-limit close sc-add-gpc sc-inc-gpc sc-inc-gpc0 sc-inc-gpc1 sc-set-gpt0 send-spoe-group 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] Action string `json:"action,omitempty"` // bandwidth limit limit @@ -117,6 +117,9 @@ type TCPResponseRule struct { // Enum: [content inspect-delay] Type string `json:"type"` + // var format + VarFormat string `json:"var_format,omitempty"` + // var name // Pattern: ^[^\s]+$ VarName string `json:"var_name,omitempty"` @@ -192,7 +195,7 @@ var tcpResponseRuleTypeActionPropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["accept","reject","lua","set-bandwidth-limit","close","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt0","send-spoe-group","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 { @@ -205,17 +208,14 @@ const ( // TCPResponseRuleActionAccept captures enum value "accept" TCPResponseRuleActionAccept string = "accept" - // TCPResponseRuleActionReject captures enum value "reject" - TCPResponseRuleActionReject string = "reject" + // TCPResponseRuleActionClose captures enum value "close" + TCPResponseRuleActionClose string = "close" // TCPResponseRuleActionLua captures enum value "lua" TCPResponseRuleActionLua string = "lua" - // TCPResponseRuleActionSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" - TCPResponseRuleActionSetDashBandwidthDashLimit string = "set-bandwidth-limit" - - // TCPResponseRuleActionClose captures enum value "close" - TCPResponseRuleActionClose string = "close" + // TCPResponseRuleActionReject captures enum value "reject" + TCPResponseRuleActionReject string = "reject" // TCPResponseRuleActionScDashAddDashGpc captures enum value "sc-add-gpc" TCPResponseRuleActionScDashAddDashGpc string = "sc-add-gpc" @@ -235,6 +235,15 @@ const ( // TCPResponseRuleActionSendDashSpoeDashGroup captures enum value "send-spoe-group" TCPResponseRuleActionSendDashSpoeDashGroup string = "send-spoe-group" + // TCPResponseRuleActionSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" + TCPResponseRuleActionSetDashBandwidthDashLimit string = "set-bandwidth-limit" + + // TCPResponseRuleActionSetDashFcDashMark captures enum value "set-fc-mark" + TCPResponseRuleActionSetDashFcDashMark string = "set-fc-mark" + + // TCPResponseRuleActionSetDashFcDashTos captures enum value "set-fc-tos" + TCPResponseRuleActionSetDashFcDashTos string = "set-fc-tos" + // TCPResponseRuleActionSetDashLogDashLevel captures enum value "set-log-level" TCPResponseRuleActionSetDashLogDashLevel string = "set-log-level" @@ -247,6 +256,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/specification/build/haproxy_spec.yaml b/specification/build/haproxy_spec.yaml index 032f3123..07c5ad16 100644 --- a/specification/build/haproxy_spec.yaml +++ b/specification/build/haproxy_spec.yaml @@ -5538,10 +5538,12 @@ definitions: action: enum: - accept + - attach-srv - capture - do-resolve - expect-netscaler-cip - expect-proxy + - lua - reject - sc-add-gpc - sc-inc-gpc @@ -5549,27 +5551,31 @@ definitions: - sc-inc-gpc1 - sc-set-gpt0 - send-spoe-group + - set-bandwidth-limit + - set-bc-mark + - set-bc-tos - set-dst-port - set-dst - - set-priority + - 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 - - lua - - set-bandwidth-limit - - set-src-port - - set-mark - - set-tos - - set-var-fmt - - set-log-level - - set-nice - - switch-mode type: string x-dependency: type: @@ -5663,12 +5669,17 @@ definitions: required: true value: - do-resolve - - set-var - - set-src - - set-priority + - set-bc-mark + - set-bc-tos - set-dst - set-dst-port + - set-fc-mark + - set-fc-tos + - set-priority-class + - set-priority-offset + - set-src - set-src-port + - set-var type: value: - session @@ -5755,18 +5766,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 @@ -6026,20 +6025,24 @@ definitions: action: enum: - accept - - reject - - lua - - set-bandwidth-limit - 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 type: string @@ -6254,6 +6257,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 e129b79a..4cb97147 100644 --- a/specification/models/configuration/tcp/request.yaml +++ b/specification/models/configuration/tcp/request.yaml @@ -16,7 +16,46 @@ tcp_request_rule: x-nullable: false action: type: string - enum: [accept, capture, do-resolve, expect-netscaler-cip, expect-proxy, reject, sc-add-gpc, sc-inc-gpc, sc-inc-gpc0, sc-inc-gpc1, sc-set-gpt0, send-spoe-group, set-dst-port, set-dst, set-priority, set-src, set-var, silent-drop, track-sc0, track-sc1, track-sc2, track-sc, unset-var, use-service, lua, set-bandwidth-limit, set-src-port, set-mark, set-tos, set-var-fmt, set-log-level, set-nice, switch-mode] + 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 x-nullable: false x-dependency: type: @@ -132,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]+$' @@ -219,7 +249,19 @@ tcp_request_rule: x-display-name: Standard HAProxy expression x-dependency: action: - value: [do-resolve, set-var, set-src, set-priority, set-dst, set-dst-port, set-src-port] + value: + - do-resolve + - set-bc-mark + - set-bc-tos + - set-dst + - set-dst-port + - set-fc-mark + - set-fc-tos + - set-priority-class + - set-priority-offset + - set-src + - set-src-port + - set-var required: true type: value: [session, connection, content] @@ -276,7 +318,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: @@ -298,7 +340,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 2246e95c..9e3ad07f 100644 --- a/specification/models/configuration/tcp/response.yaml +++ b/specification/models/configuration/tcp/response.yaml @@ -16,7 +16,28 @@ tcp_response_rule: x-nullable: false action: type: string - enum: [accept, reject, lua, set-bandwidth-limit, close, sc-add-gpc, sc-inc-gpc, sc-inc-gpc0, sc-inc-gpc1, sc-set-gpt0, send-spoe-group, 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 x-nullable: false x-dependency: type: @@ -146,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: @@ -168,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: @@ -193,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