mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-29 23:30:37 +08:00
add log
This commit is contained in:
@@ -2,12 +2,14 @@ package head
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/fumiama/WireGold/helper"
|
"github.com/fumiama/WireGold/helper"
|
||||||
blake2b "github.com/minio/blake2b-simd"
|
blake2b "github.com/minio/blake2b-simd"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Packet 是发送和接收的最小单位
|
// Packet 是发送和接收的最小单位
|
||||||
@@ -137,5 +139,6 @@ func (p *Packet) FillHash() {
|
|||||||
// IsVaildHash 验证 packet 合法性
|
// IsVaildHash 验证 packet 合法性
|
||||||
func (p *Packet) IsVaildHash() bool {
|
func (p *Packet) IsVaildHash() bool {
|
||||||
sum := blake2b.New256().Sum(p.Data)
|
sum := blake2b.New256().Sum(p.Data)
|
||||||
|
logrus.Debugln("[packet] sum really:", hex.EncodeToString(sum), "sum in hash:", hex.EncodeToString(p.Hash[:]))
|
||||||
return *(*[32]byte)(*(*unsafe.Pointer)(unsafe.Pointer(&sum))) == p.Hash
|
return *(*[32]byte)(*(*unsafe.Pointer)(unsafe.Pointer(&sum))) == p.Hash
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user