Initial commit

This commit is contained in:
Zam
2023-10-10 09:21:06 +02:00
commit edd4a9a760
8 changed files with 563 additions and 0 deletions

34
internal/packets.go Normal file
View File

@@ -0,0 +1,34 @@
package packets
type Packet struct {
header Header
data Data
}
type Header struct {
headerLength uint32
flag HeaderFlag
sync uint32
dataLength uint32
}
type Data interface {
ToBytes() []byte
}
type StringData string
func (s StringData) ToBytes() []byte {
return []byte(s)
}
type HeaderFlag uint32
const (
Request HeaderFlag = iota
PTE HeaderFlag = iota
Ack HeaderFlag = iota
File HeaderFlag = iota
End HeaderFlag = iota
Resend HeaderFlag = iota
)