From 73efd0495a823ab7b9a6b6a0a269d3516c52686f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 28 Jul 2016 00:17:54 +0200 Subject: Tweak Handshake --- peer/messages.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'peer/messages.go') diff --git a/peer/messages.go b/peer/messages.go index b2bbfc2..6cedecc 100644 --- a/peer/messages.go +++ b/peer/messages.go @@ -1,6 +1,9 @@ package peer -import "io" +import ( + "encoding/binary" + "io" +) type Message int @@ -38,8 +41,8 @@ type Handshake struct { } func (h Handshake) Encode(w io.Writer) { - l := len(h.Proto) - w.Write([]byte{byte(l)}) + l := int8(len(h.Proto)) + binary.Write(w, binary.BigEndian, l) w.Write([]byte(h.Proto)) w.Write(h.Flags[:]) w.Write(h.InfoHash[:]) -- cgit v1.2.3