test
This commit is contained in:
parent
fc76b1eeab
commit
db63390c5f
50
main.go
50
main.go
@ -22,31 +22,37 @@ func main() {
|
|||||||
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
||||||
r := bufio.NewReader(conn)
|
r := bufio.NewReader(conn)
|
||||||
|
|
||||||
for {
|
b := make([]byte, 65536)
|
||||||
p := Packet{}
|
_, err := r.Read(b)
|
||||||
b, err := r.ReadByte()
|
logInfoDebug("r.Read : %v", b)
|
||||||
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)
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
_, err := r.Read(d[len(d):])
|
p := Packet{}
|
||||||
logErrorDebug(err, "conn.Read")
|
b, err := r.ReadByte()
|
||||||
if len(d) == int(p.PLength-3) {
|
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
|
break
|
||||||
}
|
}
|
||||||
}
|
d := make([]byte, p.PLength-3)
|
||||||
logInfoDebug("Packet read : len : %d / type : %d", p.PLength, p.PType)
|
|
||||||
|
|
||||||
}
|
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)
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user