This commit is contained in:
shoopea 2020-06-14 22:05:45 +02:00
parent 1ea23d65f3
commit 362a8ea83b

25
main.go
View File

@ -21,7 +21,26 @@ func main() {
failError(err, "conn.Write") failError(err, "conn.Write")
logInfoDebug("Authentication sent (%v)", p.Bytes()) logInfoDebug("Authentication sent (%v)", p.Bytes())
// listen for reply for {
message, _ := bufio.NewReader(conn).ReadString('\n') p := Packet{}
logInfoDebug("Message from server: %s", message) 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)
}
} }