2020-02-12 06:57:45 +00:00
|
|
|
// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2020-04-30 20:20:09 +00:00
|
|
|
package router
|
2020-02-12 06:57:45 +00:00
|
|
|
|
|
|
|
import (
|
2021-05-25 19:42:22 +00:00
|
|
|
"golang.zx2c4.com/wireguard/tun"
|
2020-02-15 03:23:16 +00:00
|
|
|
"tailscale.com/types/logger"
|
2021-07-20 20:28:06 +00:00
|
|
|
"tailscale.com/wgengine/monitor"
|
2020-02-12 06:57:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// For now this router only supports the userspace WireGuard implementations.
|
|
|
|
//
|
2020-02-17 02:37:45 +00:00
|
|
|
// Work is currently underway for an in-kernel FreeBSD implementation of wireguard
|
|
|
|
// https://svnweb.freebsd.org/base?view=revision&revision=357986
|
2020-02-12 06:57:45 +00:00
|
|
|
|
2021-07-20 20:28:06 +00:00
|
|
|
func newUserspaceRouter(logf logger.Logf, tundev tun.Device, linkMon *monitor.Mon) (Router, error) {
|
|
|
|
return newUserspaceBSDRouter(logf, tundev, linkMon)
|
2020-02-12 06:57:45 +00:00
|
|
|
}
|
2020-07-14 13:12:00 +00:00
|
|
|
|
2020-07-31 05:10:14 +00:00
|
|
|
func cleanup(logf logger.Logf, interfaceName string) {
|
|
|
|
// If the interface was left behind, ifconfig down will not remove it.
|
|
|
|
// In fact, this will leave a system in a tainted state where starting tailscaled
|
|
|
|
// will result in "interface tailscale0 already exists"
|
|
|
|
// until the defunct interface is ifconfig-destroyed.
|
|
|
|
ifup := []string{"ifconfig", interfaceName, "destroy"}
|
|
|
|
if out, err := cmd(ifup...).CombinedOutput(); err != nil {
|
|
|
|
logf("ifconfig destroy: %v\n%s", err, out)
|
|
|
|
}
|
|
|
|
}
|