aboutsummaryrefslogtreecommitdiff
path: root/peer/messages.go
diff options
context:
space:
mode:
Diffstat (limited to 'peer/messages.go')
-rw-r--r--peer/messages.go9
1 files changed, 6 insertions, 3 deletions
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[:])