test
This commit is contained in:
parent
f6c99c60c3
commit
856d7c4b4e
9
main.go
9
main.go
@ -20,16 +20,17 @@ func main() {
|
|||||||
_, err = conn.Write(p.Bytes())
|
_, err = conn.Write(p.Bytes())
|
||||||
failError(err, "conn.Write")
|
failError(err, "conn.Write")
|
||||||
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
||||||
|
r := bufio.NewReader(conn)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
p := Packet{}
|
p := Packet{}
|
||||||
b, err := conn.ReadByte()
|
b, err := r.ReadByte()
|
||||||
logErrorDebug(err, "conn.ReadByte")
|
logErrorDebug(err, "conn.ReadByte")
|
||||||
p.PLength = uint8(b) << 8
|
p.PLength = uint8(b) << 8
|
||||||
b, err = conn.ReadByte()
|
b, err = r.ReadByte()
|
||||||
logErrorDebug(err, "conn.ReadByte")
|
logErrorDebug(err, "conn.ReadByte")
|
||||||
p.PLength += uint8(b)
|
p.PLength += uint8(b)
|
||||||
b, err = conn.ReadByte()
|
b, err = r.ReadByte()
|
||||||
logErrorDebug(err, "conn.ReadByte")
|
logErrorDebug(err, "conn.ReadByte")
|
||||||
p.PType = uint8(b)
|
p.PType = uint8(b)
|
||||||
if p.PLength <= 3 {
|
if p.PLength <= 3 {
|
||||||
@ -39,7 +40,7 @@ func main() {
|
|||||||
d := make([]byte, p.PLength-3)
|
d := make([]byte, p.PLength-3)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
_, err := conn.Read(d[len(d):])
|
_, err := r.Read(d[len(d):])
|
||||||
logErrorDebug(err, "conn.Read")
|
logErrorDebug(err, "conn.Read")
|
||||||
if len(d) == int(p.PLength-3) {
|
if len(d) == int(p.PLength-3) {
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user