mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-04 23:40:30 +07:00
fix(sniffer): server push cases for games
This commit is contained in:
@ -6,8 +6,10 @@
|
|||||||
package sniffing
|
package sniffing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"github.com/mzz2017/softwind/pool"
|
"github.com/mzz2017/softwind/pool"
|
||||||
"io"
|
"io"
|
||||||
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,6 +46,10 @@ func (s *Sniffer) SniffTcp() (d string, err error) {
|
|||||||
if s.stream {
|
if s.stream {
|
||||||
n, err := s.r.Read(s.buf)
|
n, err := s.r.Read(s.buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var netError net.Error
|
||||||
|
if errors.As(err, &netError) && netError.Timeout() {
|
||||||
|
return "", NotApplicableError
|
||||||
|
}
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
s.buf = s.buf[:n]
|
s.buf = s.buf[:n]
|
||||||
|
@ -29,11 +29,13 @@ func (c *ControlPlane) handleConn(lConn net.Conn) (err error) {
|
|||||||
defer lConn.Close()
|
defer lConn.Close()
|
||||||
|
|
||||||
// Sniff target domain.
|
// Sniff target domain.
|
||||||
|
lConn.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
|
||||||
sniffer := sniffing.NewConnSniffer(lConn, TcpSniffBufSize)
|
sniffer := sniffing.NewConnSniffer(lConn, TcpSniffBufSize)
|
||||||
domain, err := sniffer.SniffTcp()
|
domain, err := sniffer.SniffTcp()
|
||||||
if err != nil && !sniffing.IsSniffingError(err) {
|
if err != nil && !sniffing.IsSniffingError(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
lConn.SetReadDeadline(time.Time{})
|
||||||
// ConnSniffer should be used later, so we cannot close it now.
|
// ConnSniffer should be used later, so we cannot close it now.
|
||||||
defer sniffer.Close()
|
defer sniffer.Close()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user