mirror of https://github.com/bjdgyc/anylink.git
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
4f9cc2074a
|
@ -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() {
|
||||
if err := recover(); err != nil {
|
||||
base.Error("logAudit is panic: ", err, "\n", string(debug.Stack()), "\n", pl.Data)
|
||||
}
|
||||
putPayload(pl)
|
||||
}()
|
||||
|
||||
if !(pl.LType == sessdata.LTypeIPData && pl.PType == 0x00) {
|
||||
return
|
||||
|
@ -119,19 +125,15 @@ func logAudit(userName string, pl *sessdata.Payload) {
|
|||
default:
|
||||
return
|
||||
}
|
||||
|
||||
ipSrc := waterutil.IPv4Source(pl.Data)
|
||||
ipDst := waterutil.IPv4Destination(pl.Data)
|
||||
|
||||
// ipPort := waterutil.IPv4DestinationPort(pl.Data)
|
||||
// 修复 panic: runtime error: index out of range [2] with length 2
|
||||
// IP报文只包含头部信息时, 则打印LOG,并退出
|
||||
ipPl := waterutil.IPv4Payload(pl.Data)
|
||||
if len(ipPl) < 3 {
|
||||
base.Error("ipPl len < 3", pl.Data)
|
||||
if len(ipPl) < 4 {
|
||||
base.Error("ipPl len < 4", ipPl, pl.Data)
|
||||
return
|
||||
}
|
||||
ipPort := (uint16(ipPl[2]) << 8) | uint16(ipPl[3])
|
||||
|
||||
ipSrc := waterutil.IPv4Source(pl.Data)
|
||||
ipDst := waterutil.IPv4Destination(pl.Data)
|
||||
b := getByte51()
|
||||
key := *b
|
||||
copy(key[:16], ipSrc)
|
||||
|
@ -187,7 +189,6 @@ func logAudit(userName string, pl *sessdata.Payload) {
|
|||
AccessProto: accessProto,
|
||||
Info: info,
|
||||
}
|
||||
|
||||
select {
|
||||
case logBatch.LogChan <- audit:
|
||||
default:
|
||||
|
|
|
@ -29,7 +29,7 @@ func onTCP(payload []byte) (uint8, string) {
|
|||
}
|
||||
|
||||
func sniNewParser(b []byte) (uint8, string) {
|
||||
if len(b) < 2 || b[0] != 0x16 || b[1] != 0x03 {
|
||||
if len(b) < 6 || b[0] != 0x16 || b[1] != 0x03 {
|
||||
return acc_proto_tcp, ""
|
||||
}
|
||||
rest := b[5:]
|
||||
|
|
Loading…
Reference in New Issue