2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-02-12 06:57:45 +00:00
|
|
|
|
2020-04-30 21:20:09 +01:00
|
|
|
package router
|
2020-02-12 06:57:45 +00:00
|
|
|
|
|
|
|
import (
|
2022-12-09 23:12:20 +00:00
|
|
|
"github.com/tailscale/wireguard-go/tun"
|
2024-04-26 18:12:46 +01:00
|
|
|
"tailscale.com/health"
|
2023-04-18 22:26:58 +01:00
|
|
|
"tailscale.com/net/netmon"
|
2020-02-15 03:23:16 +00:00
|
|
|
"tailscale.com/types/logger"
|
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
|
|
|
|
2024-04-26 18:12:46 +01:00
|
|
|
func newUserspaceRouter(logf logger.Logf, tundev tun.Device, netMon *netmon.Monitor, health *health.Tracker) (Router, error) {
|
|
|
|
return newUserspaceBSDRouter(logf, tundev, netMon, health)
|
2020-02-12 06:57:45 +00:00
|
|
|
}
|
2020-07-14 14:12:00 +01:00
|
|
|
|
2024-04-03 03:52:19 +01:00
|
|
|
func cleanUp(logf logger.Logf, interfaceName string) {
|
2020-07-31 06:10:14 +01:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|