lib/protocol: Hello message length is an int16

It used to be an int32, but that's unnecessary and the spec now says
int16. Also relaxes the size requirement to that which fits in a signed
int16 instead of limiting to 1024 bytes, to allow for future growth.

As reported in
https://forum.syncthing.net/t/difference-between-documented-and-implemented-protocol/7798

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3406
This commit is contained in:
Jakob Borg
2016-07-17 21:41:20 +00:00
parent 3176629410
commit 7b7e35d339
2 changed files with 19 additions and 9 deletions

View File

@@ -26,9 +26,9 @@ func TestVersion14Hello(t *testing.T) {
t.Fatal(err)
}
hdrBuf := make([]byte, 8)
hdrBuf := make([]byte, 6)
binary.BigEndian.PutUint32(hdrBuf, HelloMessageMagic)
binary.BigEndian.PutUint32(hdrBuf[4:], uint32(len(msgBuf)))
binary.BigEndian.PutUint16(hdrBuf[4:], uint16(len(msgBuf)))
outBuf := new(bytes.Buffer)
outBuf.Write(hdrBuf)