Chore: use mirror.Tunnel

This commit is contained in:
xjasonlyu
2022-03-31 17:28:12 +08:00
parent 8d3f8d7631
commit ccf53dcb88
3 changed files with 20 additions and 19 deletions
+2 -1
View File
@@ -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)
},
+18
View File
@@ -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
}
-18
View File
@@ -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
}