Close idle connections of unreferenced outbounds and DNS servers

This commit is contained in:
世界
2026-10-02 18:00:09 +08:00
parent d2cf9747d7
commit fd9a076d25
40 changed files with 851 additions and 81 deletions
+10 -3
View File
@@ -16,6 +16,7 @@ import (
"github.com/sagernet/sing-box/option"
"github.com/sagernet/sing-cloudflared"
"github.com/sagernet/sing-tun"
"github.com/sagernet/sing/common"
"github.com/sagernet/sing/common/bufio"
E "github.com/sagernet/sing/common/exceptions"
M "github.com/sagernet/sing/common/metadata"
@@ -79,14 +80,16 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
}
return &Inbound{
Adapter: inbound.NewAdapter(C.TypeCloudflared, tag),
service: service,
Adapter: inbound.NewAdapter(C.TypeCloudflared, tag),
service: service,
references: common.FilterNotDefault([]string{options.ControlDialer.Detour, options.TunnelDialer.Detour}),
}, nil
}
type Inbound struct {
inbound.Adapter
service *cloudflared.Service
service *cloudflared.Service
references []string
}
func (i *Inbound) Start(stage adapter.StartStage) error {
@@ -255,6 +258,10 @@ func (h *icmpRouterHandler) RouteICMPFlow(source netip.Addr, destination netip.A
}
}
func (i *Inbound) References() []string {
return i.references
}
var (
_ N.HandshakeSuccess = (*routedConn)(nil)
_ N.ReaderWithUpstream = (*routedConn)(nil)