diff --git a/config-parser/parsers/actions/do-log.go b/config-parser/parsers/actions/do-log.go new file mode 100644 index 00000000..673560f8 --- /dev/null +++ b/config-parser/parsers/actions/do-log.go @@ -0,0 +1,74 @@ +/* +Copyright 2019 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 ( + stderrors "errors" + "fmt" + "strings" + + "github.com/haproxytech/client-native/v6/config-parser/common" + "github.com/haproxytech/client-native/v6/config-parser/types" +) + +type DoLog struct { + Cond string + CondTest string + Comment string +} + +func (f *DoLog) Parse(parts []string, parserType types.ParserType, comment string) error { + if comment != "" { + f.Comment = comment + } + var command []string + var minLen, requiredLen int + switch parserType { + case types.HTTP: + command = parts[1:] + minLen = 2 + requiredLen = 4 + case types.TCP: + command = parts[2:] + minLen = 3 + requiredLen = 5 + } + if len(parts) == minLen { + return nil + } + if len(parts) < requiredLen { + return stderrors.New("not enough params") + } + _, condition := common.SplitRequest(command) + if len(condition) > 1 { + f.Cond = condition[0] + f.CondTest = strings.Join(condition[1:], " ") + } + return nil +} + +func (f *DoLog) String() string { + if f.Cond != "" { + return fmt.Sprintf("do-log %s %s", f.Cond, f.CondTest) + } + return "do-log" +} + +func (f *DoLog) GetComment() string { + return f.Comment +} diff --git a/config-parser/parsers/actions/reject.go b/config-parser/parsers/actions/reject.go index 795044b3..8535f1d8 100644 --- a/config-parser/parsers/actions/reject.go +++ b/config-parser/parsers/actions/reject.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +//nolint:dupl package actions import ( diff --git a/config-parser/parsers/http/http-after-response.go b/config-parser/parsers/http/http-after-response.go index b8061299..f918caf2 100644 --- a/config-parser/parsers/http/http-after-response.go +++ b/config-parser/parsers/http/http-after-response.go @@ -76,6 +76,8 @@ func (h *AfterResponses) Parse(line string, parts []string, comment string) (str err = h.ParseHTTPRequest(&actions.SetStatus{}, parts, comment) case action == "strict-mode": err = h.ParseHTTPRequest(&actions.StrictMode{}, parts, comment) + case action == "do-log": + err = h.ParseHTTPRequest(&parsersActions.DoLog{}, parts, comment) case strings.HasPrefix(action, "unset-var("): err = h.ParseHTTPRequest(&parsersActions.UnsetVar{}, parts, comment) case strings.HasPrefix(action, "set-var("): diff --git a/config-parser/parsers/http/http-request.go b/config-parser/parsers/http/http-request.go index 0686e60b..cb29f019 100644 --- a/config-parser/parsers/http/http-request.go +++ b/config-parser/parsers/http/http-request.go @@ -147,6 +147,8 @@ func (h *Requests) Parse(line string, parts []string, comment string) (string, e err = h.ParseHTTPRequest(&actions.SetFcTos{}, parts, comment) case "set-retries": err = h.ParseHTTPRequest(&actions.SetRetries{}, parts, comment) + case "do-log": + err = h.ParseHTTPRequest(&actions.DoLog{}, parts, comment) default: switch { case strings.HasPrefix(parts[1], "track-sc"): diff --git a/config-parser/parsers/http/http-response.go b/config-parser/parsers/http/http-response.go index 50334946..0da7d1d3 100644 --- a/config-parser/parsers/http/http-response.go +++ b/config-parser/parsers/http/http-response.go @@ -47,7 +47,7 @@ func (h *Responses) ParseHTTPResponse(response types.Action, parts []string, com return nil } -func (h *Responses) Parse(line string, parts []string, comment string) (string, error) { //nolint:cyclop +func (h *Responses) Parse(line string, parts []string, comment string) (string, error) { //nolint:cyclop,gocyclo if len(parts) >= 2 && parts[0] == "http-response" { var err error switch parts[1] { @@ -99,6 +99,8 @@ func (h *Responses) Parse(line string, parts []string, comment string) (string, err = h.ParseHTTPResponse(&actions.SetFcMark{}, parts, comment) case "set-fc-tos": err = h.ParseHTTPResponse(&actions.SetFcTos{}, parts, comment) + case "do-log": + err = h.ParseHTTPResponse(&actions.DoLog{}, parts, comment) default: switch { case strings.HasPrefix(parts[1], "track-sc"): diff --git a/config-parser/parsers/tcp/types/connection.go b/config-parser/parsers/tcp/types/connection.go index a419a62f..71afd1c1 100644 --- a/config-parser/parsers/tcp/types/connection.go +++ b/config-parser/parsers/tcp/types/connection.go @@ -78,6 +78,8 @@ func (f *Connection) Parse(parts []string, comment string) error { err = f.ParseAction(&actions.SetFcMark{}, parts) case "set-fc-tos": err = f.ParseAction(&actions.SetFcTos{}, parts) + case "do-log": + err = f.ParseAction(&actions.DoLog{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/config-parser/parsers/tcp/types/content.go b/config-parser/parsers/tcp/types/content.go index 5330dc9a..e2f0025b 100644 --- a/config-parser/parsers/tcp/types/content.go +++ b/config-parser/parsers/tcp/types/content.go @@ -96,6 +96,8 @@ func (f *Content) Parse(parts []string, comment string) error { err = f.ParseAction(&actions.SetFcTos{}, parts) case "set-retries": err = f.ParseAction(&actions.SetRetries{}, parts) + case "do-log": + err = f.ParseAction(&actions.DoLog{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/config-parser/parsers/tcp/types/session.go b/config-parser/parsers/tcp/types/session.go index 0169f33d..1c56d84d 100644 --- a/config-parser/parsers/tcp/types/session.go +++ b/config-parser/parsers/tcp/types/session.go @@ -74,6 +74,8 @@ func (f *Session) Parse(parts []string, comment string) error { err = f.ParseAction(&actions.SetSrcPort{}, parts) case "set-tos": err = f.ParseAction(&actions.SetTos{}, parts) + case "do-log": + err = f.ParseAction(&actions.DoLog{}, parts) default: switch { case strings.HasPrefix(parts[2], "track-sc"): diff --git a/config-parser/tests/configs/haproxy_generated.cfg.go b/config-parser/tests/configs/haproxy_generated.cfg.go index 94c8aad3..0d3eed42 100644 --- a/config-parser/tests/configs/haproxy_generated.cfg.go +++ b/config-parser/tests/configs/haproxy_generated.cfg.go @@ -605,6 +605,8 @@ backend test http-request set-fc-tos 0xff if TRUE http-request set-retries 3 http-request set-retries var(txn.retries) if TRUE + http-request do-log + http-request do-log if FALSE 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 } @@ -715,6 +717,8 @@ backend test http-response set-bandwidth-limit my-limit limit 1m http-response set-fc-mark 2000 http-response set-fc-tos 200 + http-response do-log + http-response do-log if FALSE 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 } @@ -769,6 +773,8 @@ backend test http-after-response sc-set-gpt0(1) hdr(Host),lower http-after-response sc-set-gpt0(1) 10 http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE + http-after-response do-log + http-after-response do-log if FALSE http-error status 400 http-error status 400 default-errorfiles http-error status 400 errorfile /my/fancy/errorfile @@ -1021,6 +1027,12 @@ backend test 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-request content do-log + tcp-request content do-log if TRUE + tcp-request connection do-log + tcp-request connection do-log if TRUE + tcp-request session do-log + tcp-request session do-log if TRUE tcp-response content lua.foo tcp-response content lua.foo param if !HTTP tcp-response content lua.foo param param1 @@ -1048,6 +1060,8 @@ backend test tcp-response content sc-inc-gpc1(2) if is-error tcp-response content set-fc-mark 123456 tcp-response content set-fc-tos 0x02 + tcp-response content do-log + tcp-response content do-log if TRUE redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } stats auth admin1:AdMiN123 stats enable @@ -1467,6 +1481,8 @@ defaults test http-request set-fc-tos 0xff if TRUE http-request set-retries 3 http-request set-retries var(txn.retries) if TRUE + http-request do-log + http-request do-log if FALSE 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 } @@ -1577,6 +1593,8 @@ defaults test http-response set-bandwidth-limit my-limit limit 1m http-response set-fc-mark 2000 http-response set-fc-tos 200 + http-response do-log + http-response do-log if FALSE 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 } @@ -1631,6 +1649,8 @@ defaults test http-after-response sc-set-gpt0(1) hdr(Host),lower http-after-response sc-set-gpt0(1) 10 http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE + http-after-response do-log + http-after-response do-log if FALSE http-error status 400 http-error status 400 default-errorfiles http-error status 400 errorfile /my/fancy/errorfile @@ -1883,6 +1903,12 @@ defaults test 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-request content do-log + tcp-request content do-log if TRUE + tcp-request connection do-log + tcp-request connection do-log if TRUE + tcp-request session do-log + tcp-request session do-log if TRUE stats auth admin1:AdMiN123 stats enable stats hide-version @@ -2276,6 +2302,8 @@ frontend test http-request set-fc-tos 0xff if TRUE http-request set-retries 3 http-request set-retries var(txn.retries) if TRUE + http-request do-log + http-request do-log if FALSE http-request capture req.cook_cnt(FirstVisit),bool len 10 http-request capture str("DNS resolution failure") len 32 unless dns_successful http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz @@ -2388,6 +2416,8 @@ frontend test http-response set-bandwidth-limit my-limit limit 1m http-response set-fc-mark 2000 http-response set-fc-tos 200 + http-response do-log + http-response do-log if FALSE 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 } @@ -2443,6 +2473,8 @@ frontend test http-after-response sc-set-gpt0(1) hdr(Host),lower http-after-response sc-set-gpt0(1) 10 http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE + http-after-response do-log + http-after-response do-log if FALSE http-error status 400 http-error status 400 default-errorfiles http-error status 400 errorfile /my/fancy/errorfile @@ -2633,6 +2665,12 @@ frontend test 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-request content do-log + tcp-request content do-log if TRUE + tcp-request connection do-log + tcp-request connection do-log if TRUE + tcp-request session do-log + tcp-request session do-log if TRUE tcp-request content capture str("DNS resolution failure") len 32 unless dns_successful tcp-response content lua.foo tcp-response content lua.foo param if !HTTP @@ -2661,6 +2699,8 @@ frontend test tcp-response content sc-inc-gpc1(2) if is-error tcp-response content set-fc-mark 123456 tcp-response content set-fc-tos 0x02 + tcp-response content do-log + tcp-response content do-log if TRUE redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } stats auth admin1:AdMiN123 stats enable @@ -4389,6 +4429,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` http-request set-retries 3 `, 3}, {` http-request set-retries var(txn.retries) if TRUE +`, 3}, + {` http-request do-log +`, 3}, + {` http-request do-log if FALSE `, 3}, {` http-request capture req.cook_cnt(FirstVisit),bool len 10 `, 1}, @@ -4587,6 +4631,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` http-response set-fc-mark 2000 `, 3}, {` http-response set-fc-tos 200 +`, 3}, + {` http-response do-log +`, 3}, + {` http-response do-log if FALSE `, 3}, {` http-response capture res.hdr(Server) id 0 `, 1}, @@ -4677,6 +4725,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` http-after-response sc-set-gpt0(1) 10 `, 3}, {` http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE +`, 3}, + {` http-after-response do-log +`, 3}, + {` http-after-response do-log if FALSE `, 3}, {` http-error status 400 `, 3}, @@ -5143,6 +5195,18 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` tcp-request content set-fc-mark 0xffffffff `, 3}, {` tcp-request content set-fc-tos 100 +`, 3}, + {` tcp-request content do-log +`, 3}, + {` tcp-request content do-log if TRUE +`, 3}, + {` tcp-request connection do-log +`, 3}, + {` tcp-request connection do-log if TRUE +`, 3}, + {` tcp-request session do-log +`, 3}, + {` tcp-request session do-log if TRUE `, 3}, {` tcp-request content capture str("DNS resolution failure") len 32 unless dns_successful `, 1}, @@ -5199,6 +5263,10 @@ var configTests = []configTest{{` command spoa-mirror --runtime 0 --mirror-url {` tcp-response content set-fc-mark 123456 `, 2}, {` tcp-response content set-fc-tos 0x02 +`, 2}, + {` tcp-response content do-log +`, 2}, + {` tcp-response content do-log if TRUE `, 2}, {` redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } `, 2}, diff --git a/config-parser/tests/http-after-response_generated_test.go b/config-parser/tests/http-after-response_generated_test.go index 08516673..da531439 100644 --- a/config-parser/tests/http-after-response_generated_test.go +++ b/config-parser/tests/http-after-response_generated_test.go @@ -71,31 +71,33 @@ func TestAfterResponseshttp(t *testing.T) { "http-after-response sc-set-gpt0(1) hdr(Host),lower": true, "http-after-response sc-set-gpt0(1) 10": true, "http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE": true, - "http-after-response": false, - "http-after-response set-header": false, - "http-after-response set-header x-foo": false, - "http-after-response del-header": false, - "http-after-response replace-header Set-Cookie": false, - "http-after-response replace-header Set-Cookie (C=[^;]*);(.*)": false, - "http-after-response replace-value Cache-control": false, - "http-after-response replace-value Cache-control ^public$": false, - "http-after-response set-status": false, - "http-after-response set-status error": false, - "http-after-response set-var(sess.last_redir)": false, - "http-after-response strict-mode": false, - "http-after-response strict-mode 1": false, - "http-after-response strict-mode 0": false, - "http-after-response unset-var()": false, - "http-after-response set-map(map.lst) %[src]": false, - "http-after-response del-acl(map.lst)": false, - "http-after-response del-map(map.lst)": false, - "http-after-response sc-add-gpc": false, - "http-after-response sc-inc-gpc": false, - "http-after-response sc-inc-gpc0": false, - "http-after-response sc-inc-gpc1": false, - "http-after-response sc-set-gpt0(1)": false, - "http-after-response sc-set-gpt0": false, - "http-after-response sc-set-gpt0(1) if FALSE": false, + "http-after-response do-log": true, + "http-after-response do-log if FALSE": true, + "http-after-response": false, + "http-after-response set-header": false, + "http-after-response set-header x-foo": false, + "http-after-response del-header": false, + "http-after-response replace-header Set-Cookie": false, + "http-after-response replace-header Set-Cookie (C=[^;]*);(.*)": false, + "http-after-response replace-value Cache-control": false, + "http-after-response replace-value Cache-control ^public$": false, + "http-after-response set-status": false, + "http-after-response set-status error": false, + "http-after-response set-var(sess.last_redir)": false, + "http-after-response strict-mode": false, + "http-after-response strict-mode 1": false, + "http-after-response strict-mode 0": false, + "http-after-response unset-var()": false, + "http-after-response set-map(map.lst) %[src]": false, + "http-after-response del-acl(map.lst)": false, + "http-after-response del-map(map.lst)": false, + "http-after-response sc-add-gpc": false, + "http-after-response sc-inc-gpc": false, + "http-after-response sc-inc-gpc0": false, + "http-after-response sc-inc-gpc1": false, + "http-after-response sc-set-gpt0(1)": false, + "http-after-response sc-set-gpt0": false, + "http-after-response sc-set-gpt0(1) if FALSE": false, "---": false, "--- ---": false, } diff --git a/config-parser/tests/http-request_generated_test.go b/config-parser/tests/http-request_generated_test.go index cf157837..2e7a8981 100644 --- a/config-parser/tests/http-request_generated_test.go +++ b/config-parser/tests/http-request_generated_test.go @@ -206,6 +206,8 @@ func TestRequestshttp(t *testing.T) { "http-request set-fc-tos 0xff if TRUE": true, "http-request set-retries 3": true, "http-request set-retries var(txn.retries) if TRUE": true, + "http-request do-log": true, + "http-request do-log if FALSE": 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/config-parser/tests/http-response_generated_test.go b/config-parser/tests/http-response_generated_test.go index 3ad33e2f..1144151f 100644 --- a/config-parser/tests/http-response_generated_test.go +++ b/config-parser/tests/http-response_generated_test.go @@ -125,6 +125,8 @@ func TestResponseshttp(t *testing.T) { "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 do-log": true, + "http-response do-log if FALSE": 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/config-parser/tests/integration/backend_data_test.go b/config-parser/tests/integration/backend_data_test.go index bbac6b42..7d3383f7 100644 --- a/config-parser/tests/integration/backend_data_test.go +++ b/config-parser/tests/integration/backend_data_test.go @@ -2609,6 +2609,14 @@ const backend_httprequestsetretriesvartxnretri = ` backend test http-request set-retries var(txn.retries) if TRUE ` +const backend_httprequestdolog = ` +backend test + http-request do-log +` +const backend_httprequestdologifFALSE = ` +backend test + http-request do-log if FALSE +` const backend_httprequestaddheaderAuthorizatio = ` backend test http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz @@ -3049,6 +3057,14 @@ const backend_httpresponsesetfctos200 = ` backend test http-response set-fc-tos 200 ` +const backend_httpresponsedolog = ` +backend test + http-response do-log +` +const backend_httpresponsedologifFALSE = ` +backend test + http-response do-log if FALSE +` const backend_httpresponsereturnstatus200conte = ` backend test http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } @@ -3265,6 +3281,14 @@ const backend_httpafterresponsescsetgpt01hdrHo_ = ` backend test http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE ` +const backend_httpafterresponsedolog = ` +backend test + http-after-response do-log +` +const backend_httpafterresponsedologifFALSE = ` +backend test + http-after-response do-log if FALSE +` const backend_httperrorstatus400 = ` backend test http-error status 400 @@ -4273,6 +4297,30 @@ const backend_tcprequestcontentsetfctos100 = ` backend test tcp-request content set-fc-tos 100 ` +const backend_tcprequestcontentdolog = ` +backend test + tcp-request content do-log +` +const backend_tcprequestcontentdologifTRUE = ` +backend test + tcp-request content do-log if TRUE +` +const backend_tcprequestconnectiondolog = ` +backend test + tcp-request connection do-log +` +const backend_tcprequestconnectiondologifTRUE = ` +backend test + tcp-request connection do-log if TRUE +` +const backend_tcprequestsessiondolog = ` +backend test + tcp-request session do-log +` +const backend_tcprequestsessiondologifTRUE = ` +backend test + tcp-request session do-log if TRUE +` const backend_tcpresponsecontentluafoo = ` backend test tcp-response content lua.foo @@ -4381,6 +4429,14 @@ const backend_tcpresponsecontentsetfctos0x02 = ` backend test tcp-response content set-fc-tos 0x02 ` +const backend_tcpresponsecontentdolog = ` +backend test + tcp-response content do-log +` +const backend_tcpresponsecontentdologifTRUE = ` +backend test + tcp-response content do-log if TRUE +` const backend_redirectprefixhttpwwwbarcomcode3 = ` backend test redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } diff --git a/config-parser/tests/integration/backend_test.go b/config-parser/tests/integration/backend_test.go index ad9c4c93..3f3d78b8 100644 --- a/config-parser/tests/integration/backend_test.go +++ b/config-parser/tests/integration/backend_test.go @@ -278,6 +278,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httpafterresponsedelheaderXValue___", backend_httpafterresponsedelheaderXValue___}, {"backend_httpafterresponsedelmapmaplstsrc", backend_httpafterresponsedelmapmaplstsrc}, {"backend_httpafterresponsedelmapmaplstsrc_", backend_httpafterresponsedelmapmaplstsrc_}, + {"backend_httpafterresponsedolog", backend_httpafterresponsedolog}, + {"backend_httpafterresponsedologifFALSE", backend_httpafterresponsedologifFALSE}, {"backend_httpafterresponsereplaceheaderSe", backend_httpafterresponsereplaceheaderSe}, {"backend_httpafterresponsereplaceheaderSe_", backend_httpafterresponsereplaceheaderSe_}, {"backend_httpafterresponsereplacevalueCac", backend_httpafterresponsereplacevalueCac}, @@ -387,6 +389,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httprequestdenyifTRUE", backend_httprequestdenyifTRUE}, {"backend_httprequestdisablel7retry", backend_httprequestdisablel7retry}, {"backend_httprequestdisablel7retryifFALSE", backend_httprequestdisablel7retryifFALSE}, + {"backend_httprequestdolog", backend_httprequestdolog}, + {"backend_httprequestdologifFALSE", backend_httprequestdologifFALSE}, {"backend_httprequestdoresolvetxnmyipmydns", backend_httprequestdoresolvetxnmyipmydns}, {"backend_httprequestdoresolvetxnmyipmydns_", backend_httprequestdoresolvetxnmyipmydns_}, {"backend_httprequestdoresolvetxnmyipmydns__", backend_httprequestdoresolvetxnmyipmydns__}, @@ -570,6 +574,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_httpresponsedenydenystatus400con__________", backend_httpresponsedenydenystatus400con__________}, {"backend_httpresponsedenydenystatus400ifT", backend_httpresponsedenydenystatus400ifT}, {"backend_httpresponsedenyifTRUE", backend_httpresponsedenyifTRUE}, + {"backend_httpresponsedolog", backend_httpresponsedolog}, + {"backend_httpresponsedologifFALSE", backend_httpresponsedologifFALSE}, {"backend_httpresponseluafoo", backend_httpresponseluafoo}, {"backend_httpresponseluafooifFALSE", backend_httpresponseluafooifFALSE}, {"backend_httpresponseluafooparam", backend_httpresponseluafooparam}, @@ -938,6 +944,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestconnectionaccept", backend_tcprequestconnectionaccept}, {"backend_tcprequestconnectionacceptifHTTP", backend_tcprequestconnectionacceptifHTTP}, {"backend_tcprequestconnectioncapturereqpa", backend_tcprequestconnectioncapturereqpa}, + {"backend_tcprequestconnectiondolog", backend_tcprequestconnectiondolog}, + {"backend_tcprequestconnectiondologifTRUE", backend_tcprequestconnectiondologifTRUE}, {"backend_tcprequestconnectionexpectnetsca", backend_tcprequestconnectionexpectnetsca}, {"backend_tcprequestconnectionexpectnetsca_", backend_tcprequestconnectionexpectnetsca_}, {"backend_tcprequestconnectionexpectproxyl", backend_tcprequestconnectionexpectproxyl}, @@ -994,6 +1002,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestcontentacceptifHTTP", backend_tcprequestcontentacceptifHTTP}, {"backend_tcprequestcontentcapturereqpaylo", backend_tcprequestcontentcapturereqpaylo}, {"backend_tcprequestcontentcapturereqpaylo_", backend_tcprequestcontentcapturereqpaylo_}, + {"backend_tcprequestcontentdolog", backend_tcprequestcontentdolog}, + {"backend_tcprequestcontentdologifTRUE", backend_tcprequestcontentdologifTRUE}, {"backend_tcprequestcontentdoresolvetxnmyi", backend_tcprequestcontentdoresolvetxnmyi}, {"backend_tcprequestcontentdoresolvetxnmyi_", backend_tcprequestcontentdoresolvetxnmyi_}, {"backend_tcprequestcontentluafoo", backend_tcprequestcontentluafoo}, @@ -1074,6 +1084,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestsessionattachsrvsrv1", backend_tcprequestsessionattachsrvsrv1}, {"backend_tcprequestsessionattachsrvsrv1na", backend_tcprequestsessionattachsrvsrv1na}, {"backend_tcprequestsessionattachsrvsrv1na_", backend_tcprequestsessionattachsrvsrv1na_}, + {"backend_tcprequestsessiondolog", backend_tcprequestsessiondolog}, + {"backend_tcprequestsessiondologifTRUE", backend_tcprequestsessiondologifTRUE}, {"backend_tcprequestsessionreject", backend_tcprequestsessionreject}, {"backend_tcprequestsessionrejectifHTTP", backend_tcprequestsessionrejectifHTTP}, {"backend_tcprequestsessionscaddgpc121", backend_tcprequestsessionscaddgpc121}, @@ -1117,6 +1129,8 @@ func TestWholeConfigsSectionsBackend(t *testing.T) { {"backend_tcprequestsessionunsetvarsesssrc", backend_tcprequestsessionunsetvarsesssrc}, {"backend_tcpresponsecontentclose", backend_tcpresponsecontentclose}, {"backend_tcpresponsecontentcloseifHTTP", backend_tcpresponsecontentcloseifHTTP}, + {"backend_tcpresponsecontentdolog", backend_tcpresponsecontentdolog}, + {"backend_tcpresponsecontentdologifTRUE", backend_tcpresponsecontentdologifTRUE}, {"backend_tcpresponsecontentluafoo", backend_tcpresponsecontentluafoo}, {"backend_tcpresponsecontentluafooparamifH", backend_tcpresponsecontentluafooparamifH}, {"backend_tcpresponsecontentluafooparampar", backend_tcpresponsecontentluafooparampar}, diff --git a/config-parser/tests/integration/defaults_data_test.go b/config-parser/tests/integration/defaults_data_test.go index 67e87131..545cbc14 100644 --- a/config-parser/tests/integration/defaults_data_test.go +++ b/config-parser/tests/integration/defaults_data_test.go @@ -1861,6 +1861,14 @@ const defaults_httprequestsetretriesvartxnretri = ` defaults test http-request set-retries var(txn.retries) if TRUE ` +const defaults_httprequestdolog = ` +defaults test + http-request do-log +` +const defaults_httprequestdologifFALSE = ` +defaults test + http-request do-log if FALSE +` const defaults_httprequestaddheaderAuthorizatio = ` defaults test http-request add-header Authorization Basic\ eC1oYXByb3h5LXJlY3J1aXRzOlBlb3BsZSB3aG8gZGVjb2RlIG1lc3NhZ2VzIG9mdGVuIGxvdmUgd29ya2luZyBhdCBIQVByb3h5LiBEbyBub3QgYmUgc2h5LCBjb250YWN0IHVz @@ -2301,6 +2309,14 @@ const defaults_httpresponsesetfctos200 = ` defaults test http-response set-fc-tos 200 ` +const defaults_httpresponsedolog = ` +defaults test + http-response do-log +` +const defaults_httpresponsedologifFALSE = ` +defaults test + http-response do-log if FALSE +` const defaults_httpresponsereturnstatus200conte = ` defaults test http-response return status 200 content-type "text/plain" string "My content" if { var(txn.myip) -m found } @@ -2517,6 +2533,14 @@ const defaults_httpafterresponsescsetgpt01hdrHo_ = ` defaults test http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE ` +const defaults_httpafterresponsedolog = ` +defaults test + http-after-response do-log +` +const defaults_httpafterresponsedologifFALSE = ` +defaults test + http-after-response do-log if FALSE +` const defaults_httperrorstatus400 = ` defaults test http-error status 400 @@ -3525,6 +3549,30 @@ const defaults_tcprequestcontentsetfctos100 = ` defaults test tcp-request content set-fc-tos 100 ` +const defaults_tcprequestcontentdolog = ` +defaults test + tcp-request content do-log +` +const defaults_tcprequestcontentdologifTRUE = ` +defaults test + tcp-request content do-log if TRUE +` +const defaults_tcprequestconnectiondolog = ` +defaults test + tcp-request connection do-log +` +const defaults_tcprequestconnectiondologifTRUE = ` +defaults test + tcp-request connection do-log if TRUE +` +const defaults_tcprequestsessiondolog = ` +defaults test + tcp-request session do-log +` +const defaults_tcprequestsessiondologifTRUE = ` +defaults test + tcp-request session do-log if TRUE +` const defaults_statsauthadmin1AdMiN123 = ` defaults test stats auth admin1:AdMiN123 diff --git a/config-parser/tests/integration/defaults_test.go b/config-parser/tests/integration/defaults_test.go index 989cc0b0..2e333df6 100644 --- a/config-parser/tests/integration/defaults_test.go +++ b/config-parser/tests/integration/defaults_test.go @@ -274,6 +274,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_httpafterresponsedelheaderXValue___", defaults_httpafterresponsedelheaderXValue___}, {"defaults_httpafterresponsedelmapmaplstsrc", defaults_httpafterresponsedelmapmaplstsrc}, {"defaults_httpafterresponsedelmapmaplstsrc_", defaults_httpafterresponsedelmapmaplstsrc_}, + {"defaults_httpafterresponsedolog", defaults_httpafterresponsedolog}, + {"defaults_httpafterresponsedologifFALSE", defaults_httpafterresponsedologifFALSE}, {"defaults_httpafterresponsereplaceheaderSe", defaults_httpafterresponsereplaceheaderSe}, {"defaults_httpafterresponsereplaceheaderSe_", defaults_httpafterresponsereplaceheaderSe_}, {"defaults_httpafterresponsereplacevalueCac", defaults_httpafterresponsereplacevalueCac}, @@ -383,6 +385,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_httprequestdenyifTRUE", defaults_httprequestdenyifTRUE}, {"defaults_httprequestdisablel7retry", defaults_httprequestdisablel7retry}, {"defaults_httprequestdisablel7retryifFALSE", defaults_httprequestdisablel7retryifFALSE}, + {"defaults_httprequestdolog", defaults_httprequestdolog}, + {"defaults_httprequestdologifFALSE", defaults_httprequestdologifFALSE}, {"defaults_httprequestdoresolvetxnmyipmydns", defaults_httprequestdoresolvetxnmyipmydns}, {"defaults_httprequestdoresolvetxnmyipmydns_", defaults_httprequestdoresolvetxnmyipmydns_}, {"defaults_httprequestdoresolvetxnmyipmydns__", defaults_httprequestdoresolvetxnmyipmydns__}, @@ -566,6 +570,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_httpresponsedenydenystatus400con__________", defaults_httpresponsedenydenystatus400con__________}, {"defaults_httpresponsedenydenystatus400ifT", defaults_httpresponsedenydenystatus400ifT}, {"defaults_httpresponsedenyifTRUE", defaults_httpresponsedenyifTRUE}, + {"defaults_httpresponsedolog", defaults_httpresponsedolog}, + {"defaults_httpresponsedologifFALSE", defaults_httpresponsedologifFALSE}, {"defaults_httpresponseluafoo", defaults_httpresponseluafoo}, {"defaults_httpresponseluafooifFALSE", defaults_httpresponseluafooifFALSE}, {"defaults_httpresponseluafooparam", defaults_httpresponseluafooparam}, @@ -744,6 +750,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_tcprequestconnectionaccept", defaults_tcprequestconnectionaccept}, {"defaults_tcprequestconnectionacceptifHTTP", defaults_tcprequestconnectionacceptifHTTP}, {"defaults_tcprequestconnectioncapturereqpa", defaults_tcprequestconnectioncapturereqpa}, + {"defaults_tcprequestconnectiondolog", defaults_tcprequestconnectiondolog}, + {"defaults_tcprequestconnectiondologifTRUE", defaults_tcprequestconnectiondologifTRUE}, {"defaults_tcprequestconnectionexpectnetsca", defaults_tcprequestconnectionexpectnetsca}, {"defaults_tcprequestconnectionexpectnetsca_", defaults_tcprequestconnectionexpectnetsca_}, {"defaults_tcprequestconnectionexpectproxyl", defaults_tcprequestconnectionexpectproxyl}, @@ -800,6 +808,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_tcprequestcontentacceptifHTTP", defaults_tcprequestcontentacceptifHTTP}, {"defaults_tcprequestcontentcapturereqpaylo", defaults_tcprequestcontentcapturereqpaylo}, {"defaults_tcprequestcontentcapturereqpaylo_", defaults_tcprequestcontentcapturereqpaylo_}, + {"defaults_tcprequestcontentdolog", defaults_tcprequestcontentdolog}, + {"defaults_tcprequestcontentdologifTRUE", defaults_tcprequestcontentdologifTRUE}, {"defaults_tcprequestcontentdoresolvetxnmyi", defaults_tcprequestcontentdoresolvetxnmyi}, {"defaults_tcprequestcontentdoresolvetxnmyi_", defaults_tcprequestcontentdoresolvetxnmyi_}, {"defaults_tcprequestcontentluafoo", defaults_tcprequestcontentluafoo}, @@ -880,6 +890,8 @@ func TestWholeConfigsSectionsDefaults(t *testing.T) { {"defaults_tcprequestsessionattachsrvsrv1", defaults_tcprequestsessionattachsrvsrv1}, {"defaults_tcprequestsessionattachsrvsrv1na", defaults_tcprequestsessionattachsrvsrv1na}, {"defaults_tcprequestsessionattachsrvsrv1na_", defaults_tcprequestsessionattachsrvsrv1na_}, + {"defaults_tcprequestsessiondolog", defaults_tcprequestsessiondolog}, + {"defaults_tcprequestsessiondologifTRUE", defaults_tcprequestsessiondologifTRUE}, {"defaults_tcprequestsessionreject", defaults_tcprequestsessionreject}, {"defaults_tcprequestsessionrejectifHTTP", defaults_tcprequestsessionrejectifHTTP}, {"defaults_tcprequestsessionscaddgpc121", defaults_tcprequestsessionscaddgpc121}, diff --git a/config-parser/tests/integration/frontend_data_test.go b/config-parser/tests/integration/frontend_data_test.go index b66a1584..0aaa7902 100644 --- a/config-parser/tests/integration/frontend_data_test.go +++ b/config-parser/tests/integration/frontend_data_test.go @@ -1589,6 +1589,14 @@ const frontend_httprequestsetretriesvartxnretri = ` frontend test http-request set-retries var(txn.retries) if TRUE ` +const frontend_httprequestdolog = ` +frontend test + http-request do-log +` +const frontend_httprequestdologifFALSE = ` +frontend test + http-request do-log if FALSE +` const frontend_httprequestcapturereqcookcntFirs = ` frontend test http-request capture req.cook_cnt(FirstVisit),bool len 10 @@ -2037,6 +2045,14 @@ const frontend_httpresponsesetfctos200 = ` frontend test http-response set-fc-tos 200 ` +const frontend_httpresponsedolog = ` +frontend test + http-response do-log +` +const frontend_httpresponsedologifFALSE = ` +frontend test + http-response do-log if FALSE +` const frontend_httpresponsecapturereshdrServeri = ` frontend test http-response capture res.hdr(Server) id 0 @@ -2257,6 +2273,14 @@ const frontend_httpafterresponsescsetgpt01hdrHo_ = ` frontend test http-after-response sc-set-gpt0(1) hdr(Host),lower if FALSE ` +const frontend_httpafterresponsedolog = ` +frontend test + http-after-response do-log +` +const frontend_httpafterresponsedologifFALSE = ` +frontend test + http-after-response do-log if FALSE +` const frontend_httperrorstatus400 = ` frontend test http-error status 400 @@ -3017,6 +3041,30 @@ const frontend_tcprequestcontentsetfctos100 = ` frontend test tcp-request content set-fc-tos 100 ` +const frontend_tcprequestcontentdolog = ` +frontend test + tcp-request content do-log +` +const frontend_tcprequestcontentdologifTRUE = ` +frontend test + tcp-request content do-log if TRUE +` +const frontend_tcprequestconnectiondolog = ` +frontend test + tcp-request connection do-log +` +const frontend_tcprequestconnectiondologifTRUE = ` +frontend test + tcp-request connection do-log if TRUE +` +const frontend_tcprequestsessiondolog = ` +frontend test + tcp-request session do-log +` +const frontend_tcprequestsessiondologifTRUE = ` +frontend test + tcp-request session do-log if TRUE +` const frontend_tcprequestcontentcapturestrDNSre = ` frontend test tcp-request content capture str("DNS resolution failure") len 32 unless dns_successful @@ -3129,6 +3177,14 @@ const frontend_tcpresponsecontentsetfctos0x02 = ` frontend test tcp-response content set-fc-tos 0x02 ` +const frontend_tcpresponsecontentdolog = ` +frontend test + tcp-response content do-log +` +const frontend_tcpresponsecontentdologifTRUE = ` +frontend test + tcp-response content do-log if TRUE +` const frontend_redirectprefixhttpwwwbarcomcode3 = ` frontend test redirect prefix http://www.bar.com code 301 if { hdr(host) -i foo.com } diff --git a/config-parser/tests/integration/frontend_test.go b/config-parser/tests/integration/frontend_test.go index bdc747a9..b92e6e05 100644 --- a/config-parser/tests/integration/frontend_test.go +++ b/config-parser/tests/integration/frontend_test.go @@ -209,6 +209,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httpafterresponsedelheaderXValue___", frontend_httpafterresponsedelheaderXValue___}, {"frontend_httpafterresponsedelmapmaplstsrc", frontend_httpafterresponsedelmapmaplstsrc}, {"frontend_httpafterresponsedelmapmaplstsrc_", frontend_httpafterresponsedelmapmaplstsrc_}, + {"frontend_httpafterresponsedolog", frontend_httpafterresponsedolog}, + {"frontend_httpafterresponsedologifFALSE", frontend_httpafterresponsedologifFALSE}, {"frontend_httpafterresponsereplaceheaderSe", frontend_httpafterresponsereplaceheaderSe}, {"frontend_httpafterresponsereplaceheaderSe_", frontend_httpafterresponsereplaceheaderSe_}, {"frontend_httpafterresponsereplacevalueCac", frontend_httpafterresponsereplacevalueCac}, @@ -283,6 +285,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httprequestdenyifTRUE", frontend_httprequestdenyifTRUE}, {"frontend_httprequestdisablel7retry", frontend_httprequestdisablel7retry}, {"frontend_httprequestdisablel7retryifFALSE", frontend_httprequestdisablel7retryifFALSE}, + {"frontend_httprequestdolog", frontend_httprequestdolog}, + {"frontend_httprequestdologifFALSE", frontend_httprequestdologifFALSE}, {"frontend_httprequestdoresolvetxnmyipmydns", frontend_httprequestdoresolvetxnmyipmydns}, {"frontend_httprequestdoresolvetxnmyipmydns_", frontend_httprequestdoresolvetxnmyipmydns_}, {"frontend_httprequestdoresolvetxnmyipmydns__", frontend_httprequestdoresolvetxnmyipmydns__}, @@ -467,6 +471,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_httpresponsedenydenystatus400con__________", frontend_httpresponsedenydenystatus400con__________}, {"frontend_httpresponsedenydenystatus400ifT", frontend_httpresponsedenydenystatus400ifT}, {"frontend_httpresponsedenyifTRUE", frontend_httpresponsedenyifTRUE}, + {"frontend_httpresponsedolog", frontend_httpresponsedolog}, + {"frontend_httpresponsedologifFALSE", frontend_httpresponsedologifFALSE}, {"frontend_httpresponseluafoo", frontend_httpresponseluafoo}, {"frontend_httpresponseluafooifFALSE", frontend_httpresponseluafooifFALSE}, {"frontend_httpresponseluafooparam", frontend_httpresponseluafooparam}, @@ -616,6 +622,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestconnectionaccept", frontend_tcprequestconnectionaccept}, {"frontend_tcprequestconnectionacceptifHTTP", frontend_tcprequestconnectionacceptifHTTP}, {"frontend_tcprequestconnectioncapturereqpa", frontend_tcprequestconnectioncapturereqpa}, + {"frontend_tcprequestconnectiondolog", frontend_tcprequestconnectiondolog}, + {"frontend_tcprequestconnectiondologifTRUE", frontend_tcprequestconnectiondologifTRUE}, {"frontend_tcprequestconnectionexpectnetsca", frontend_tcprequestconnectionexpectnetsca}, {"frontend_tcprequestconnectionexpectnetsca_", frontend_tcprequestconnectionexpectnetsca_}, {"frontend_tcprequestconnectionexpectproxyl", frontend_tcprequestconnectionexpectproxyl}, @@ -673,6 +681,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestcontentcapturereqpaylo", frontend_tcprequestcontentcapturereqpaylo}, {"frontend_tcprequestcontentcapturereqpaylo_", frontend_tcprequestcontentcapturereqpaylo_}, {"frontend_tcprequestcontentcapturestrDNSre", frontend_tcprequestcontentcapturestrDNSre}, + {"frontend_tcprequestcontentdolog", frontend_tcprequestcontentdolog}, + {"frontend_tcprequestcontentdologifTRUE", frontend_tcprequestcontentdologifTRUE}, {"frontend_tcprequestcontentdoresolvetxnmyi", frontend_tcprequestcontentdoresolvetxnmyi}, {"frontend_tcprequestcontentdoresolvetxnmyi_", frontend_tcprequestcontentdoresolvetxnmyi_}, {"frontend_tcprequestcontentluafoo", frontend_tcprequestcontentluafoo}, @@ -753,6 +763,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestsessionattachsrvsrv1", frontend_tcprequestsessionattachsrvsrv1}, {"frontend_tcprequestsessionattachsrvsrv1na", frontend_tcprequestsessionattachsrvsrv1na}, {"frontend_tcprequestsessionattachsrvsrv1na_", frontend_tcprequestsessionattachsrvsrv1na_}, + {"frontend_tcprequestsessiondolog", frontend_tcprequestsessiondolog}, + {"frontend_tcprequestsessiondologifTRUE", frontend_tcprequestsessiondologifTRUE}, {"frontend_tcprequestsessionreject", frontend_tcprequestsessionreject}, {"frontend_tcprequestsessionrejectifHTTP", frontend_tcprequestsessionrejectifHTTP}, {"frontend_tcprequestsessionscaddgpc121", frontend_tcprequestsessionscaddgpc121}, @@ -796,6 +808,8 @@ func TestWholeConfigsSectionsFrontend(t *testing.T) { {"frontend_tcprequestsessionunsetvarsesssrc", frontend_tcprequestsessionunsetvarsesssrc}, {"frontend_tcpresponsecontentclose", frontend_tcpresponsecontentclose}, {"frontend_tcpresponsecontentcloseifHTTP", frontend_tcpresponsecontentcloseifHTTP}, + {"frontend_tcpresponsecontentdolog", frontend_tcpresponsecontentdolog}, + {"frontend_tcpresponsecontentdologifTRUE", frontend_tcpresponsecontentdologifTRUE}, {"frontend_tcpresponsecontentluafoo", frontend_tcpresponsecontentluafoo}, {"frontend_tcpresponsecontentluafooparamifH", frontend_tcpresponsecontentluafooparamifH}, {"frontend_tcpresponsecontentluafooparampar", frontend_tcpresponsecontentluafooparampar}, diff --git a/config-parser/tests/tcp-request_generated_test.go b/config-parser/tests/tcp-request_generated_test.go index 522786bc..fe70259d 100644 --- a/config-parser/tests/tcp-request_generated_test.go +++ b/config-parser/tests/tcp-request_generated_test.go @@ -208,6 +208,12 @@ func TestRequeststcp(t *testing.T) { "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 do-log": true, + "tcp-request content do-log if TRUE": true, + "tcp-request connection do-log": true, + "tcp-request connection do-log if TRUE": true, + "tcp-request session do-log": true, + "tcp-request session do-log if TRUE": 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/config-parser/tests/tcp-response_generated_test.go b/config-parser/tests/tcp-response_generated_test.go index 623fc21c..1835d7bb 100644 --- a/config-parser/tests/tcp-response_generated_test.go +++ b/config-parser/tests/tcp-response_generated_test.go @@ -54,6 +54,8 @@ func TestResponsestcp(t *testing.T) { "tcp-response content sc-inc-gpc1(2) if is-error": true, "tcp-response content set-fc-mark 123456": true, "tcp-response content set-fc-tos 0x02": true, + "tcp-response content do-log": true, + "tcp-response content do-log if TRUE": true, "tcp-response": false, "tcp-response content lua.": false, "tcp-response content lua. param": false, diff --git a/config-parser/types/types-other.go b/config-parser/types/types-other.go index 74cdb72d..8feea594 100644 --- a/config-parser/types/types-other.go +++ b/config-parser/types/types-other.go @@ -555,6 +555,8 @@ type Action interface { //test:ok:http-request set-fc-tos 0xff if TRUE //test:ok:http-request set-retries 3 //test:ok:http-request set-retries var(txn.retries) if TRUE +//test:ok:http-request do-log +//test:ok:http-request do-log if FALSE type HTTPRequests struct{} //name:http-response @@ -735,6 +737,8 @@ type HTTPRequests struct{} //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 +//test:ok:http-response do-log +//test:ok:http-response do-log if FALSE type HTTPResponses struct{} //name:http-after-response @@ -815,6 +819,8 @@ type HTTPResponses struct{} //test:fail:http-after-response sc-set-gpt0(1) //test:fail:http-after-response sc-set-gpt0 //test:fail:http-after-response sc-set-gpt0(1) if FALSE +//test:ok:http-after-response do-log +//test:ok:http-after-response do-log if FALSE type HTTPAfterResponse struct{} //name:http-error @@ -1205,6 +1211,12 @@ type TCPType interface { //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 +//test:ok:tcp-request content do-log +//test:ok:tcp-request content do-log if TRUE +//test:ok:tcp-request connection do-log +//test:ok:tcp-request connection do-log if TRUE +//test:ok:tcp-request session do-log +//test:ok:tcp-request session do-log if TRUE type TCPRequests struct{} //name:tcp-response @@ -1261,6 +1273,8 @@ type TCPRequests struct{} //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 +//test:ok:tcp-response content do-log +//test:ok:tcp-response content do-log if TRUE type TCPResponses struct{} //name:redirect diff --git a/configuration/http_after_response_rule.go b/configuration/http_after_response_rule.go index 8f767deb..f5b232a9 100644 --- a/configuration/http_after_response_rule.go +++ b/configuration/http_after_response_rule.go @@ -251,7 +251,7 @@ func ParseHTTPAfterRules(t, pName string, p parser.Parser) (models.HTTPAfterResp return httpResRules, nil } -func ParseHTTPAfterRule(f types.Action) (*models.HTTPAfterResponseRule, error) { //nolint:maintidx,gocognit +func ParseHTTPAfterRule(f types.Action) (*models.HTTPAfterResponseRule, error) { //nolint:maintidx,gocognit,gocyclo,cyclop switch v := f.(type) { case *http_actions.AddHeader: return &models.HTTPAfterResponseRule{ @@ -464,6 +464,12 @@ func ParseHTTPAfterRule(f types.Action) (*models.HTTPAfterResponseRule, error) { Cond: v.Cond, CondTest: v.CondTest, }, nil + case *actions.DoLog: + return &models.HTTPAfterResponseRule{ + Type: "do-log", + Cond: v.Cond, + CondTest: v.CondTest, + }, nil } return nil, nil //nolint:nilnil } @@ -624,6 +630,11 @@ func SerializeHTTPAfterRule(f models.HTTPAfterResponseRule) (types.Action, error Cond: f.Cond, CondTest: f.CondTest, } + case "do-log": + rule = &actions.DoLog{ + Cond: f.Cond, + CondTest: f.CondTest, + } } return rule, nil } diff --git a/configuration/http_request_rule.go b/configuration/http_request_rule.go index 05f9a8c5..8e9839ba 100644 --- a/configuration/http_request_rule.go +++ b/configuration/http_request_rule.go @@ -812,6 +812,12 @@ func ParseHTTPRequestRule(f types.Action) (*models.HTTPRequestRule, error) { //n Cond: v.Cond, CondTest: v.CondTest, } + case *actions.DoLog: + rule = &models.HTTPRequestRule{ + Type: models.HTTPRequestRuleTypeDoDashLog, + Cond: v.Cond, + CondTest: v.CondTest, + } } return rule, nil @@ -1315,6 +1321,11 @@ func SerializeHTTPRequestRule(f models.HTTPRequestRule, opt *options.Configurati Cond: f.Cond, CondTest: f.CondTest, } + case "do-log": + rule = &actions.DoLog{ + Cond: f.Cond, + CondTest: f.CondTest, + } } return rule, nil diff --git a/configuration/http_response_rule.go b/configuration/http_response_rule.go index 0b764a31..5de6cdbd 100644 --- a/configuration/http_response_rule.go +++ b/configuration/http_response_rule.go @@ -600,6 +600,12 @@ func ParseHTTPResponseRule(f types.Action) *models.HTTPResponseRule { //nolint:m Cond: v.Cond, CondTest: v.CondTest, } + case *actions.DoLog: + return &models.HTTPResponseRule{ + Type: models.HTTPResponseRuleTypeDoDashLog, + Cond: v.Cond, + CondTest: v.CondTest, + } } return nil } @@ -923,6 +929,11 @@ func SerializeHTTPResponseRule(f models.HTTPResponseRule, opt *options.Configura Cond: f.Cond, CondTest: f.CondTest, } + case "do-log": + rule = &actions.DoLog{ + Cond: f.Cond, + CondTest: f.CondTest, + } } return rule, nil } diff --git a/configuration/tcp_request_rule.go b/configuration/tcp_request_rule.go index f5687056..4011b2ed 100644 --- a/configuration/tcp_request_rule.go +++ b/configuration/tcp_request_rule.go @@ -412,6 +412,10 @@ func ParseTCPRequestRule(f types.TCPType) (*models.TCPRequestRule, error) { //no rule.VarName = a.Name rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.DoLog: + rule.Action = models.TCPRequestRuleActionDoDashLog + rule.Cond = a.Cond + rule.CondTest = a.CondTest default: return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", a)) } @@ -626,6 +630,10 @@ func ParseTCPRequestRule(f types.TCPType) (*models.TCPRequestRule, error) { //no rule.Expr = a.Expr.String() rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.DoLog: + rule.Action = models.TCPRequestRuleActionDoDashLog + rule.Cond = a.Cond + rule.CondTest = a.CondTest default: return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", a)) } @@ -760,6 +768,10 @@ func ParseTCPRequestRule(f types.TCPType) (*models.TCPRequestRule, error) { //no rule.RstTTL = a.RstTTL rule.Cond = a.Cond rule.CondTest = a.CondTest + case *actions.DoLog: + rule.Action = models.TCPRequestRuleActionDoDashLog + rule.Cond = a.Cond + rule.CondTest = a.CondTest default: return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", a)) } @@ -991,6 +1003,13 @@ func SerializeTCPRequestRule(f models.TCPRequestRule, opt *options.Configuration CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionDoDashLog: + return &tcp_types.Connection{ + Action: &actions.DoLog{ + 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: @@ -1301,6 +1320,13 @@ func SerializeTCPRequestRule(f models.TCPRequestRule, opt *options.Configuration CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionDoDashLog: + return &tcp_types.Content{ + Action: &actions.DoLog{ + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil } return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", f.Action)) case models.TCPRequestRuleTypeSession: @@ -1500,6 +1526,13 @@ func SerializeTCPRequestRule(f models.TCPRequestRule, opt *options.Configuration CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionDoDashLog: + return &tcp_types.Session{ + Action: &actions.DoLog{ + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil } return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%s' in tcp_request_rule", f.Action)) case models.TCPRequestRuleTypeInspectDashDelay: diff --git a/configuration/tcp_response_rule.go b/configuration/tcp_response_rule.go index 08ba0f06..3f25ea4c 100644 --- a/configuration/tcp_response_rule.go +++ b/configuration/tcp_response_rule.go @@ -458,6 +458,13 @@ func ParseTCPResponseRule(t types.TCPType) (*models.TCPResponseRule, error) { Cond: a.Cond, CondTest: a.CondTest, }, nil + case *actions.DoLog: + return &models.TCPResponseRule{ + Type: models.TCPResponseRuleTypeContent, + Action: models.TCPResponseRuleActionDoDashLog, + Cond: a.Cond, + CondTest: a.CondTest, + }, nil } } return nil, NewConfError(ErrValidationError, "invalid action") @@ -676,6 +683,13 @@ func SerializeTCPResponseRule(t models.TCPResponseRule, opt *options.Configurati CondTest: t.CondTest, }, }, nil + case models.TCPResponseRuleActionDoDashLog: + return &tcp_types.Content{ + Action: &actions.DoLog{ + Cond: t.Cond, + CondTest: t.CondTest, + }, + }, nil } case models.TCPResponseRuleTypeInspectDashDelay: if t.Timeout != nil { diff --git a/models/http_after_response_rule.go b/models/http_after_response_rule.go index 7ddf6141..af460710 100644 --- a/models/http_after_response_rule.go +++ b/models/http_after_response_rule.go @@ -127,8 +127,8 @@ type HTTPAfterResponseRule struct { // type // Required: true - // Enum: ["add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var"] - // +kubebuilder:validation:Enum="add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var"; + // Enum: ["add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var","do-log"] + // +kubebuilder:validation:Enum="add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var","do-log"; Type string `json:"type"` // var expr @@ -449,7 +449,7 @@ var httpAfterResponseRuleTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["add-header","allow","capture","del-acl","del-header","del-map","replace-header","replace-value","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","set-header","set-log-level","set-map","set-status","set-var","set-var-fmt","strict-mode","unset-var","do-log"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -524,6 +524,9 @@ const ( // HTTPAfterResponseRuleTypeUnsetDashVar captures enum value "unset-var" HTTPAfterResponseRuleTypeUnsetDashVar string = "unset-var" + + // HTTPAfterResponseRuleTypeDoDashLog captures enum value "do-log" + HTTPAfterResponseRuleTypeDoDashLog string = "do-log" ) // prop value enum diff --git a/models/http_request_rule.go b/models/http_request_rule.go index 644ac35a..f1883ece 100644 --- a/models/http_request_rule.go +++ b/models/http_request_rule.go @@ -296,8 +296,8 @@ type HTTPRequestRule struct { // type // Required: true - // Enum: ["add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries"] - // +kubebuilder:validation:Enum="add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries"; + // Enum: ["add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries","do-log"] + // +kubebuilder:validation:Enum="add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries","do-log"; Type string `json:"type"` // uri fmt @@ -1252,7 +1252,7 @@ var httpRequestRuleTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["add-acl","add-header","allow","auth","cache-use","capture","del-acl","del-header","del-map","deny","disable-l7-retry","do-resolve","early-hint","lua","normalize-uri","redirect","reject","replace-header","replace-path","replace-pathq","replace-uri","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-bc-mark","set-bc-tos","set-dst","set-dst-port","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-method","set-nice","set-path","set-pathq","set-priority-class","set-priority-offset","set-query","set-src","set-src-port","set-timeout","set-tos","set-uri","set-var","silent-drop","strict-mode","tarpit","track-sc","unset-var","use-service","wait-for-body","wait-for-handshake","set-bandwidth-limit","set-retries","do-log"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -1450,6 +1450,9 @@ const ( // HTTPRequestRuleTypeSetDashRetries captures enum value "set-retries" HTTPRequestRuleTypeSetDashRetries string = "set-retries" + + // HTTPRequestRuleTypeDoDashLog captures enum value "do-log" + HTTPRequestRuleTypeDoDashLog string = "do-log" ) // prop value enum diff --git a/models/http_response_rule.go b/models/http_response_rule.go index 89119b2e..fdae1d82 100644 --- a/models/http_response_rule.go +++ b/models/http_response_rule.go @@ -248,8 +248,8 @@ type HTTPResponseRule struct { // type // Required: true - // Enum: ["add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit"] - // +kubebuilder:validation:Enum="add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit"; + // Enum: ["add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit","do-log"] + // +kubebuilder:validation:Enum="add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit","do-log"; Type string `json:"type"` // var expr @@ -1012,7 +1012,7 @@ var httpResponseRuleTypeTypePropEnum []interface{} func init() { var res []string - if err := json.Unmarshal([]byte(`["add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["add-acl","add-header","allow","cache-store","capture","del-acl","del-header","del-map","deny","lua","redirect","replace-header","replace-value","return","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","sc-set-gpt0","send-spoe-group","set-fc-mark","set-fc-tos","set-header","set-log-level","set-map","set-mark","set-nice","set-status","set-timeout","set-tos","set-var","set-var-fmt","silent-drop","strict-mode","track-sc","unset-var","wait-for-body","set-bandwidth-limit","do-log"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -1138,6 +1138,9 @@ const ( // HTTPResponseRuleTypeSetDashBandwidthDashLimit captures enum value "set-bandwidth-limit" HTTPResponseRuleTypeSetDashBandwidthDashLimit string = "set-bandwidth-limit" + + // HTTPResponseRuleTypeDoDashLog captures enum value "do-log" + HTTPResponseRuleTypeDoDashLog string = "do-log" ) // prop value enum diff --git a/models/tcp_request_rule.go b/models/tcp_request_rule.go index ee3e07b7..a768e985 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-gpt","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-sc","unset-var","use-service","set-retries"] - // +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-gpt","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-sc","unset-var","use-service","set-retries"; + // 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-gpt","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-sc","unset-var","use-service","set-retries","do-log"] + // +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-gpt","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-sc","unset-var","use-service","set-retries","do-log"; Action string `json:"action,omitempty"` // bandwidth limit limit @@ -235,7 +235,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-gpt","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-sc","unset-var","use-service","set-retries"]`), &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-gpt","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-sc","unset-var","use-service","set-retries","do-log"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -358,6 +358,9 @@ const ( // TCPRequestRuleActionSetDashRetries captures enum value "set-retries" TCPRequestRuleActionSetDashRetries string = "set-retries" + + // TCPRequestRuleActionDoDashLog captures enum value "do-log" + TCPRequestRuleActionDoDashLog string = "do-log" ) // prop value enum diff --git a/models/tcp_response_rule.go b/models/tcp_response_rule.go index 258be7bf..db100600 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-gpt","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-gpt","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"; + // Enum: ["accept","close","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","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","do-log"] + // +kubebuilder:validation:Enum="accept","close","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","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","do-log"; Action string `json:"action,omitempty"` // bandwidth limit limit @@ -202,7 +202,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-gpt","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 { + if err := json.Unmarshal([]byte(`["accept","close","lua","reject","sc-add-gpc","sc-inc-gpc","sc-inc-gpc0","sc-inc-gpc1","sc-set-gpt","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","do-log"]`), &res); err != nil { panic(err) } for _, v := range res { @@ -277,6 +277,9 @@ const ( // TCPResponseRuleActionUnsetDashVar captures enum value "unset-var" TCPResponseRuleActionUnsetDashVar string = "unset-var" + + // TCPResponseRuleActionDoDashLog captures enum value "do-log" + TCPResponseRuleActionDoDashLog string = "do-log" ) // prop value enum diff --git a/specification/build/haproxy_spec.yaml b/specification/build/haproxy_spec.yaml index 977a81f2..a6d677c9 100644 --- a/specification/build/haproxy_spec.yaml +++ b/specification/build/haproxy_spec.yaml @@ -5115,6 +5115,7 @@ definitions: - wait-for-handshake - set-bandwidth-limit - set-retries + - do-log type: string x-nullable: false uri-fmt: @@ -5679,6 +5680,7 @@ definitions: - unset-var - wait-for-body - set-bandwidth-limit + - do-log type: string x-nullable: false var_expr: @@ -5975,6 +5977,7 @@ definitions: - set-var-fmt - strict-mode - unset-var + - do-log type: string x-nullable: false var_expr: @@ -6424,6 +6427,7 @@ definitions: - unset-var - use-service - set-retries + - do-log type: string x-dependency: type: @@ -6904,6 +6908,7 @@ definitions: - set-var-fmt - silent-drop - unset-var + - do-log type: string x-dependency: type: diff --git a/specification/models/configuration/http/after_response.yaml b/specification/models/configuration/http/after_response.yaml index 1aff8dfc..b4d7b25c 100644 --- a/specification/models/configuration/http/after_response.yaml +++ b/specification/models/configuration/http/after_response.yaml @@ -31,6 +31,7 @@ http_after_response_rule: - set-var-fmt - strict-mode - unset-var + - do-log x-nullable: false capture_sample: pattern: '^(?:[A-Za-z]+\("([A-Za-z\s]+)"\)|[A-Za-z]+)' diff --git a/specification/models/configuration/http/request.yaml b/specification/models/configuration/http/request.yaml index 344b355f..7b708c68 100644 --- a/specification/models/configuration/http/request.yaml +++ b/specification/models/configuration/http/request.yaml @@ -72,6 +72,7 @@ http_request_rule: - wait-for-handshake - set-bandwidth-limit - set-retries + - do-log x-nullable: false capture_sample: pattern: '^(?:[A-Za-z]+\("([A-Za-z\s]+)"\)|[A-Za-z]+)' diff --git a/specification/models/configuration/http/response.yaml b/specification/models/configuration/http/response.yaml index 69413a9a..9cc6449f 100644 --- a/specification/models/configuration/http/response.yaml +++ b/specification/models/configuration/http/response.yaml @@ -48,6 +48,7 @@ http_response_rule: - unset-var - wait-for-body - set-bandwidth-limit + - do-log x-nullable: false capture_sample: type: string diff --git a/specification/models/configuration/tcp/request.yaml b/specification/models/configuration/tcp/request.yaml index c4b734b9..fe6db675 100644 --- a/specification/models/configuration/tcp/request.yaml +++ b/specification/models/configuration/tcp/request.yaml @@ -51,6 +51,7 @@ tcp_request_rule: - unset-var - use-service - set-retries + - do-log x-nullable: false x-dependency: type: diff --git a/specification/models/configuration/tcp/response.yaml b/specification/models/configuration/tcp/response.yaml index bd530f94..20862cf9 100644 --- a/specification/models/configuration/tcp/response.yaml +++ b/specification/models/configuration/tcp/response.yaml @@ -35,6 +35,7 @@ tcp_response_rule: - set-var-fmt - silent-drop - unset-var + - do-log x-nullable: false x-dependency: type: diff --git a/test/configuration_test.go b/test/configuration_test.go index c286321a..e15d538b 100644 --- a/test/configuration_test.go +++ b/test/configuration_test.go @@ -483,6 +483,8 @@ frontend test http-request sc-set-gpt(1,2) hdr(Host),lower if FALSE http-request set-retries 3 http-request set-retries var(txn.retries) if TRUE + http-request do-log + http-request do-log if FALSE http-response allow if src 192.168.0.0/16 http-response set-header X-SSL %[ssl_fc] http-response set-var(req.my_var) req.fhdr(user-agent),lower @@ -519,6 +521,8 @@ frontend test http-response set-timeout tunnel 20 http-response set-timeout client 20 http-response sc-set-gpt(1,2) 1234 if FALSE + http-response do-log + http-response do-log if FALSE http-after-response set-map(map.lst) %[src] %[res.hdr(X-Value)] http-after-response del-map(map.lst) %[src] if FALSE http-after-response del-acl(map.lst) %[src] if FALSE @@ -536,6 +540,8 @@ frontend test http-after-response set-var(sess.last_redir) res.hdr(location) http-after-response unset-var(sess.last_redir) http-after-response sc-set-gpt(1,2) hdr(port) if FALSE + http-after-response do-log + http-after-response do-log if FALSE http-error status 400 content-type application/json lf-file /var/errors.file tcp-request connection accept if TRUE tcp-request connection reject if FALSE @@ -584,6 +590,12 @@ frontend test tcp-request session sc-set-gpt(1,2) 1234 tcp-request content set-retries 3 tcp-request content set-retries var(txn.retries) if TRUE + tcp-request connection do-log + tcp-request connection do-log if FALSE + tcp-request session do-log + tcp-request session do-log if FALSE + tcp-request content do-log + tcp-request content do-log if FALSE log global no log log 127.0.0.1:514 local0 notice notice @@ -731,6 +743,8 @@ backend test tcp-response content set-fc-mark 7676 if TRUE tcp-response content set-fc-tos 0xab if FALSE tcp-response content sc-set-gpt(1,2) 1234 + tcp-response content do-log + tcp-response content do-log if FALSE option contstats timeout check 2s timeout tunnel 5s diff --git a/test/expected/structured.json b/test/expected/structured.json index ac547eec..1a3bafb5 100644 --- a/test/expected/structured.json +++ b/test/expected/structured.json @@ -927,6 +927,16 @@ "sc_id": 1, "sc_idx": 2, "sc_int": 1234 + }, + { + "type": "content", + "action": "do-log" + }, + { + "type": "content", + "action": "do-log", + "cond": "if", + "cond_test": "FALSE" } ], "server_templates": { @@ -1672,6 +1682,14 @@ "sc_expr": "hdr(port)", "cond": "if", "cond_test": "FALSE" + }, + { + "type": "do-log" + }, + { + "type": "do-log", + "cond": "if", + "cond_test": "FALSE" } ], "http_error_rule_list": [ @@ -2021,6 +2039,14 @@ "expr": "var(txn.retries)", "cond": "if", "cond_test": "TRUE" + }, + { + "type": "do-log" + }, + { + "type": "do-log", + "cond": "if", + "cond_test": "FALSE" } ], "http_response_rule_list": [ @@ -2255,6 +2281,14 @@ "sc_int": 1234, "cond": "if", "cond_test": "FALSE" + }, + { + "type": "do-log" + }, + { + "type": "do-log", + "cond": "if", + "cond_test": "FALSE" } ], "log_target_list": [ @@ -2604,6 +2638,36 @@ "expr": "var(txn.retries)", "cond": "if", "cond_test": "TRUE" + }, + { + "type": "connection", + "action": "do-log" + }, + { + "type": "connection", + "action": "do-log", + "cond": "if", + "cond_test": "FALSE" + }, + { + "type": "session", + "action": "do-log" + }, + { + "type": "session", + "action": "do-log", + "cond": "if", + "cond_test": "FALSE" + }, + { + "type": "content", + "action": "do-log" + }, + { + "type": "content", + "action": "do-log", + "cond": "if", + "cond_test": "FALSE" } ], "binds": {