feat wip: bump protocol version & quic-go version, frag & defrag implementation

This commit is contained in:
Toby
2022-02-25 00:14:22 -08:00
parent 52bcc1d57b
commit 6efa976a56
5 changed files with 428 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import (
)
const (
protocolVersion = uint8(2)
protocolVersion = uint8(3)
protocolTimeout = 10 * time.Second
closeErrorCodeGeneric = 0
@@ -50,6 +50,17 @@ type udpMessage struct {
HostLen uint16 `struc:"sizeof=Host"`
Host string
Port uint16
MsgID uint16 // doesn't matter when not fragmented
FragID uint8 // doesn't matter when not fragmented, starts at 0 when fragmented
FragCount uint8 // must be 1 when not fragmented
DataLen uint16 `struc:"sizeof=Data"`
Data []byte
}
func (m udpMessage) HeaderSize() int {
return 4 + 2 + len(m.Host) + 2 + 2 + 1 + 1 + 2
}
func (m udpMessage) Size() int {
return m.HeaderSize() + len(m.Data)
}