logAudit引入recover, 防止主程序崩溃.

This commit is contained in:
lanrenwo
2023-09-03 11:18:52 +08:00
committed by GitHub
parent 7651b69ed6
commit f6980261d4

View File

@@ -3,6 +3,7 @@ package handler
import ( import (
"crypto/md5" "crypto/md5"
"encoding/binary" "encoding/binary"
"runtime/debug"
"time" "time"
"github.com/bjdgyc/anylink/base" "github.com/bjdgyc/anylink/base"
@@ -101,7 +102,12 @@ func logAuditBatch() {
// 解析IP包的数据 // 解析IP包的数据
func logAudit(userName string, pl *sessdata.Payload) { 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) { if !(pl.LType == sessdata.LTypeIPData && pl.PType == 0x00) {
return return