This commit is contained in:
aozhiwei 2023-08-10 22:26:17 +08:00
parent e2ac9b3814
commit 78c774542b

View File

@ -59,21 +59,22 @@ func (this *WSPListener_) accept() {
*/
func (this *WSPListener_) socketRead(conn net.Conn) {
buf := make([]byte, 1024 * 64)
//recvBuf := make([]byte, 1024 * 64)
recvBuf := make([]byte, 1024 * 64 * 2)
offset := 0
for {
bufLen, err := conn.Read(buf)
if err == nil && bufLen > 0 {
copy(buf[:bufLen], recvBuf[offset:])
warning := false
for bufLen - offset >= 12 {
packLen := int(buf[0]) >> 16 + int(buf[1])
if buf[8] == 'K' && buf[9] == 'S' {
packLen := int(recvBuf[0]) >> 16 + int(recvBuf[1])
if recvBuf[8] == 'K' && recvBuf[9] == 'S' {
if bufLen - offset < 12 + packLen {
continue
}
hdr := new(q5.MsgHdr)
hdr.MsgId = int(buf[0]) >> 16 + int(buf[1])
hdr.SeqId = int(buf[0]) >> 16 + int(buf[1])
hdr.MsgId = int(recvBuf[0]) >> 16 + int(recvBuf[1])
hdr.SeqId = int(recvBuf[0]) >> 16 + int(recvBuf[1])
offset += 12 + packLen
} else {
warning = true
@ -81,6 +82,7 @@ func (this *WSPListener_) socketRead(conn net.Conn) {
continue
}
}
copy(recvBuf[:offset], recvBuf[:])
if warning {
f5.SysLog().Warning("收到client非法数据包")
}