Skip to content

Commit

Permalink
fixed #708
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed Aug 28, 2020
1 parent b657e1f commit 884ad52
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions streamserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func NewStreamServer(password []byte, client net.Conn, timeout int) (*StreamServ
if time.Now().Unix()-i > 60 {
x.BP12.Put(s.cn)
x.BP2048.Put(s.RB)
WaitReadErr(s.Client)
return nil, nil, errors.New("Expired request")
}
if i%2 == 0 {
Expand Down Expand Up @@ -213,6 +214,7 @@ func (s *StreamServer) Read() (int, error) {
return 0, err
}
if _, err := s.ca.Open(s.RB[:0], s.cn, s.RB[:2+16], nil); err != nil {
WaitReadErr(s.Client)
return 0, err
}
l := int(binary.BigEndian.Uint16(s.RB[:2]))
Expand Down
26 changes: 26 additions & 0 deletions waitreaderr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2016-present Cloud <[email protected]>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 3 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

package brook

import "net"

func WaitReadErr(conn net.Conn) {
var b [2048]byte
for {
if _, err := conn.Read(b[:]); err != nil {
return
}
}
}

0 comments on commit 884ad52

Please sign in to comment.