gottdad/main.go
2020-06-14 22:20:19 +02:00

59 lines
1.2 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())
r := bufio.NewReader(conn)
b := make([]byte, 65536)
_, err := r.Read(b)
logInfoDebug("r.Read : %v", b)
/*
for {
p := Packet{}
b, err := r.ReadByte()
logErrorDebug(err, "r.ReadByte")
p.PLength = uint16(b) << 8
b, err = r.ReadByte()
logErrorDebug(err, "r.ReadByte")
p.PLength += uint16(b)
b, err = r.ReadByte()
logErrorDebug(err, "r.ReadByte")
p.PType = uint8(b)
if p.PLength <= 3 {
logInfoAlert("Wrong packet length")
break
}
d := make([]byte, p.PLength-3)
for {
_, err := r.Read(d[len(d):])
logErrorDebug(err, "r.Read")
if len(d) == int(p.PLength-3) {
break
}
}
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
}
*/
}