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
+11 -1
View File
@@ -26,7 +26,11 @@ func RegisterOutbound(registry *outbound.Registry) {
outbound.Register[option.ShadowsocksOutboundOptions](registry, C.TypeShadowsocks, NewOutbound)
}
var _ adapter.OutboundWithMultiplex = (*Outbound)(nil)
var (
_ adapter.OutboundWithMultiplex = (*Outbound)(nil)
_ adapter.InterfaceUpdateListener = (*Outbound)(nil)
_ adapter.IdleConnectionCloser = (*Outbound)(nil)
)
type Outbound struct {
outbound.Adapter
@@ -136,6 +140,12 @@ func (h *Outbound) InterfaceUpdated(ctx context.Context) {
}
}
func (h *Outbound) CloseIdleConnections() {
if h.multiplexDialer != nil {
h.multiplexDialer.CloseIdleConnections()
}
}
func (h *Outbound) Close() error {
return common.Close(common.PtrOrNil(h.multiplexDialer))
}