Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 192d769

Browse files
authored
chore: ensure forced domains are always sniffed (#1793)
When a domain matches forceDomain: - SkipList is not checked - Failed attempts are not cached - Sniffing is attempted every time This ensures forced domains are always sniffed regardless of previous failures.
1 parent c99c71a commit 192d769

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

component/sniffer/dispatcher.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ func (sd *Dispatcher) shouldOverride(metadata *C.Metadata) bool {
4848
if metadata.DNSMode == C.DNSMapping && sd.forceDnsMapping {
4949
return true
5050
}
51+
return sd.forceSniff(metadata)
52+
}
53+
54+
func (sd *Dispatcher) forceSniff(metadata *C.Metadata) bool {
5155
for _, matcher := range sd.forceDomain {
5256
if matcher.MatchDomain(metadata.Host) {
5357
return true
@@ -98,16 +102,21 @@ func (sd *Dispatcher) TCPSniff(conn *N.BufferedConn, metadata *C.Metadata) bool
98102
if !inWhitelist {
99103
return false
100104
}
105+
forceSniffer := sd.forceSniff(metadata)
101106

102107
dst := metadata.AddrPort()
103-
if count, ok := sd.skipList.Get(dst); ok && count > 5 {
104-
log.Debugln("[Sniffer] Skip sniffing[%s] due to multiple failures", dst)
105-
return false
108+
if !forceSniffer {
109+
if count, ok := sd.skipList.Get(dst); ok && count > 5 {
110+
log.Debugln("[Sniffer] Skip sniffing[%s] due to multiple failures", dst)
111+
return false
112+
}
106113
}
107114

108115
host, err := sd.sniffDomain(conn, metadata)
109116
if err != nil {
110-
sd.cacheSniffFailed(metadata)
117+
if !forceSniffer {
118+
sd.cacheSniffFailed(metadata)
119+
}
111120
log.Debugln("[Sniffer] All sniffing sniff failed with from [%s:%d] to [%s:%d]", metadata.SrcIP, metadata.SrcPort, metadata.String(), metadata.DstPort)
112121
return false
113122
}

0 commit comments

Comments
 (0)