-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22c909a
commit d6c52f7
Showing
4 changed files
with
52 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
package tun | ||
|
||
import ( | ||
"github.com/v2fly/v2ray-core/v5/common/net" | ||
"gvisor.dev/gvisor/pkg/tcpip/stack" | ||
tun_net "github.com/v2fly/v2ray-core/v5/app/tun/net" | ||
) | ||
|
||
var ( | ||
tcpQueue = make(chan TCPConn) | ||
udpQueue = make(chan UDPConn) | ||
tcpQueue = make(chan tun_net.TCPConn) | ||
udpQueue = make(chan tun_net.UDPConn) | ||
) | ||
|
||
type TCPConn interface { | ||
net.Conn | ||
|
||
ID() *stack.TransportEndpointID | ||
} | ||
|
||
type UDPConn interface { | ||
net.Conn | ||
|
||
ID() *stack.TransportEndpointID | ||
} | ||
|
||
func handleTCP(conn TCPConn) { | ||
func handleTCP(conn tun_net.TCPConn) { | ||
tcpQueue <- conn | ||
} | ||
|
||
func handleUDP(conn UDPConn) { | ||
func handleUDP(conn tun_net.UDPConn) { | ||
udpQueue <- conn | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package net | ||
|
||
import ( | ||
"github.com/v2fly/v2ray-core/v5/common/net" | ||
|
||
"gvisor.dev/gvisor/pkg/tcpip" | ||
"gvisor.dev/gvisor/pkg/tcpip/stack" | ||
) | ||
|
||
type TCPConn interface { | ||
net.Conn | ||
|
||
ID() *stack.TransportEndpointID | ||
} | ||
|
||
type UDPConn interface { | ||
net.Conn | ||
|
||
ID() *stack.TransportEndpointID | ||
} | ||
|
||
func AddressFromTCPIPAddr(addr tcpip.Address) net.Address { | ||
return net.IPAddress(addr.AsSlice()) | ||
} |