Open nunu6689 opened 1 day ago
How about this?
diff --git a/constant/metadata.go b/constant/metadata.go
index 7b73c21a..e0aafdb9 100644
--- a/constant/metadata.go
+++ b/constant/metadata.go
@@ -157,6 +157,8 @@ type Metadata struct {
RawDstAddr net.Addr `json:"-"`
// Only domain rule
SniffHost string `json:"sniffHost"`
+
+ ProxyType AdapterType
}
func (m *Metadata) RemoteAddress() string {
diff --git a/tunnel/statistic/manager.go b/tunnel/statistic/manager.go
index 0b309299..3a33ba8f 100644
--- a/tunnel/statistic/manager.go
+++ b/tunnel/statistic/manager.go
@@ -5,6 +5,7 @@ import (
"time"
"github.com/metacubex/mihomo/common/atomic"
+ C "github.com/metacubex/mihomo/constant"
"github.com/puzpuzpuz/xsync/v3"
"github.com/shirou/gopsutil/v3/process"
@@ -82,7 +83,9 @@ func (m *Manager) Memory() uint64 {
func (m *Manager) Snapshot() *Snapshot {
var connections []*TrackerInfo
m.Range(func(c Tracker) bool {
- connections = append(connections, c.Info())
+ if c.Info().Metadata.ProxyType != C.Dns {
+ connections = append(connections, c.Info())
+ }
return true
})
return &Snapshot{
diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go
index c379846b..9591ef8a 100644
--- a/tunnel/tunnel.go
+++ b/tunnel/tunnel.go
@@ -409,6 +409,7 @@ func handleUDPConn(packet C.PacketAdapter) {
}
logMetadata(metadata, rule, rawPc)
+ metadata.ProxyType = proxy.Type()
pc := statistic.NewUDPTracker(rawPc, statistic.DefaultManager, metadata, rule, 0, 0, true)
if rawPc.Chains().Last() == "REJECT-DROP" {
@@ -547,6 +548,7 @@ func handleTCPConn(connCtx C.ConnContext) {
}
logMetadata(metadata, rule, remoteConn)
+ metadata.ProxyType = proxy.Type()
remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule, 0, int64(peekLen), true)
defer func(remoteConn C.Conn) {
_ = remoteConn.Close()
Verification Steps
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.