mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-07-30 11:40:53 -04:00
Add TCP Listener support for wireguard outbound (#3651)
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/network/ipv4"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/network/ipv6"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/stack"
|
||||
@@ -21,6 +22,8 @@ type WrappedStack struct {
|
||||
config *Config
|
||||
ctx context.Context
|
||||
stack *stack.Stack
|
||||
|
||||
stackTCPListeners []*gonet.TCPListener
|
||||
}
|
||||
|
||||
func NewStack(ctx context.Context, config *Config) (*WrappedStack, error) {
|
||||
@@ -58,6 +61,10 @@ func (w *WrappedStack) CreateStackFromNetworkLayerDevice(packetSwitchDevice pack
|
||||
})
|
||||
|
||||
w.stack = s
|
||||
|
||||
if err := w.ApplyListeners(); err != nil {
|
||||
return fmt.Errorf("failed to apply listeners: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -159,6 +166,10 @@ func (w *WrappedStack) Close() error {
|
||||
if w == nil || w.stack == nil {
|
||||
return nil
|
||||
}
|
||||
for _, l := range w.stackTCPListeners {
|
||||
l.Close()
|
||||
}
|
||||
w.stackTCPListeners = nil
|
||||
w.stack.Close()
|
||||
w.stack = nil
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user