This commit is contained in:
shoopea 2020-06-14 22:20:19 +02:00
parent fc76b1eeab
commit db63390c5f

50
main.go
View File

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