This commit is contained in:
shoopea 2020-06-14 17:23:07 +02:00
parent 330a7c6216
commit 6ddec0775c

13
def.go
View File

@ -2,7 +2,7 @@ package main
import ( import (
"bytes" "bytes"
"encoding/gob" "encoding/binary"
) )
const ( const (
@ -58,12 +58,13 @@ type PacketAdminJoin struct {
func (p *PacketAdminJoin) Bytes() []byte { func (p *PacketAdminJoin) Bytes() []byte {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
buf.Reset()
p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 3) p.PLength = uint16(len(p.Password) + len(p.AppName) + len(p.AppVersion) + 3)
err := enc.Encode(p)
logErrorDebug(err, "enc.Encode") buf.WriteByte(p.PLength)
buf.WriteByte(p.PType)
buf.WriteString(p.Password)
buf.WriteString(p.AppName)
buf.WriteString(p.AppVersion)
return buf.Bytes() return buf.Bytes()
} }