Skip to content

fix(inbound, tun): Close proxy.Inbound in AlwaysOnInboundHandler and close Tun in tun.Handler#5860

Open
Rynnya wants to merge 1 commit intoXTLS:mainfrom
Rynnya:fix(inbound)-close-all-resources-in-alwaysoninbound
Open

fix(inbound, tun): Close proxy.Inbound in AlwaysOnInboundHandler and close Tun in tun.Handler#5860
Rynnya wants to merge 1 commit intoXTLS:mainfrom
Rynnya:fix(inbound)-close-all-resources-in-alwaysoninbound

Conversation

@Rynnya
Copy link
Copy Markdown

@Rynnya Rynnya commented Mar 29, 2026

Fixes broken chain of Close() calls on TUN inbound.
On Windows this fixes dangling adapter after calling Close() on Instance, and, strangely, fixes timeout on first attempt to create adapter again after application reboot.
On Linux nothing technically changes (I'm not really sure if Tun.Start() is called by AlwaysOnInboundHandler)
On Darwin, Android and iOS nothing changes because they have empty Close() implementations.

@Fangliding
Copy link
Copy Markdown
Member

#5464 (comment)

@Rynnya
Copy link
Copy Markdown
Author

Rynnya commented Mar 29, 2026

#5464 (comment)

Got tests on Linux, and while Tun.Start() wasn't called (because AlwaysOnInboundHandler.proxy of type proxy.Inbound doesn't implement common.Runnable), it didn't had any effect anyway (because tunnel, when opened, already in UP state)

Tun.Close(), however, did close tunnel device, just like it would if application would be closed instead; this doesn't affect processes where xray is used from the start and until application dies, but it does help with applications that would reuse tunnel after some downtime (less work with OS routing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants