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

This commit is contained in:
lanrenwo 2023-09-03 11:18:52 +08:00 committed by GitHub
parent 7651b69ed6
commit f6980261d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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