From 0c55c63ed9f70b99de3e88cda1abd3b2f08e89d3 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sun, 22 Oct 2023 14:44:48 +0800 Subject: [PATCH 1/4] FIX:Repeated sslhandshake in [tcp-log] plugin --- kong/plugins/tcp-log/handler.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kong/plugins/tcp-log/handler.lua b/kong/plugins/tcp-log/handler.lua index 3bfc9c7c3bfd..06fddb1a0765 100644 --- a/kong/plugins/tcp-log/handler.lua +++ b/kong/plugins/tcp-log/handler.lua @@ -31,8 +31,15 @@ local function log(premature, conf, message) return end - if conf.tls then - ok, err = sock:sslhandshake(true, conf.tls_sni, false) + local times, err = sock:getreusedtimes() + if not times then + kong.log.err("failed to get socket reused time to ", host, ":", tostring(port), ": ", err) + sock:close() + return + end + + if conf.tls and times == 0 then + ok, err = sock:sslhandshake(false, conf.tls_sni, false) if not ok then kong.log.err("failed to perform TLS handshake to ", host, ":", port, ": ", err) sock:close() From d32b70e71e8bca87dbc04e5f17a8023b34f31346 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 23 Oct 2023 20:25:23 +0800 Subject: [PATCH 2/4] add changelog --- changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml diff --git a/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml new file mode 100644 index 000000000000..43fb1693b736 --- /dev/null +++ b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml @@ -0,0 +1,3 @@ +message: fix an issue that repeated ssl handshake in tcp-log plugin +type: bugfix +scope: Plugin From 75fc9028e28206a71fd7f06e94e15ed4bd74c113 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 24 Oct 2023 23:00:47 +0800 Subject: [PATCH 3/4] update message as the comments --- changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml index 43fb1693b736..6dcea84080b2 100644 --- a/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml +++ b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml @@ -1,3 +1,3 @@ -message: fix an issue that repeated ssl handshake in tcp-log plugin +message: **tcp-log**: fix an issue that repeated ssl handshake type: bugfix scope: Plugin From c30c604d0609f8f3c104c44636e52b48125303d3 Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 25 Oct 2023 05:37:59 +0800 Subject: [PATCH 4/4] Update changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml Co-authored-by: tzssangglass --- changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml index 6dcea84080b2..f712729860e3 100644 --- a/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml +++ b/changelog/unreleased/kong/fix-tcp-log-sslhandshake.yml @@ -1,3 +1,3 @@ -message: **tcp-log**: fix an issue that repeated ssl handshake +message: "**tcp-log**: fix an issue that repeated ssl handshake" type: bugfix scope: Plugin