豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit 6a1a13b

Browse files
RynnyaFangliding
authored andcommitted
TUN inbound: Closable by AlwaysOnInboundHandler (#5860)
#5860 (comment)
1 parent 6c4008e commit 6a1a13b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/proxyman/inbound/always.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func (h *AlwaysOnInboundHandler) Close() error {
186186
errs = append(errs, worker.Close())
187187
}
188188
errs = append(errs, h.mux.Close())
189+
errs = append(errs, common.Close(h.proxy))
189190
if err := errors.Combine(errs...); err != nil {
190191
return errors.New("failed to close all resources").Base(err)
191192
}

proxy/tun/handler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type Handler struct {
2323
ctx context.Context
2424
config *Config
2525
stack Stack
26+
tun Tun
2627
policyManager policy.Manager
2728
dispatcher routing.Dispatcher
2829
tag string
@@ -95,6 +96,7 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin
9596
}
9697

9798
t.stack = tunStack
99+
t.tun = tunInterface
98100

99101
errors.LogInfo(t.ctx, tunName, " up")
100102
return nil
@@ -144,6 +146,11 @@ func (t *Handler) HandleConnection(conn net.Conn, destination net.Destination) {
144146
}
145147
}
146148

149+
// Close implements common.Closable.
150+
func (t *Handler) Close() error {
151+
return errors.Combine(t.stack.Close(), t.tun.Close())
152+
}
153+
147154
// Network implements proxy.Inbound
148155
// and exists only to comply to proxy interface, declaring it doesn't listen on any network,
149156
// making the process not open any port for this inbound (input will be network interface)

0 commit comments

Comments
 (0)