Fixed PeekAll
- added to handleStream for protocol detection
This commit is contained in:
parent
9e2a04c8a7
commit
b122a6091b
|
@ -53,19 +53,11 @@ func (w *WedgeConn) Buffered() int {
|
||||||
func (w *WedgeConn) PeekAll() (buf []byte, err error) {
|
func (w *WedgeConn) PeekAll() (buf []byte, err error) {
|
||||||
loginfo.Println("PeekAll")
|
loginfo.Println("PeekAll")
|
||||||
|
|
||||||
var peek []byte
|
_, err = w.Peek(1)
|
||||||
for {
|
|
||||||
b, err := w.reader.Peek(1)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(peek) > 0 {
|
return nil, err
|
||||||
return peek, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var t byte
|
buf, err = w.Peek(w.Buffered())
|
||||||
t = b[0]
|
return
|
||||||
|
|
||||||
peek = append(peek, t)
|
|
||||||
loginfo.Println("len", len(peek))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,12 +167,7 @@ func handleStream(ctx context.Context, wConn *WedgeConn) {
|
||||||
loginfo.Println("handle Stream")
|
loginfo.Println("handle Stream")
|
||||||
loginfo.Println("conn", wConn, wConn.LocalAddr().String(), wConn.RemoteAddr().String())
|
loginfo.Println("conn", wConn, wConn.LocalAddr().String(), wConn.RemoteAddr().String())
|
||||||
|
|
||||||
//peek for one byte to get the readers to converge
|
peek, err := wConn.PeekAll()
|
||||||
//look at buffer
|
|
||||||
//get the realrequest
|
|
||||||
peek, err := wConn.Peek(1)
|
|
||||||
loginfo.Println(hex.Dump(peek[0:]))
|
|
||||||
peek, err = wConn.Peek(wConn.Buffered())
|
|
||||||
loginfo.Println(hex.Dump(peek[0:]))
|
loginfo.Println(hex.Dump(peek[0:]))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue