mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
fix: add wait timeout, and log
This commit is contained in:
parent
bee1bddceb
commit
9e6ba64940
|
@ -5,6 +5,7 @@ import (
|
|||
"net"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/component/trie"
|
||||
|
||||
|
@ -85,8 +86,16 @@ func (sd *SnifferDispatcher) Enable() bool {
|
|||
func (sd *SnifferDispatcher) sniffDomain(conn *CN.BufferedConn, metadata *C.Metadata) (string, error) {
|
||||
for _, sniffer := range sd.sniffers {
|
||||
if sniffer.SupportNetwork() == C.TCP {
|
||||
conn.SetReadDeadline(time.Now().Add(3 * time.Second))
|
||||
_, err := conn.Peek(1)
|
||||
if err != nil {
|
||||
_, ok := err.(*net.OpError)
|
||||
if ok {
|
||||
log.Errorln("[Sniffer] [%s] Maybe read timeout, Consider adding skip", metadata.DstIP.String())
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
log.Errorln("[Sniffer] %v", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user