mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2024-12-30 02:37:01 +00:00
Chore: use mirror.Tunnel
This commit is contained in:
+2
-1
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/xjasonlyu/tun2socks/v2/component/dialer"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core"
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/device"
|
||||
"github.com/xjasonlyu/tun2socks/v2/engine/mirror"
|
||||
"github.com/xjasonlyu/tun2socks/v2/log"
|
||||
"github.com/xjasonlyu/tun2socks/v2/proxy"
|
||||
"github.com/xjasonlyu/tun2socks/v2/restapi"
|
||||
@@ -156,7 +157,7 @@ func netstack(k *Key) (err error) {
|
||||
|
||||
if _defaultStack, err = core.CreateStack(&core.Config{
|
||||
LinkEndpoint: _defaultDevice,
|
||||
TransportHandler: &fakeTunnel{},
|
||||
TransportHandler: &mirror.Tunnel{},
|
||||
ErrorFunc: func(err tcpip.Error) {
|
||||
log.Warnf("[STACK] %s", err)
|
||||
},
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package mirror
|
||||
|
||||
import (
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||
"github.com/xjasonlyu/tun2socks/v2/tunnel"
|
||||
)
|
||||
|
||||
var _ adapter.TransportHandler = (*Tunnel)(nil)
|
||||
|
||||
type Tunnel struct{}
|
||||
|
||||
func (*Tunnel) HandleTCP(conn adapter.TCPConn) {
|
||||
tunnel.TCPIn() <- conn
|
||||
}
|
||||
|
||||
func (*Tunnel) HandleUDP(conn adapter.UDPConn) {
|
||||
tunnel.UDPIn() <- conn
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"github.com/xjasonlyu/tun2socks/v2/core/adapter"
|
||||
"github.com/xjasonlyu/tun2socks/v2/tunnel"
|
||||
)
|
||||
|
||||
var _ adapter.TransportHandler = (*fakeTunnel)(nil)
|
||||
|
||||
type fakeTunnel struct{}
|
||||
|
||||
func (*fakeTunnel) HandleTCP(conn adapter.TCPConn) {
|
||||
tunnel.TCPIn() <- conn
|
||||
}
|
||||
|
||||
func (*fakeTunnel) HandleUDP(conn adapter.UDPConn) {
|
||||
tunnel.UDPIn() <- conn
|
||||
}
|
||||
Reference in New Issue
Block a user