1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-06-12 04:43:22 +08:00

feat(head): use uniform head extract & crc64 -> md5

This commit is contained in:
源文雨
2024-08-08 12:42:04 +08:00
parent e018aee705
commit d5d7a9412f
5 changed files with 63 additions and 39 deletions

34
gold/head/flags.go Normal file
View File

@@ -0,0 +1,34 @@
package head
import "encoding/binary"
type PacketFlags uint16
func (pf PacketFlags) IsValid() bool {
return pf&0x8000 == 0
}
func (pf PacketFlags) DontFrag() bool {
return pf&0x4000 == 0x4000
}
func (pf PacketFlags) NoFrag() bool {
return pf == 0x4000
}
func (pf PacketFlags) IsSingle() bool {
return pf == 0
}
func (pf PacketFlags) ZeroOffset() bool {
return pf&0x1fff == 0
}
func (pf PacketFlags) Offset() uint16 {
return uint16(pf << 3)
}
// Flags extract flags from raw data
func Flags(data []byte) PacketFlags {
return PacketFlags(binary.LittleEndian.Uint16(data[10:12]))
}