This commit is contained in:
shoopea 2020-06-14 22:39:17 +02:00
parent 98ee832598
commit e9b8332d84

43
main.go
View File

@ -2,6 +2,7 @@ package main
import ( import (
"bufio" "bufio"
"encoding/binary"
"net" "net"
) )
@ -21,38 +22,42 @@ func main() {
failError(err, "conn.Write") failError(err, "conn.Write")
logInfoDebug("Authentication sent (%v)", p.Bytes()) logInfoDebug("Authentication sent (%v)", p.Bytes())
r := bufio.NewReader(conn) r := bufio.NewReader(conn)
b := make([]byte, 0xFFFF)
b := make([]byte, 65536) read := 0
_, err = r.Read(b) n := 0
logInfoDebug("r.Read : %v", b)
/*
for { for {
p := Packet{} p := Packet{}
b, err := r.ReadByte()
logErrorDebug(err, "r.ReadByte") for {
p.PLength = uint16(b) << 8 n, err = r.Read(b[read:])
b, err = r.ReadByte() logErrorDebug(err, "r.Read")
logErrorDebug(err, "r.ReadByte") read += n
p.PLength += uint16(b) if read >= 3 {
b, err = r.ReadByte() break
logErrorDebug(err, "r.ReadByte") }
p.PType = uint8(b) }
p.PLength = binary.LittleEndian.Uint16(b[0:])
p.PType = b[2]
if p.PLength <= 3 { if p.PLength <= 3 {
logInfoAlert("Wrong packet length") logInfoAlert("Wrong packet length")
break break
} }
d := make([]byte, p.PLength-3)
for { for {
_, err := r.Read(d[len(d):]) n, err = r.Read(b[read:])
logErrorDebug(err, "r.Read") logErrorDebug(err, "r.Read")
if len(d) == int(p.PLength-3) { read += n
if read >= p.PLength {
break break
} }
} }
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
c := make([]byte, 0xFFFF)
copy(c, b[p.PLength:])
b = c
read -= p.PLength
} }
*/
} }