fix(sniffer): should remain partial data for further read even if timeout

This commit is contained in:
mzz2017
2023-04-09 16:41:39 +08:00
parent 129d6055dd
commit 99c0d190d2

View File

@ -45,6 +45,7 @@ func (s *Sniffer) SniffTcp() (d string, err error) {
defer s.readMu.Unlock()
if s.stream {
n, err := s.r.Read(s.buf)
s.buf = s.buf[:n]
if err != nil {
var netError net.Error
if errors.As(err, &netError) && netError.Timeout() {
@ -52,7 +53,6 @@ func (s *Sniffer) SniffTcp() (d string, err error) {
}
return "", err
}
s.buf = s.buf[:n]
}
if len(s.buf) == 0 {
return "", NotApplicableError