|
|
@ -133,8 +133,8 @@ func (e *userspaceEngine) GetInternals() (*tstun.Wrapper, *magicsock.Conn) {
|
|
|
|
|
|
|
|
|
|
|
|
// Config is the engine configuration.
|
|
|
|
// Config is the engine configuration.
|
|
|
|
type Config struct {
|
|
|
|
type Config struct {
|
|
|
|
// Router is the interface to OS networking APIs used to interface
|
|
|
|
// Router interfaces the Engine to the OS network stack.
|
|
|
|
// the OS with the Engine.
|
|
|
|
// If nil, a fake Router that does nothing is used.
|
|
|
|
Router router.Router
|
|
|
|
Router router.Router
|
|
|
|
|
|
|
|
|
|
|
|
// LinkMonitor optionally provides an existing link monitor to re-use.
|
|
|
|
// LinkMonitor optionally provides an existing link monitor to re-use.
|
|
|
@ -153,7 +153,6 @@ type Config struct {
|
|
|
|
func NewFakeUserspaceEngine(logf logger.Logf, listenPort uint16) (Engine, error) {
|
|
|
|
func NewFakeUserspaceEngine(logf logger.Logf, listenPort uint16) (Engine, error) {
|
|
|
|
logf("Starting userspace wireguard engine (with fake TUN device)")
|
|
|
|
logf("Starting userspace wireguard engine (with fake TUN device)")
|
|
|
|
return NewUserspaceEngine(logf, tstun.NewFake(), Config{
|
|
|
|
return NewUserspaceEngine(logf, tstun.NewFake(), Config{
|
|
|
|
Router: router.NewFake(logf),
|
|
|
|
|
|
|
|
ListenPort: listenPort,
|
|
|
|
ListenPort: listenPort,
|
|
|
|
Fake: true,
|
|
|
|
Fake: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -165,15 +164,8 @@ func NewUserspaceEngine(logf logger.Logf, dev tun.Device, conf Config) (_ Engine
|
|
|
|
var closePool closeOnErrorPool
|
|
|
|
var closePool closeOnErrorPool
|
|
|
|
defer closePool.closeAllIfError(&reterr)
|
|
|
|
defer closePool.closeAllIfError(&reterr)
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: default to a no-op router, require caller to pass in
|
|
|
|
|
|
|
|
// effectful ones.
|
|
|
|
|
|
|
|
if conf.Router == nil {
|
|
|
|
if conf.Router == nil {
|
|
|
|
r, err := router.New(logf, dev)
|
|
|
|
conf.Router = router.NewFake(logf)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
conf.Router = r
|
|
|
|
|
|
|
|
closePool.add(r)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tsTUNDev := tstun.Wrap(logf, dev)
|
|
|
|
tsTUNDev := tstun.Wrap(logf, dev)
|
|
|
|