gottdad/main.go
2020-06-14 22:07:45 +02:00

52 lines
1.1 KiB
Go

package main
import (
"bufio"
"net"
)
func main() {
conn, err := net.Dial("tcp", "poop.siteop.biz:3977")
failError(err, "net.Dial")
logInfoDebug("Connected to poop.siteop.biz:3977")
//send auth
p := PacketAdminJoin{
Packet: Packet{PType: AdminPacketAdminJoin},
Password: "plop",
AppName: "gottdad",
AppVersion: "alpha",
}
_, err = conn.Write(p.Bytes())
failError(err, "conn.Write")
logInfoDebug("Authentication sent (%v)", p.Bytes())
for {
p := Packet{}
b, err := conn.ReadByte()
logErrorDebug(err, "conn.ReadByte")
p.PLength = uint8(b) << 8
b, err = conn.ReadByte()
logErrorDebug(err, "conn.ReadByte")
p.PLength += uint8(b)
b, err = conn.ReadByte()
logErrorDebug(err, "conn.ReadByte")
p.PType = uint8(b)
if p.PLength <= 3 {
logInfoAlert("Wrong packet length")
break
}
d := make([]byte, p.PLength-3)
for {
_, err := conn.Read(d[len(d):])
logErrorDebug(err, "conn.Read")
if len(d) == int(p.PLength-3) {
break
}
}
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
}
}