Refactor(core): with error callback

This commit is contained in:
xjasonlyu
2022-03-29 17:19:54 +08:00
parent 0a9f7f123c
commit 3999c5d66b
5 changed files with 61 additions and 19 deletions

View File

@@ -7,13 +7,13 @@ 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/core/option"
_ "github.com/xjasonlyu/tun2socks/v2/dns"
"github.com/xjasonlyu/tun2socks/v2/log"
"github.com/xjasonlyu/tun2socks/v2/proxy"
"github.com/xjasonlyu/tun2socks/v2/stats"
"github.com/xjasonlyu/tun2socks/v2/tunnel"
"gvisor.dev/gvisor/pkg/tcpip"
"gvisor.dev/gvisor/pkg/tcpip/stack"
)
@@ -169,6 +169,12 @@ func (e *engine) applyStack() (err error) {
}
}()
e.stack, err = core.CreateStackWithOptions(e.device, &fakeTunnel{}, option.WithDefault())
e.stack, err = core.CreateStack(&core.Config{
LinkEndpoint: e.device,
TransportHandler: &fakeTunnel{},
ErrorFunc: func(err tcpip.Error) {
log.Warnf("[STACK] %s", err)
},
})
return
}