mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
TUN inbound: Closable by AlwaysOnInboundHandler (#5860)
https://github.com/XTLS/Xray-core/pull/5860#issuecomment-4193477738
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user