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:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user