TUN inbound: Closable by AlwaysOnInboundHandler (#5860)

https://github.com/XTLS/Xray-core/pull/5860#issuecomment-4193477738
This commit is contained in:
Rynnya
2026-04-07 11:19:03 +03:00
committed by Fangliding
parent 6c4008edad
commit 6a1a13b797
2 changed files with 8 additions and 0 deletions

View File

@@ -186,6 +186,7 @@ func (h *AlwaysOnInboundHandler) Close() error {
errs = append(errs, worker.Close())
}
errs = append(errs, h.mux.Close())
errs = append(errs, common.Close(h.proxy))
if err := errors.Combine(errs...); err != nil {
return errors.New("failed to close all resources").Base(err)
}

View File

@@ -23,6 +23,7 @@ type Handler struct {
ctx context.Context
config *Config
stack Stack
tun Tun
policyManager policy.Manager
dispatcher routing.Dispatcher
tag string
@@ -95,6 +96,7 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin
}
t.stack = tunStack
t.tun = tunInterface
errors.LogInfo(t.ctx, tunName, " up")
return nil
@@ -144,6 +146,11 @@ func (t *Handler) HandleConnection(conn net.Conn, destination net.Destination) {
}
}
// Close implements common.Closable.
func (t *Handler) Close() error {
return errors.Combine(t.stack.Close(), t.tun.Close())
}
// Network implements proxy.Inbound
// and exists only to comply to proxy interface, declaring it doesn't listen on any network,
// making the process not open any port for this inbound (input will be network interface)