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

feat(p2p): change magic of tcp

This commit is contained in:
源文雨
2024-08-03 14:55:23 +08:00
parent ecff222074
commit 08688b584b

View File

@@ -23,13 +23,10 @@ const (
packetTypeTop packetTypeTop
) )
const magic = 0x12d3fde9 var (
magicbuf = []byte("GET ")
var magicbuf [4]byte magic = binary.LittleEndian.Uint32(magicbuf)
)
func init() {
binary.LittleEndian.PutUint32(magicbuf[:], magic)
}
type packet struct { type packet struct {
typ packetType typ packetType
@@ -44,7 +41,7 @@ func (p *packet) pack() (net.Buffers, func()) {
w.WriteByte(byte(p.typ)) w.WriteByte(byte(p.typ))
w.WriteUInt16(p.len) w.WriteUInt16(p.len)
}) })
return net.Buffers{magicbuf[:], d, p.dat}, cl return net.Buffers{magicbuf, d, p.dat}, cl
} }
func (p *packet) Read(_ []byte) (int, error) { func (p *packet) Read(_ []byte) (int, error) {