Add TCP Listener support for wireguard outbound#3651
Merged
xiaokangwang merged 1 commit intov2fly:masterfrom Mar 14, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3651 +/- ##
==========================================
+ Coverage 22.37% 22.88% +0.51%
==========================================
Files 864 867 +3
Lines 56065 47635 -8430
==========================================
- Hits 12543 10901 -1642
+ Misses 42265 35479 -6786
+ Partials 1257 1255 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Machine Generated)
This pull request introduces support for configurable TCP listeners in the gVisor-based packet switch stack, allowing TCP connections to be accepted and relayed to tagged outbound handlers. The changes include protocol buffer and generated code updates, new listener management logic, and integration with the stack lifecycle.
TCP Listener feature additions:
TCPListenermessage to the protocol buffer definition (config.proto) and updated generated code to support multiple TCP listeners in theConfigstruct. ([[1]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-3b84b456b991b8d195155c819727ae4bc72b059d237fe5865b2a6220f10ea936R13-R18),[[2]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-3b84b456b991b8d195155c819727ae4bc72b059d237fe5865b2a6220f10ea936R29),[[3]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436R21-R80),[[4]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436R92-R99),[[5]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436L50-R111),[[6]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436L63-R124),[[7]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436R190-R205),[[8]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436L145-R218),[[9]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436L160-R250),[[10]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-6d5f70c28dbc05b46b7773065ff1d592f2a10f50ad2af88d62bfc111bb76e436L188-R264))ApplyListeners, which creates TCP listeners based on the configuration and starts accept loops for each. ([common/packetswitch/gvisorstack/tcp_listener.goR1-R84](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-8eaabc0ad3338d7bfaee2f6aab569590d708ccfbb5ff755a0eea6ad12134caceR1-R84))[[1]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-e1402106b5770a215ecd84b3b5ea5973f90b0b1cafbfd76656aed4295f16fbd0R25-R26),[[2]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-e1402106b5770a215ecd84b3b5ea5973f90b0b1cafbfd76656aed4295f16fbd0R64-R67),[[3]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-e1402106b5770a215ecd84b3b5ea5973f90b0b1cafbfd76656aed4295f16fbd0R169-R172))TCP connection handling:
handleTCPConnmethod. ([common/packetswitch/gvisorstack/tcp_listener.goR1-R84](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-8eaabc0ad3338d7bfaee2f6aab569590d708ccfbb5ff755a0eea6ad12134caceR1-R84))Outbound handler abstraction:
abstactOutbountpackage, including error handling and context-aware connection management. ([[1]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-1d5a9a82ae3946b7e9573dfd0b8200f95af236bfd99788f07b628026ae0b2322R1-R9),[[2]](https://github.com/v2fly/v2ray-core/pull/3651/files#diff-2e7cbf8ca60ffe27ff05ae9bd589a01a7d2d64a4827bb5d4be01f91a9b2cfd4dR1-R133))These changes collectively enable the stack to accept TCP connections on configurable addresses and ports, and relay them to tagged outbound handlers for further processing.