mirror of
https://github.com/fumiama/go-registry.git
synced 2026-06-10 03:28:21 +08:00
add ack cmd type
This commit is contained in:
21
cmd.go
21
cmd.go
@@ -20,6 +20,15 @@ const (
|
||||
CMDDAT
|
||||
)
|
||||
|
||||
const (
|
||||
ACKNONE uint8 = iota<<4 + 3
|
||||
ACKSUCC
|
||||
ACKDATA
|
||||
ACKNULL
|
||||
ACKNEQU
|
||||
ACKERRO
|
||||
)
|
||||
|
||||
var (
|
||||
ErrMd5Mismatch = errors.New("cmdpacket.decrypt: md5 mismatch")
|
||||
)
|
||||
@@ -91,13 +100,12 @@ func (c *CmdPacket) Refresh(cmd uint8, data []byte, t *tea.TEA) {
|
||||
c.md5 = md5.Sum(data)
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
func (c *CmdPacket) ClearData() {
|
||||
c.data = nil
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
func (c *CmdPacket) ReadFrom(f io.Reader) (n int64, err error) {
|
||||
if c.cmd > 0 {
|
||||
err = io.EOF
|
||||
return
|
||||
}
|
||||
buf := (*[1 + 1 + 16 + 255]byte)(unsafe.Pointer(&c.rawCmdPacket))
|
||||
cnt, err := io.ReadFull(f, buf[:1+1+16])
|
||||
if err != nil {
|
||||
@@ -152,13 +160,14 @@ func (c *CmdPacket) Decrypt(seq uint8) error {
|
||||
|
||||
//go:nosplit
|
||||
func (c *CmdPacket) Put() {
|
||||
c.cmd = 0
|
||||
c.data = nil
|
||||
pool.Put(c)
|
||||
}
|
||||
|
||||
//go:nosplit
|
||||
func setseq(t *tea.TEA, seq uint8) {
|
||||
*(*uint8)(unsafe.Pointer(uintptr(unsafe.Pointer(t)) + uintptr(15))) = seq
|
||||
*(*uint8)(unsafe.Add(unsafe.Pointer(t), 15)) = seq
|
||||
}
|
||||
|
||||
// TEA encoding sumtable
|
||||
|
||||
Reference in New Issue
Block a user