mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-24 05:02:14 +08:00
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.
This commit is contained in:
parent
c99c71a969
commit
192d769f75
@ -48,6 +48,10 @@ func (sd *Dispatcher) shouldOverride(metadata *C.Metadata) bool {
|
|||||||
if metadata.DNSMode == C.DNSMapping && sd.forceDnsMapping {
|
if metadata.DNSMode == C.DNSMapping && sd.forceDnsMapping {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
return sd.forceSniff(metadata)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sd *Dispatcher) forceSniff(metadata *C.Metadata) bool {
|
||||||
for _, matcher := range sd.forceDomain {
|
for _, matcher := range sd.forceDomain {
|
||||||
if matcher.MatchDomain(metadata.Host) {
|
if matcher.MatchDomain(metadata.Host) {
|
||||||
return true
|
return true
|
||||||
@ -98,16 +102,21 @@ func (sd *Dispatcher) TCPSniff(conn *N.BufferedConn, metadata *C.Metadata) bool
|
|||||||
if !inWhitelist {
|
if !inWhitelist {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
forceSniffer := sd.forceSniff(metadata)
|
||||||
|
|
||||||
dst := metadata.AddrPort()
|
dst := metadata.AddrPort()
|
||||||
if count, ok := sd.skipList.Get(dst); ok && count > 5 {
|
if !forceSniffer {
|
||||||
log.Debugln("[Sniffer] Skip sniffing[%s] due to multiple failures", dst)
|
if count, ok := sd.skipList.Get(dst); ok && count > 5 {
|
||||||
return false
|
log.Debugln("[Sniffer] Skip sniffing[%s] due to multiple failures", dst)
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host, err := sd.sniffDomain(conn, metadata)
|
host, err := sd.sniffDomain(conn, metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sd.cacheSniffFailed(metadata)
|
if !forceSniffer {
|
||||||
|
sd.cacheSniffFailed(metadata)
|
||||||
|
}
|
||||||
log.Debugln("[Sniffer] All sniffing sniff failed with from [%s:%d] to [%s:%d]", metadata.SrcIP, metadata.SrcPort, metadata.String(), metadata.DstPort)
|
log.Debugln("[Sniffer] All sniffing sniff failed with from [%s:%d] to [%s:%d]", metadata.SrcIP, metadata.SrcPort, metadata.String(), metadata.DstPort)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user