test
This commit is contained in:
parent
98ee832598
commit
e9b8332d84
43
main.go
43
main.go
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/binary"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -21,38 +22,42 @@ func main() {
|
||||
failError(err, "conn.Write")
|
||||
logInfoDebug("Authentication sent (%v)", p.Bytes())
|
||||
r := bufio.NewReader(conn)
|
||||
|
||||
b := make([]byte, 65536)
|
||||
_, err = r.Read(b)
|
||||
logInfoDebug("r.Read : %v", b)
|
||||
/*
|
||||
b := make([]byte, 0xFFFF)
|
||||
read := 0
|
||||
n := 0
|
||||
|
||||
for {
|
||||
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)
|
||||
|
||||
for {
|
||||
n, err = r.Read(b[read:])
|
||||
logErrorDebug(err, "r.Read")
|
||||
read += n
|
||||
if read >= 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
p.PLength = binary.LittleEndian.Uint16(b[0:])
|
||||
p.PType = b[2]
|
||||
if p.PLength <= 3 {
|
||||
logInfoAlert("Wrong packet length")
|
||||
break
|
||||
}
|
||||
d := make([]byte, p.PLength-3)
|
||||
|
||||
for {
|
||||
_, err := r.Read(d[len(d):])
|
||||
n, err = r.Read(b[read:])
|
||||
logErrorDebug(err, "r.Read")
|
||||
if len(d) == int(p.PLength-3) {
|
||||
read += n
|
||||
if read >= p.PLength {
|
||||
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
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user