47 lines
997 B
Go
47 lines
997 B
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)
|
|
d := make([]byte, p.PLength-3)
|
|
|
|
for {
|
|
_, err := conn.Read(d[len(d):])
|
|
logErrorDebug(err, "conn.Read")
|
|
if len(d) == p.PLength-3 {
|
|
break
|
|
}
|
|
}
|
|
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
|
|
}
|
|
}
|