From a168c96a935e1065d78c24bdbc9cb37de9b418ae Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Fri, 1 Sep 2023 18:10:20 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsniNewParser=E7=9A=84pani?= =?UTF-8?q?c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload_tcp_parser.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/handler/payload_tcp_parser.go b/server/handler/payload_tcp_parser.go index 6d3c4cc..f2e1c31 100644 --- a/server/handler/payload_tcp_parser.go +++ b/server/handler/payload_tcp_parser.go @@ -32,6 +32,9 @@ func sniNewParser(b []byte) (uint8, string) { if len(b) < 2 || b[0] != 0x16 || b[1] != 0x03 { return acc_proto_tcp, "" } + if len(b) < 6 { + return acc_proto_tcp, "" + } rest := b[5:] restLen := len(rest) if restLen == 0 { From 2af2d273e4725284f255a4f8c2dd486dee7502c0 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Sat, 2 Sep 2023 10:44:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=AE=80=E5=8C=96sniNewParser=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload_tcp_parser.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/handler/payload_tcp_parser.go b/server/handler/payload_tcp_parser.go index f2e1c31..bbb933e 100644 --- a/server/handler/payload_tcp_parser.go +++ b/server/handler/payload_tcp_parser.go @@ -29,10 +29,7 @@ func onTCP(payload []byte) (uint8, string) { } func sniNewParser(b []byte) (uint8, string) { - if len(b) < 2 || b[0] != 0x16 || b[1] != 0x03 { - return acc_proto_tcp, "" - } - if len(b) < 6 { + if len(b) < 6 || b[0] != 0x16 || b[1] != 0x03 { return acc_proto_tcp, "" } rest := b[5:] From 7651b69ed636649161c36f0613719d69960b4b6c Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Sat, 2 Sep 2023 10:46:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4sniNewParser=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E7=9A=84=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload_tcp_parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/handler/payload_tcp_parser.go b/server/handler/payload_tcp_parser.go index bbb933e..95c9a0d 100644 --- a/server/handler/payload_tcp_parser.go +++ b/server/handler/payload_tcp_parser.go @@ -31,7 +31,7 @@ func onTCP(payload []byte) (uint8, string) { func sniNewParser(b []byte) (uint8, string) { if len(b) < 6 || b[0] != 0x16 || b[1] != 0x03 { return acc_proto_tcp, "" - } + } rest := b[5:] restLen := len(rest) if restLen == 0 { From f6980261d456531f69fd8ab92437539d75dd344d Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Sun, 3 Sep 2023 11:18:52 +0800 Subject: [PATCH 4/4] =?UTF-8?q?logAudit=E5=BC=95=E5=85=A5recover,=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E4=B8=BB=E7=A8=8B=E5=BA=8F=E5=B4=A9=E6=BA=83?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload_access_audit.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/handler/payload_access_audit.go b/server/handler/payload_access_audit.go index 89f3450..e703c1c 100644 --- a/server/handler/payload_access_audit.go +++ b/server/handler/payload_access_audit.go @@ -3,6 +3,7 @@ package handler import ( "crypto/md5" "encoding/binary" + "runtime/debug" "time" "github.com/bjdgyc/anylink/base" @@ -101,7 +102,12 @@ func logAuditBatch() { // 解析IP包的数据 func logAudit(userName string, pl *sessdata.Payload) { - defer putPayload(pl) + defer func() { + putPayload(pl) + if err := recover(); err != nil { + base.Error("logAudit is panic: ", err, "\n", string(debug.Stack()), "\n", pl.Data) + } + }() if !(pl.LType == sessdata.LTypeIPData && pl.PType == 0x00) { return