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, worker.Close())
|
||||||
}
|
}
|
||||||
errs = append(errs, h.mux.Close())
|
errs = append(errs, h.mux.Close())
|
||||||
|
errs = append(errs, common.Close(h.proxy))
|
||||||
if err := errors.Combine(errs...); err != nil {
|
if err := errors.Combine(errs...); err != nil {
|
||||||
return errors.New("failed to close all resources").Base(err)
|
return errors.New("failed to close all resources").Base(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type Handler struct {
|
|||||||
ctx context.Context
|
ctx context.Context
|
||||||
config *Config
|
config *Config
|
||||||
stack Stack
|
stack Stack
|
||||||
|
tun Tun
|
||||||
policyManager policy.Manager
|
policyManager policy.Manager
|
||||||
dispatcher routing.Dispatcher
|
dispatcher routing.Dispatcher
|
||||||
tag string
|
tag string
|
||||||
@@ -95,6 +96,7 @@ func (t *Handler) Init(ctx context.Context, pm policy.Manager, dispatcher routin
|
|||||||
}
|
}
|
||||||
|
|
||||||
t.stack = tunStack
|
t.stack = tunStack
|
||||||
|
t.tun = tunInterface
|
||||||
|
|
||||||
errors.LogInfo(t.ctx, tunName, " up")
|
errors.LogInfo(t.ctx, tunName, " up")
|
||||||
return nil
|
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
|
// Network implements proxy.Inbound
|
||||||
// and exists only to comply to proxy interface, declaring it doesn't listen on any network,
|
// 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)
|
// making the process not open any port for this inbound (input will be network interface)
|
||||||
|
|||||||
Reference in New Issue
Block a user