From 6127c41aeaca5b0311b5812fec10dd4798103378 Mon Sep 17 00:00:00 2001 From: bjdgyc Date: Fri, 1 Sep 2023 17:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/payload_access_audit.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/handler/payload_access_audit.go b/server/handler/payload_access_audit.go index 4384352..89f3450 100644 --- a/server/handler/payload_access_audit.go +++ b/server/handler/payload_access_audit.go @@ -106,6 +106,7 @@ func logAudit(userName string, pl *sessdata.Payload) { if !(pl.LType == sessdata.LTypeIPData && pl.PType == 0x00) { return } + ipProto := waterutil.IPv4Protocol(pl.Data) // 访问协议 var accessProto uint8 @@ -121,7 +122,15 @@ func logAudit(userName string, pl *sessdata.Payload) { ipSrc := waterutil.IPv4Source(pl.Data) ipDst := waterutil.IPv4Destination(pl.Data) - ipPort := waterutil.IPv4DestinationPort(pl.Data) + + // ipPort := waterutil.IPv4DestinationPort(pl.Data) + // 修复 panic: runtime error: index out of range [2] with length 2 + ipPl := waterutil.IPv4Payload(pl.Data) + if len(ipPl) < 3 { + base.Error("ipPl len < 3", pl.Data) + return + } + ipPort := (uint16(ipPl[2]) << 8) | uint16(ipPl[3]) b := getByte51() key := *b