diff --git a/parsers/actions/set-bc-mark.go b/parsers/actions/set-bc-mark.go new file mode 100644 index 0000000..973e0f8 --- /dev/null +++ b/parsers/actions/set-bc-mark.go @@ -0,0 +1,76 @@ +/* +Copyright 2024 HAProxy Technologies + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//nolint:dupl +package actions + +import ( + "fmt" + "math" + "strings" + + "github.com/haproxytech/config-parser/v5/common" + "github.com/haproxytech/config-parser/v5/types" +) + +type SetBcMark struct { + Expr common.Expression + Cond string + CondTest string + Comment string +} + +func (f *SetBcMark) Parse(parts []string, parserType types.ParserType, comment string) error { + if comment != "" { + f.Comment = comment + } + if len(parts) < 3 { + return fmt.Errorf("not enough params") + } + var command []string + switch parserType { + case types.HTTP: + command = parts[2:] + case types.TCP: + command = parts[3:] + } + command, condition := common.SplitRequest(command) + + if len(command) > 0 { + if len(command) == 1 && !validateUnsignedNumber(command[0], math.MaxUint32) { + return fmt.Errorf("number '%s' is not a valid mark value", command[0]) + } + expr := common.Expression{} + err := expr.Parse(command) + if err != nil { + return fmt.Errorf("not enough params") + } + f.Expr = expr + } + if len(condition) > 1 { + f.Cond = condition[0] + f.CondTest = strings.Join(condition[1:], " ") + } + return nil +} + +func (f *SetBcMark) String() string { + return common.SmartJoin("set-bc-mark", f.Expr.String(), f.Cond, f.CondTest) +} + +func (f *SetBcMark) GetComment() string { + return f.Comment +} diff --git a/parsers/actions/set-bc-tos.go b/parsers/actions/set-bc-tos.go new file mode 100644 index 0000000..16fbb49 --- /dev/null +++ b/parsers/actions/set-bc-tos.go @@ -0,0 +1,76 @@ +/* +Copyright 2024 HAProxy Technologies + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//nolint:dupl +package actions + +import ( + "fmt" + "math" + "strings" + + "github.com/haproxytech/config-parser/v5/common" + "github.com/haproxytech/config-parser/v5/types" +) + +type SetBcTos struct { + Expr common.Expression + Cond string + CondTest string + Comment string +} + +func (f *SetBcTos) Parse(parts []string, parserType types.ParserType, comment string) error { + if comment != "" { + f.Comment = comment + } + if len(parts) < 3 { + return fmt.Errorf("not enough params") + } + var command []string + switch parserType { + case types.HTTP: + command = parts[2:] + case types.TCP: + command = parts[3:] + } + command, condition := common.SplitRequest(command) + + if len(command) > 0 { + if len(command) == 1 && !validateUnsignedNumber(command[0], math.MaxUint8) { + return fmt.Errorf("number '%s' is not a valid TOS value", command[0]) + } + expr := common.Expression{} + err := expr.Parse(command) + if err != nil { + return fmt.Errorf("not enough params") + } + f.Expr = expr + } + if len(condition) > 1 { + f.Cond = condition[0] + f.CondTest = strings.Join(condition[1:], " ") + } + return nil +} + +func (f *SetBcTos) String() string { + return common.SmartJoin("set-bc-tos", f.Expr.String(), f.Cond, f.CondTest) +} + +func (f *SetBcTos) GetComment() string { + return f.Comment +} diff --git a/parsers/actions/set-fc-mark.go b/parsers/actions/set-fc-mark.go new file mode 100644 index 0000000..fbd7ec3 --- /dev/null +++ b/parsers/actions/set-fc-mark.go @@ -0,0 +1,76 @@ +/* +Copyright 2024 HAProxy Technologies + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//nolint:dupl +package actions + +import ( + "fmt" + "math" + "strings" + + "github.com/haproxytech/config-parser/v5/common" + "github.com/haproxytech/config-parser/v5/types" +) + +type SetFcMark struct { + Expr common.Expression + Cond string + CondTest string + Comment string +} + +func (f *SetFcMark) Parse(parts []string, parserType types.ParserType, comment string) error { + if comment != "" { + f.Comment = comment + } + if len(parts) < 3 { + return fmt.Errorf("not enough params") + } + var command []string + switch parserType { + case types.HTTP: + command = parts[2:] + case types.TCP: + command = parts[3:] + } + command, condition := common.SplitRequest(command) + + if len(command) > 0 { + if len(command) == 1 && !validateUnsignedNumber(command[0], math.MaxUint32) { + return fmt.Errorf("number '%s' is not a valid mark value", command[0]) + } + expr := common.Expression{} + err := expr.Parse(command) + if err != nil { + return fmt.Errorf("not enough params") + } + f.Expr = expr + } + if len(condition) > 1 { + f.Cond = condition[0] + f.CondTest = strings.Join(condition[1:], " ") + } + return nil +} + +func (f *SetFcMark) String() string { + return common.SmartJoin("set-fc-mark", f.Expr.String(), f.Cond, f.CondTest) +} + +func (f *SetFcMark) GetComment() string { + return f.Comment +} diff --git a/parsers/actions/set-fc-tos.go b/parsers/actions/set-fc-tos.go new file mode 100644 index 0000000..85f465e --- /dev/null +++ b/parsers/actions/set-fc-tos.go @@ -0,0 +1,94 @@ +/* +Copyright 2024 HAProxy Technologies + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package actions + +import ( + "fmt" + "math" + "strconv" + "strings" + + "github.com/haproxytech/config-parser/v5/common" + "github.com/haproxytech/config-parser/v5/types" +) + +type SetFcTos struct { + Expr common.Expression + Cond string + CondTest string + Comment string +} + +func (f *SetFcTos) Parse(parts []string, parserType types.ParserType, comment string) error { + if comment != "" { + f.Comment = comment + } + if len(parts) < 3 { + return fmt.Errorf("not enough params") + } + var command []string + switch parserType { + case types.HTTP: + command = parts[2:] + case types.TCP: + command = parts[3:] + } + command, condition := common.SplitRequest(command) + + if len(command) > 0 { + if len(command) == 1 && !validateUnsignedNumber(command[0], math.MaxUint8) { + return fmt.Errorf("number '%s' is not a valid TOS value", command[0]) + } + expr := common.Expression{} + err := expr.Parse(command) + if err != nil { + return fmt.Errorf("not enough params") + } + f.Expr = expr + } + if len(condition) > 1 { + f.Cond = condition[0] + f.CondTest = strings.Join(condition[1:], " ") + } + return nil +} + +func (f *SetFcTos) String() string { + return common.SmartJoin("set-fc-tos", f.Expr.String(), f.Cond, f.CondTest) +} + +func (f *SetFcTos) GetComment() string { + return f.Comment +} + +// Test if the given string is an unsigned integer between zero and "max". +// The number can be in decimal or hexadecimal (0x). +// If the parsing failed, assume the string was an Expr and return true. +func validateUnsignedNumber(text string, max int64) bool { + var n int64 + var err error + if strings.HasPrefix(text, "0x") { + n, err = strconv.ParseInt(text, 16, 64) + } else { + n, err = strconv.ParseInt(text, 10, 64) + } + if err != nil { + // Assume it was an expression, not a number. + return true + } + return n >= 0 && n <= max +} diff --git a/parsers/http/http-request.go b/parsers/http/http-request.go index 41590d9..8bf8016 100644 --- a/parsers/http/http-request.go +++ b/parsers/http/http-request.go @@ -137,6 +137,14 @@ func (h *Requests) Parse(line string, parts []string, comment string) (string, e err = h.ParseHTTPRequest(&httpActions.WaitForHandshake{}, parts, comment) case "set-bandwidth-limit": err = h.ParseHTTPRequest(&actions.SetBandwidthLimit{}, parts, comment) + case "set-bc-mark": + err = h.ParseHTTPRequest(&actions.SetBcMark{}, parts, comment) + case "set-bc-tos": + err = h.ParseHTTPRequest(&actions.SetBcTos{}, parts, comment) + case "set-fc-mark": + err = h.ParseHTTPRequest(&actions.SetFcMark{}, parts, comment) + case "set-fc-tos": + err = h.ParseHTTPRequest(&actions.SetFcTos{}, parts, comment) default: switch { case strings.HasPrefix(parts[1], "track-sc"): diff --git a/parsers/http/http-response.go b/parsers/http/http-response.go index faad182..046f4e1 100644 --- a/parsers/http/http-response.go +++ b/parsers/http/http-response.go @@ -95,6 +95,10 @@ func (h *Responses) Parse(line string, parts []string, comment string) (string, err = h.ParseHTTPResponse(&httpActions.WaitForBody{}, parts, comment) case "set-bandwidth-limit": err = h.ParseHTTPResponse(&actions.SetBandwidthLimit{}, parts, comment) + case "set-fc-mark": + err = h.ParseHTTPResponse(&actions.SetFcMark{}, parts, comment) + case "set-fc-tos": + err = h.ParseHTTPResponse(&actions.SetFcTos{}, parts, comment) default: switch { case strings.HasPrefix(parts[1], "track-sc"): diff --git a/parsers/tcp/types/connection.go b/parsers/tcp/types/connection.go index eff71f6..421fb56 100644 --- a/parsers/tcp/types/connection.go +++ b/parsers/tcp/types/connection.go @@ -73,6 +73,10 @@ func (f *Connection) Parse(parts []string, comment string) error { err = f.ParseAction(&actions.SetSrcPort{}, parts) case "set-dst-port": err = f.ParseAction(&actions.SetDstPort{}, parts) + case "set-fc-mark": + err = f.ParseAction(&actions.SetFcMark{}, parts) + case "set-fc-tos": + err = f.ParseAction(&actions.SetFcTos{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/parsers/tcp/types/content.go b/parsers/tcp/types/content.go index 50dfa99..446b6fe 100644 --- a/parsers/tcp/types/content.go +++ b/parsers/tcp/types/content.go @@ -85,6 +85,14 @@ func (f *Content) Parse(parts []string, comment string) error { //nolint:gocyclo err = f.ParseAction(&tcpActions.SwitchMode{}, parts) case "close": err = f.ParseAction(&tcpActions.Close{}, parts) + case "set-bc-mark": + err = f.ParseAction(&actions.SetBcMark{}, parts) + case "set-bc-tos": + err = f.ParseAction(&actions.SetBcTos{}, parts) + case "set-fc-mark": + err = f.ParseAction(&actions.SetFcMark{}, parts) + case "set-fc-tos": + err = f.ParseAction(&actions.SetFcTos{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/parsers/tcp/types/session.go b/parsers/tcp/types/session.go index 04bbf2e..6bd609b 100644 --- a/parsers/tcp/types/session.go +++ b/parsers/tcp/types/session.go @@ -57,6 +57,10 @@ func (f *Session) Parse(parts []string, comment string) error { err = f.ParseAction(&actions.Reject{}, parts) case "silent-drop": err = f.ParseAction(&actions.SilentDrop{}, parts) + case "set-fc-mark": + err = f.ParseAction(&actions.SetFcMark{}, parts) + case "set-fc-tos": + err = f.ParseAction(&actions.SetFcTos{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/tests/configs/haproxy_generated.cfg.go b/tests/configs/haproxy_generated.cfg.go index 53d58d8..eed14bb 100644 --- a/tests/configs/haproxy_generated.cfg.go +++ b/tests/configs/haproxy_generated.cfg.go @@ -585,6 +585,12 @@ backend test http-request set-bandwidth-limit my-limit limit 1m period 10s http-request set-bandwidth-limit my-limit period 10s http-request set-bandwidth-limit my-limit limit 1m + http-request set-bc-mark 123 + http-request set-bc-mark 0xffffffff + http-request set-bc-mark hdr(port) if FALSE + http-request set-bc-tos 10 + http-request set-fc-mark 0 + http-request set-fc-tos 0xff if TRUE http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz http-request add-header Authorisation "Basic eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz" http-request return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } @@ -690,6 +696,8 @@ backend test http-response set-bandwidth-limit my-limit limit 1m period 10s http-response set-bandwidth-limit my-limit period 10s http-response set-bandwidth-limit my-limit limit 1m + http-response set-fc-mark 2000 + http-response set-fc-tos 200 http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } http-response return status 200 content-type "text/plain" string "My content" unless { var(txn.myip) -m found } http-response return content-type "text/plain" string "My content" if { var(txn.myip) -m found } @@ -975,6 +983,14 @@ backend test tcp-request content switch-mode http tcp-request content switch-mode http if FALSE tcp-request content switch-mode http proto my-proto + tcp-request connection set-fc-mark 1 + tcp-request connection set-fc-tos 1 + tcp-request session set-fc-mark 9999 if some_check + tcp-request session set-fc-tos 255 + tcp-request content set-bc-mark hdr(port) + tcp-request content set-bc-tos 0xff if some_check + tcp-request content set-fc-mark 0xffffffff + tcp-request content set-fc-tos 100 tcp-response content lua.foo tcp-response content lua.foo param if !HTTP tcp-response content lua.foo param param1 @@ -1000,6 +1016,8 @@ backend test tcp-response content sc-inc-gpc0(2) if is-error tcp-response content sc-inc-gpc1(2) tcp-response content sc-inc-gpc1(2) if is-error + tcp-response content set-fc-mark 123456 + tcp-response content set-fc-tos 0x02 redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } stats auth admin1:AdMiN123 stats enable @@ -1668,6 +1686,12 @@ frontend test http-request set-bandwidth-limit my-limit limit 1m period 10s http-request set-bandwidth-limit my-limit period 10s http-request set-bandwidth-limit my-limit limit 1m + http-request set-bc-mark 123 + http-request set-bc-mark 0xffffffff + http-request set-bc-mark hdr(port) if FALSE + http-request set-bc-tos 10 + http-request set-fc-mark 0 + http-request set-fc-tos 0xff if TRUE http-request capture req.cook_cnt(FirstVisit),bool len 10 http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz http-request add-header Authorisation "Basic eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz" @@ -1774,6 +1798,8 @@ frontend test http-response set-bandwidth-limit my-limit limit 1m period 10s http-response set-bandwidth-limit my-limit period 10s http-response set-bandwidth-limit my-limit limit 1m + http-response set-fc-mark 2000 + http-response set-fc-tos 200 http-response capture res.hdr(Server) id 0 http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } http-response return status 200 content-type "text/plain" string "My content" unless { var(txn.myip) -m found } @@ -1998,6 +2024,14 @@ frontend test tcp-request content switch-mode http tcp-request content switch-mode http if FALSE tcp-request content switch-mode http proto my-proto + tcp-request connection set-fc-mark 1 + tcp-request connection set-fc-tos 1 + tcp-request session set-fc-mark 9999 if some_check + tcp-request session set-fc-tos 255 + tcp-request content set-bc-mark hdr(port) + tcp-request content set-bc-tos 0xff if some_check + tcp-request content set-fc-mark 0xffffffff + tcp-request content set-fc-tos 100 tcp-response content lua.foo tcp-response content lua.foo param if !HTTP tcp-response content lua.foo param param1 @@ -2023,6 +2057,8 @@ frontend test tcp-response content sc-inc-gpc0(2) if is-error tcp-response content sc-inc-gpc1(2) tcp-response content sc-inc-gpc1(2) if is-error + tcp-response content set-fc-mark 123456 + tcp-response content set-fc-tos 0x02 redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } stats auth admin1:AdMiN123 stats enable @@ -3689,6 +3725,18 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` http-request set-bandwidth-limit my-limit period 10s `, 2}, {` http-request set-bandwidth-limit my-limit limit 1m +`, 2}, + {` http-request set-bc-mark 123 +`, 2}, + {` http-request set-bc-mark 0xffffffff +`, 2}, + {` http-request set-bc-mark hdr(port) if FALSE +`, 2}, + {` http-request set-bc-tos 10 +`, 2}, + {` http-request set-fc-mark 0 +`, 2}, + {` http-request set-fc-tos 0xff if TRUE `, 2}, {` http-request capture req.cook_cnt(FirstVisit),bool len 10 `, 1}, @@ -3875,6 +3923,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` http-response set-bandwidth-limit my-limit period 10s `, 2}, {` http-response set-bandwidth-limit my-limit limit 1m +`, 2}, + {` http-response set-fc-mark 2000 +`, 2}, + {` http-response set-fc-tos 200 `, 2}, {` http-response capture res.hdr(Server) id 0 `, 1}, @@ -4389,6 +4441,22 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` tcp-request content switch-mode http if FALSE `, 2}, {` tcp-request content switch-mode http proto my-proto +`, 2}, + {` tcp-request connection set-fc-mark 1 +`, 2}, + {` tcp-request connection set-fc-tos 1 +`, 2}, + {` tcp-request session set-fc-mark 9999 if some_check +`, 2}, + {` tcp-request session set-fc-tos 255 +`, 2}, + {` tcp-request content set-bc-mark hdr(port) +`, 2}, + {` tcp-request content set-bc-tos 0xff if some_check +`, 2}, + {` tcp-request content set-fc-mark 0xffffffff +`, 2}, + {` tcp-request content set-fc-tos 100 `, 2}, {` tcp-response content lua.foo `, 2}, @@ -4439,6 +4507,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` tcp-response content sc-inc-gpc1(2) `, 2}, {` tcp-response content sc-inc-gpc1(2) if is-error +`, 2}, + {` tcp-response content set-fc-mark 123456 +`, 2}, + {` tcp-response content set-fc-tos 0x02 `, 2}, {` redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } `, 2}, diff --git a/tests/http-request_generated_test.go b/tests/http-request_generated_test.go index 590f73f..69382ab 100644 --- a/tests/http-request_generated_test.go +++ b/tests/http-request_generated_test.go @@ -194,6 +194,12 @@ func TestRequestshttp(t *testing.T) { "http-request set-bandwidth-limit my-limit limit 1m period 10s": true, "http-request set-bandwidth-limit my-limit period 10s": true, "http-request set-bandwidth-limit my-limit limit 1m": true, + "http-request set-bc-mark 123": true, + "http-request set-bc-mark 0xffffffff": true, + "http-request set-bc-mark hdr(port) if FALSE": true, + "http-request set-bc-tos 10": true, + "http-request set-fc-mark 0": true, + "http-request set-fc-tos 0xff if TRUE": true, `http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz`: true, `http-request add-header Authorisation "Basic eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz"`: true, `http-request return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found }`: true, diff --git a/tests/http-response_generated_test.go b/tests/http-response_generated_test.go index e3c6121..3b32309 100644 --- a/tests/http-response_generated_test.go +++ b/tests/http-response_generated_test.go @@ -120,6 +120,8 @@ func TestResponseshttp(t *testing.T) { "http-response set-bandwidth-limit my-limit limit 1m period 10s": true, "http-response set-bandwidth-limit my-limit period 10s": true, "http-response set-bandwidth-limit my-limit limit 1m": true, + "http-response set-fc-mark 2000": true, + "http-response set-fc-tos 200": true, `http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found }`: true, `http-response return status 200 content-type "text/plain" string "My content" unless { var(txn.myip) -m found }`: true, `http-response return content-type "text/plain" string "My content" if { var(txn.myip) -m found }`: true, diff --git a/tests/integration/backend_data_test.go b/tests/integration/backend_data_test.go index 6581379..4c01d2d 100644 --- a/tests/integration/backend_data_test.go +++ b/tests/integration/backend_data_test.go @@ -2561,6 +2561,30 @@ const backend_httprequestsetbandwidthlimitmyli___ = ` backend test http-request set-bandwidth-limit my-limit limit 1m ` +const backend_httprequestsetbcmark123 = ` +backend test + http-request set-bc-mark 123 +` +const backend_httprequestsetbcmark0xffffffff = ` +backend test + http-request set-bc-mark 0xffffffff +` +const backend_httprequestsetbcmarkhdrportifFAL = ` +backend test + http-request set-bc-mark hdr(port) if FALSE +` +const backend_httprequestsetbctos10 = ` +backend test + http-request set-bc-tos 10 +` +const backend_httprequestsetfcmark0 = ` +backend test + http-request set-fc-mark 0 +` +const backend_httprequestsetfctos0xffifTRUE = ` +backend test + http-request set-fc-tos 0xff if TRUE +` const backend_httprequestaddheaderAuthorizatio = ` backend test http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz @@ -2981,6 +3005,14 @@ const backend_httpresponsesetbandwidthlimitmyl___ = ` backend test http-response set-bandwidth-limit my-limit limit 1m ` +const backend_httpresponsesetfcmark2000 = ` +backend test + http-response set-fc-mark 2000 +` +const backend_httpresponsesetfctos200 = ` +backend test + http-response set-fc-tos 200 +` const backend_httpresponsereturnstatus200conte = ` backend test http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } @@ -4121,6 +4153,38 @@ const backend_tcprequestcontentswitchmodehttpp = ` backend test tcp-request content switch-mode http proto my-proto ` +const backend_tcprequestconnectionsetfcmark1 = ` +backend test + tcp-request connection set-fc-mark 1 +` +const backend_tcprequestconnectionsetfctos1 = ` +backend test + tcp-request connection set-fc-tos 1 +` +const backend_tcprequestsessionsetfcmark9999if = ` +backend test + tcp-request session set-fc-mark 9999 if some_check +` +const backend_tcprequestsessionsetfctos255 = ` +backend test + tcp-request session set-fc-tos 255 +` +const backend_tcprequestcontentsetbcmarkhdrpor = ` +backend test + tcp-request content set-bc-mark hdr(port) +` +const backend_tcprequestcontentsetbctos0xffifs = ` +backend test + tcp-request content set-bc-tos 0xff if some_check +` +const backend_tcprequestcontentsetfcmark0xffff = ` +backend test + tcp-request content set-fc-mark 0xffffffff +` +const backend_tcprequestcontentsetfctos100 = ` +backend test + tcp-request content set-fc-tos 100 +` const backend_tcpresponsecontentluafoo = ` backend test tcp-response content lua.foo @@ -4221,6 +4285,14 @@ const backend_tcpresponsecontentscincgpc12ifis_ = ` backend test tcp-response content sc-inc-gpc1(2) if is-error ` +const backend_tcpresponsecontentsetfcmark12345 = ` +backend test + tcp-response content set-fc-mark 123456 +` +const backend_tcpresponsecontentsetfctos0x02 = ` +backend test + tcp-response content set-fc-tos 0x02 +` const backend_redirectprefixhttpwwwbarcomcode3 = ` backend test redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } diff --git a/tests/integration/backend_test.go b/tests/integration/backend_test.go index f30d912..2576b57 100644 --- a/tests/integration/backend_test.go +++ b/tests/integration/backend_test.go @@ -461,6 +461,10 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httprequestsetbandwidthlimitmyli_", backend_httprequestsetbandwidthlimitmyli_}, {"backend_httprequestsetbandwidthlimitmyli__", backend_httprequestsetbandwidthlimitmyli__}, {"backend_httprequestsetbandwidthlimitmyli___", backend_httprequestsetbandwidthlimitmyli___}, + {"backend_httprequestsetbcmark0xffffffff", backend_httprequestsetbcmark0xffffffff}, + {"backend_httprequestsetbcmark123", backend_httprequestsetbcmark123}, + {"backend_httprequestsetbcmarkhdrportifFAL", backend_httprequestsetbcmarkhdrportifFAL}, + {"backend_httprequestsetbctos10", backend_httprequestsetbctos10}, {"backend_httprequestsetdstporthdrxport", backend_httprequestsetdstporthdrxport}, {"backend_httprequestsetdstporthdrxportifv", backend_httprequestsetdstporthdrxportifv}, {"backend_httprequestsetdstporthdrxportunl", backend_httprequestsetdstporthdrxportunl}, @@ -468,6 +472,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httprequestsetdstvartxnmyip", backend_httprequestsetdstvartxnmyip}, {"backend_httprequestsetdstvartxnmyipifvar", backend_httprequestsetdstvartxnmyipifvar}, {"backend_httprequestsetdstvartxnmyipunles", backend_httprequestsetdstvartxnmyipunles}, + {"backend_httprequestsetfcmark0", backend_httprequestsetfcmark0}, + {"backend_httprequestsetfctos0xffifTRUE", backend_httprequestsetfctos0xffifTRUE}, {"backend_httprequestsetheaderXvaluevalue", backend_httprequestsetheaderXvaluevalue}, {"backend_httprequestsetloglevelsilent", backend_httprequestsetloglevelsilent}, {"backend_httprequestsetmapmaplstsrcreqhdr", backend_httprequestsetmapmaplstsrcreqhdr}, @@ -594,6 +600,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httpresponsesetbandwidthlimitmyl_", backend_httpresponsesetbandwidthlimitmyl_}, {"backend_httpresponsesetbandwidthlimitmyl__", backend_httpresponsesetbandwidthlimitmyl__}, {"backend_httpresponsesetbandwidthlimitmyl___", backend_httpresponsesetbandwidthlimitmyl___}, + {"backend_httpresponsesetfcmark2000", backend_httpresponsesetfcmark2000}, + {"backend_httpresponsesetfctos200", backend_httpresponsesetfctos200}, {"backend_httpresponsesetheaderXvaluevalue", backend_httpresponsesetheaderXvaluevalue}, {"backend_httpresponsesetloglevelsilent", backend_httpresponsesetloglevelsilent}, {"backend_httpresponsesetmapmaplstsrcreshd", backend_httpresponsesetmapmaplstsrcreshd}, @@ -938,6 +946,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestconnectionscincgpc12if_", backend_tcprequestconnectionscincgpc12if_}, {"backend_tcprequestconnectionscsetgpt0013", backend_tcprequestconnectionscsetgpt0013}, {"backend_tcprequestconnectionscsetgpt0013_", backend_tcprequestconnectionscsetgpt0013_}, + {"backend_tcprequestconnectionsetfcmark1", backend_tcprequestconnectionsetfcmark1}, + {"backend_tcprequestconnectionsetfctos1", backend_tcprequestconnectionsetfctos1}, {"backend_tcprequestconnectionsetmark0x1Ab", backend_tcprequestconnectionsetmark0x1Ab}, {"backend_tcprequestconnectionsetmark20", backend_tcprequestconnectionsetmark20}, {"backend_tcprequestconnectionsetsrchdrxfo", backend_tcprequestconnectionsetsrchdrxfo}, @@ -992,7 +1002,11 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestcontentsetbandwidthlim_", backend_tcprequestcontentsetbandwidthlim_}, {"backend_tcprequestcontentsetbandwidthlim__", backend_tcprequestcontentsetbandwidthlim__}, {"backend_tcprequestcontentsetbandwidthlim___", backend_tcprequestcontentsetbandwidthlim___}, + {"backend_tcprequestcontentsetbcmarkhdrpor", backend_tcprequestcontentsetbcmarkhdrpor}, + {"backend_tcprequestcontentsetbctos0xffifs", backend_tcprequestcontentsetbctos0xffifs}, {"backend_tcprequestcontentsetdstipv410001", backend_tcprequestcontentsetdstipv410001}, + {"backend_tcprequestcontentsetfcmark0xffff", backend_tcprequestcontentsetfcmark0xffff}, + {"backend_tcprequestcontentsetfctos100", backend_tcprequestcontentsetfctos100}, {"backend_tcprequestcontentsetloglevelsile", backend_tcprequestcontentsetloglevelsile}, {"backend_tcprequestcontentsetloglevelsile_", backend_tcprequestcontentsetloglevelsile_}, {"backend_tcprequestcontentsetmark0x1AbifF", backend_tcprequestcontentsetmark0x1AbifF}, @@ -1053,6 +1067,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestsessionscincgpc12ifise_", backend_tcprequestsessionscincgpc12ifise_}, {"backend_tcprequestsessionscsetgpt001337", backend_tcprequestsessionscsetgpt001337}, {"backend_tcprequestsessionscsetgpt001337i", backend_tcprequestsessionscsetgpt001337i}, + {"backend_tcprequestsessionsetfcmark9999if", backend_tcprequestsessionsetfcmark9999if}, + {"backend_tcprequestsessionsetfctos255", backend_tcprequestsessionsetfctos255}, {"backend_tcprequestsessionsetvarfmtsessdn", backend_tcprequestsessionsetvarfmtsessdn}, {"backend_tcprequestsessionsetvarfmtsesssr", backend_tcprequestsessionsetvarfmtsesssr}, {"backend_tcprequestsessionsetvarsessdnssl", backend_tcprequestsessionsetvarsessdnssl}, @@ -1093,6 +1109,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcpresponsecontentsetbandwidthli__", backend_tcpresponsecontentsetbandwidthli__}, {"backend_tcpresponsecontentsetbandwidthli___", backend_tcpresponsecontentsetbandwidthli___}, {"backend_tcpresponsecontentsetdstdest", backend_tcpresponsecontentsetdstdest}, + {"backend_tcpresponsecontentsetfcmark12345", backend_tcpresponsecontentsetfcmark12345}, + {"backend_tcpresponsecontentsetfctos0x02", backend_tcpresponsecontentsetfctos0x02}, {"backend_tcpresponsecontentsetloglevelsil", backend_tcpresponsecontentsetloglevelsil}, {"backend_tcpresponsecontentsetloglevelsil_", backend_tcpresponsecontentsetloglevelsil_}, {"backend_tcpresponsecontentsetmark0x1Abif", backend_tcpresponsecontentsetmark0x1Abif}, diff --git a/tests/integration/frontend_data_test.go b/tests/integration/frontend_data_test.go index 86ac8c3..011459e 100644 --- a/tests/integration/frontend_data_test.go +++ b/tests/integration/frontend_data_test.go @@ -1533,6 +1533,30 @@ const frontend_httprequestsetbandwidthlimitmyli___ = ` frontend test http-request set-bandwidth-limit my-limit limit 1m ` +const frontend_httprequestsetbcmark123 = ` +frontend test + http-request set-bc-mark 123 +` +const frontend_httprequestsetbcmark0xffffffff = ` +frontend test + http-request set-bc-mark 0xffffffff +` +const frontend_httprequestsetbcmarkhdrportifFAL = ` +frontend test + http-request set-bc-mark hdr(port) if FALSE +` +const frontend_httprequestsetbctos10 = ` +frontend test + http-request set-bc-tos 10 +` +const frontend_httprequestsetfcmark0 = ` +frontend test + http-request set-fc-mark 0 +` +const frontend_httprequestsetfctos0xffifTRUE = ` +frontend test + http-request set-fc-tos 0xff if TRUE +` const frontend_httprequestcapturereqcookcntFirs = ` frontend test http-request capture req.cook_cnt(FirstVisit),bool len 10 @@ -1957,6 +1981,14 @@ const frontend_httpresponsesetbandwidthlimitmyl___ = ` frontend test http-response set-bandwidth-limit my-limit limit 1m ` +const frontend_httpresponsesetfcmark2000 = ` +frontend test + http-response set-fc-mark 2000 +` +const frontend_httpresponsesetfctos200 = ` +frontend test + http-response set-fc-tos 200 +` const frontend_httpresponsecapturereshdrServeri = ` frontend test http-response capture res.hdr(Server) id 0 @@ -2853,6 +2885,38 @@ const frontend_tcprequestcontentswitchmodehttpp = ` frontend test tcp-request content switch-mode http proto my-proto ` +const frontend_tcprequestconnectionsetfcmark1 = ` +frontend test + tcp-request connection set-fc-mark 1 +` +const frontend_tcprequestconnectionsetfctos1 = ` +frontend test + tcp-request connection set-fc-tos 1 +` +const frontend_tcprequestsessionsetfcmark9999if = ` +frontend test + tcp-request session set-fc-mark 9999 if some_check +` +const frontend_tcprequestsessionsetfctos255 = ` +frontend test + tcp-request session set-fc-tos 255 +` +const frontend_tcprequestcontentsetbcmarkhdrpor = ` +frontend test + tcp-request content set-bc-mark hdr(port) +` +const frontend_tcprequestcontentsetbctos0xffifs = ` +frontend test + tcp-request content set-bc-tos 0xff if some_check +` +const frontend_tcprequestcontentsetfcmark0xffff = ` +frontend test + tcp-request content set-fc-mark 0xffffffff +` +const frontend_tcprequestcontentsetfctos100 = ` +frontend test + tcp-request content set-fc-tos 100 +` const frontend_tcpresponsecontentluafoo = ` frontend test tcp-response content lua.foo @@ -2953,6 +3017,14 @@ const frontend_tcpresponsecontentscincgpc12ifis_ = ` frontend test tcp-response content sc-inc-gpc1(2) if is-error ` +const frontend_tcpresponsecontentsetfcmark12345 = ` +frontend test + tcp-response content set-fc-mark 123456 +` +const frontend_tcpresponsecontentsetfctos0x02 = ` +frontend test + tcp-response content set-fc-tos 0x02 +` const frontend_redirectprefixhttpwwwbarcomcode3 = ` frontend test redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } diff --git a/tests/integration/frontend_test.go b/tests/integration/frontend_test.go index 43a1290..959d120 100644 --- a/tests/integration/frontend_test.go +++ b/tests/integration/frontend_test.go @@ -353,6 +353,10 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httprequestsetbandwidthlimitmyli_", frontend_httprequestsetbandwidthlimitmyli_}, {"frontend_httprequestsetbandwidthlimitmyli__", frontend_httprequestsetbandwidthlimitmyli__}, {"frontend_httprequestsetbandwidthlimitmyli___", frontend_httprequestsetbandwidthlimitmyli___}, + {"frontend_httprequestsetbcmark0xffffffff", frontend_httprequestsetbcmark0xffffffff}, + {"frontend_httprequestsetbcmark123", frontend_httprequestsetbcmark123}, + {"frontend_httprequestsetbcmarkhdrportifFAL", frontend_httprequestsetbcmarkhdrportifFAL}, + {"frontend_httprequestsetbctos10", frontend_httprequestsetbctos10}, {"frontend_httprequestsetdstporthdrxport", frontend_httprequestsetdstporthdrxport}, {"frontend_httprequestsetdstporthdrxportifv", frontend_httprequestsetdstporthdrxportifv}, {"frontend_httprequestsetdstporthdrxportunl", frontend_httprequestsetdstporthdrxportunl}, @@ -360,6 +364,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httprequestsetdstvartxnmyip", frontend_httprequestsetdstvartxnmyip}, {"frontend_httprequestsetdstvartxnmyipifvar", frontend_httprequestsetdstvartxnmyipifvar}, {"frontend_httprequestsetdstvartxnmyipunles", frontend_httprequestsetdstvartxnmyipunles}, + {"frontend_httprequestsetfcmark0", frontend_httprequestsetfcmark0}, + {"frontend_httprequestsetfctos0xffifTRUE", frontend_httprequestsetfctos0xffifTRUE}, {"frontend_httprequestsetheaderXvaluevalue", frontend_httprequestsetheaderXvaluevalue}, {"frontend_httprequestsetloglevelsilent", frontend_httprequestsetloglevelsilent}, {"frontend_httprequestsetmapmaplstsrcreqhdr", frontend_httprequestsetmapmaplstsrcreqhdr}, @@ -487,6 +493,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httpresponsesetbandwidthlimitmyl_", frontend_httpresponsesetbandwidthlimitmyl_}, {"frontend_httpresponsesetbandwidthlimitmyl__", frontend_httpresponsesetbandwidthlimitmyl__}, {"frontend_httpresponsesetbandwidthlimitmyl___", frontend_httpresponsesetbandwidthlimitmyl___}, + {"frontend_httpresponsesetfcmark2000", frontend_httpresponsesetfcmark2000}, + {"frontend_httpresponsesetfctos200", frontend_httpresponsesetfctos200}, {"frontend_httpresponsesetheaderXvaluevalue", frontend_httpresponsesetheaderXvaluevalue}, {"frontend_httpresponsesetloglevelsilent", frontend_httpresponsesetloglevelsilent}, {"frontend_httpresponsesetmapmaplstsrcreshd", frontend_httpresponsesetmapmaplstsrcreshd}, @@ -613,6 +621,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestconnectionscincgpc12if_", frontend_tcprequestconnectionscincgpc12if_}, {"frontend_tcprequestconnectionscsetgpt0013", frontend_tcprequestconnectionscsetgpt0013}, {"frontend_tcprequestconnectionscsetgpt0013_", frontend_tcprequestconnectionscsetgpt0013_}, + {"frontend_tcprequestconnectionsetfcmark1", frontend_tcprequestconnectionsetfcmark1}, + {"frontend_tcprequestconnectionsetfctos1", frontend_tcprequestconnectionsetfctos1}, {"frontend_tcprequestconnectionsetmark0x1Ab", frontend_tcprequestconnectionsetmark0x1Ab}, {"frontend_tcprequestconnectionsetmark20", frontend_tcprequestconnectionsetmark20}, {"frontend_tcprequestconnectionsetsrchdrxfo", frontend_tcprequestconnectionsetsrchdrxfo}, @@ -667,7 +677,11 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestcontentsetbandwidthlim_", frontend_tcprequestcontentsetbandwidthlim_}, {"frontend_tcprequestcontentsetbandwidthlim__", frontend_tcprequestcontentsetbandwidthlim__}, {"frontend_tcprequestcontentsetbandwidthlim___", frontend_tcprequestcontentsetbandwidthlim___}, + {"frontend_tcprequestcontentsetbcmarkhdrpor", frontend_tcprequestcontentsetbcmarkhdrpor}, + {"frontend_tcprequestcontentsetbctos0xffifs", frontend_tcprequestcontentsetbctos0xffifs}, {"frontend_tcprequestcontentsetdstipv410001", frontend_tcprequestcontentsetdstipv410001}, + {"frontend_tcprequestcontentsetfcmark0xffff", frontend_tcprequestcontentsetfcmark0xffff}, + {"frontend_tcprequestcontentsetfctos100", frontend_tcprequestcontentsetfctos100}, {"frontend_tcprequestcontentsetloglevelsile", frontend_tcprequestcontentsetloglevelsile}, {"frontend_tcprequestcontentsetloglevelsile_", frontend_tcprequestcontentsetloglevelsile_}, {"frontend_tcprequestcontentsetmark0x1AbifF", frontend_tcprequestcontentsetmark0x1AbifF}, @@ -728,6 +742,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestsessionscincgpc12ifise_", frontend_tcprequestsessionscincgpc12ifise_}, {"frontend_tcprequestsessionscsetgpt001337", frontend_tcprequestsessionscsetgpt001337}, {"frontend_tcprequestsessionscsetgpt001337i", frontend_tcprequestsessionscsetgpt001337i}, + {"frontend_tcprequestsessionsetfcmark9999if", frontend_tcprequestsessionsetfcmark9999if}, + {"frontend_tcprequestsessionsetfctos255", frontend_tcprequestsessionsetfctos255}, {"frontend_tcprequestsessionsetvarfmtsessdn", frontend_tcprequestsessionsetvarfmtsessdn}, {"frontend_tcprequestsessionsetvarfmtsesssr", frontend_tcprequestsessionsetvarfmtsesssr}, {"frontend_tcprequestsessionsetvarsessdnssl", frontend_tcprequestsessionsetvarsessdnssl}, @@ -768,6 +784,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcpresponsecontentsetbandwidthli__", frontend_tcpresponsecontentsetbandwidthli__}, {"frontend_tcpresponsecontentsetbandwidthli___", frontend_tcpresponsecontentsetbandwidthli___}, {"frontend_tcpresponsecontentsetdstdest", frontend_tcpresponsecontentsetdstdest}, + {"frontend_tcpresponsecontentsetfcmark12345", frontend_tcpresponsecontentsetfcmark12345}, + {"frontend_tcpresponsecontentsetfctos0x02", frontend_tcpresponsecontentsetfctos0x02}, {"frontend_tcpresponsecontentsetloglevelsil", frontend_tcpresponsecontentsetloglevelsil}, {"frontend_tcpresponsecontentsetloglevelsil_", frontend_tcpresponsecontentsetloglevelsil_}, {"frontend_tcpresponsecontentsetmark0x1Abif", frontend_tcpresponsecontentsetmark0x1Abif}, diff --git a/tests/tcp-request_generated_test.go b/tests/tcp-request_generated_test.go index 9cec01b..a079f58 100644 --- a/tests/tcp-request_generated_test.go +++ b/tests/tcp-request_generated_test.go @@ -187,6 +187,14 @@ func TestRequeststcp(t *testing.T) { "tcp-request content switch-mode http": true, "tcp-request content switch-mode http if FALSE": true, "tcp-request content switch-mode http proto my-proto": true, + "tcp-request connection set-fc-mark 1": true, + "tcp-request connection set-fc-tos 1": true, + "tcp-request session set-fc-mark 9999 if some_check": true, + "tcp-request session set-fc-tos 255": true, + "tcp-request content set-bc-mark hdr(port)": true, + "tcp-request content set-bc-tos 0xff if some_check": true, + "tcp-request content set-fc-mark 0xffffffff": true, + "tcp-request content set-fc-tos 100": true, "tcp-request content sc-inc-gpc": false, "tcp-request content sc-inc-gpc0": false, "tcp-request content sc-inc-gpc1": false, diff --git a/tests/tcp-response_generated_test.go b/tests/tcp-response_generated_test.go index 701e4b2..cf7c648 100644 --- a/tests/tcp-response_generated_test.go +++ b/tests/tcp-response_generated_test.go @@ -52,26 +52,28 @@ func TestResponsestcp(t *testing.T) { "tcp-response content sc-inc-gpc0(2) if is-error": true, "tcp-response content sc-inc-gpc1(2)": true, "tcp-response content sc-inc-gpc1(2) if is-error": true, - "tcp-response": false, - "tcp-response content lua.": false, - "tcp-response content lua. param": false, - "tcp-response content set-priority-class": false, - "tcp-response content do-resolve": false, - "tcp-response content set-priority-offset": false, - "tcp-response content set-dst": false, - "tcp-response content capture": false, - "tcp-response content set-bandwidth-limit my-limit limit": false, - "tcp-response content set-bandwidth-limit my-limit period": false, - "tcp-response content set-bandwidth-limit my-limit 10s": false, - "tcp-response content set-bandwidth-limit my-limit period 10s limit": false, - "tcp-response content set-bandwidth-limit my-limit limit period 10s": false, - "tcp-response content set-log-level": false, - "tcp-response content set-mark": false, - "tcp-response content set-tos": false, - "tcp-response content set-nice": false, - "tcp-response content sc-inc-gpc": false, - "---": false, - "--- ---": false, + "tcp-response content set-fc-mark 123456": true, + "tcp-response content set-fc-tos 0x02": true, + "tcp-response": false, + "tcp-response content lua.": false, + "tcp-response content lua. param": false, + "tcp-response content set-priority-class": false, + "tcp-response content do-resolve": false, + "tcp-response content set-priority-offset": false, + "tcp-response content set-dst": false, + "tcp-response content capture": false, + "tcp-response content set-bandwidth-limit my-limit limit": false, + "tcp-response content set-bandwidth-limit my-limit period": false, + "tcp-response content set-bandwidth-limit my-limit 10s": false, + "tcp-response content set-bandwidth-limit my-limit period 10s limit": false, + "tcp-response content set-bandwidth-limit my-limit limit period 10s": false, + "tcp-response content set-log-level": false, + "tcp-response content set-mark": false, + "tcp-response content set-tos": false, + "tcp-response content set-nice": false, + "tcp-response content sc-inc-gpc": false, + "---": false, + "--- ---": false, } parser := &tcp.Responses{} for command, shouldPass := range tests { diff --git a/types/types-other.go b/types/types-other.go index 575c0d1..9b9e02e 100644 --- a/types/types-other.go +++ b/types/types-other.go @@ -543,6 +543,12 @@ type Action interface { //test:fail:http-request set-bandwidth-limit my-limit 10s //test:fail:http-request set-bandwidth-limit my-limit period 10s limit //test:fail:http-request set-bandwidth-limit my-limit limit period 10s +//test:ok:http-request set-bc-mark 123 +//test:ok:http-request set-bc-mark 0xffffffff +//test:ok:http-request set-bc-mark hdr(port) if FALSE +//test:ok:http-request set-bc-tos 10 +//test:ok:http-request set-fc-mark 0 +//test:ok:http-request set-fc-tos 0xff if TRUE type HTTPRequests struct{} //name:http-response @@ -716,6 +722,8 @@ type HTTPRequests struct{} //test:fail:http-response set-bandwidth-limit my-limit 10s //test:fail:http-response set-bandwidth-limit my-limit period 10s limit //test:fail:http-response set-bandwidth-limit my-limit limit period 10s +//test:ok:http-response set-fc-mark 2000 +//test:ok:http-response set-fc-tos 200 type HTTPResponses struct{} //name:http-after-response @@ -1161,7 +1169,14 @@ type TCPType interface { //test:fail:tcp-request content switch-mode //test:fail:tcp-request content switch-mode tcp //test:fail:tcp-request content switch-mode http proto - +//test:ok:tcp-request connection set-fc-mark 1 +//test:ok:tcp-request connection set-fc-tos 1 +//test:ok:tcp-request session set-fc-mark 9999 if some_check +//test:ok:tcp-request session set-fc-tos 255 +//test:ok:tcp-request content set-bc-mark hdr(port) +//test:ok:tcp-request content set-bc-tos 0xff if some_check +//test:ok:tcp-request content set-fc-mark 0xffffffff +//test:ok:tcp-request content set-fc-tos 100 type TCPRequests struct{} //name:tcp-response @@ -1216,6 +1231,8 @@ type TCPRequests struct{} //test:ok:tcp-response content sc-inc-gpc0(2) if is-error //test:ok:tcp-response content sc-inc-gpc1(2) //test:ok:tcp-response content sc-inc-gpc1(2) if is-error +//test:ok:tcp-response content set-fc-mark 123456 +//test:ok:tcp-response content set-fc-tos 0x02 type TCPResponses struct{} //name:redirect