mihomo
mihomo copied to clipboard
[Feature] don't track outbound type dns
Verification Steps
- [X] I have read the documentation and confirmed that this feature is not implemented
- [X] I have searched for the feature request I want to propose in the Issue Tracker and did not find it
- [X] I am a non-Chinese user.
Description
When using tproxy with outbound type DNS please don't put it in the connections list. It flooded the connections list and stay there for a while. XD dashboard was lagging a lot, only yacd can handle it. Thanks.
proxies:
- name: 'dns-hijack'
type: dns
rules:
- DST-PORT,53,dns-hijack
diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go
index b1b4add5ee..be2c70e8de 100644
--- a/tunnel/tunnel.go
+++ b/tunnel/tunnel.go
@@ -409,8 +409,10 @@ func handleUDPConn(packet C.PacketAdapter) {
}
logMetadata(metadata, rule, rawPc)
- pc := statistic.NewUDPTracker(rawPc, statistic.DefaultManager, metadata, rule, 0, 0, true)
-
+ pc := rawPc
+ if proxy.Type() != C.Dns {
+ pc = statistic.NewUDPTracker(rawPc, statistic.DefaultManager, metadata, rule, 0, 0, true)
+ }
if rawPc.Chains().Last() == "REJECT-DROP" {
_ = pc.Close()
return nil, nil, errors.New("rejected drop packet")
@@ -547,7 +549,9 @@ func handleTCPConn(connCtx C.ConnContext) {
}
logMetadata(metadata, rule, remoteConn)
- remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule, 0, int64(peekLen), true)
+ if proxy.Type() != C.Dns {
+ remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule, 0, int64(peekLen), true)
+ }
defer func(remoteConn C.Conn) {
_ = remoteConn.Close()
}(remoteConn)