mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-16 18:08:40 +00:00
![Brad Fitzpatrick](/assets/img/avatar_default.png)
In prep for most of the package funcs in net/interfaces to become methods in a long-lived netmon.Monitor that can cache things. (Many of the funcs are very heavy to call regularly, whereas the long-lived netmon.Monitor can subscribe to things from the OS and remember answers to questions it's asked regularly later) Updates tailscale/corp#10910 Updates tailscale/corp#18960 Updates #7967 Updates #3299 Change-Id: Ie4e8dedb70136af2d611b990b865a822cd1797e5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
27 lines
606 B
Go
27 lines
606 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Common code for FreeBSD and Darwin. This might also work on other
|
|
// BSD systems (e.g. OpenBSD) but has not been tested.
|
|
// Not used on iOS. See defaultroute_ios.go.
|
|
|
|
//go:build !ios && (darwin || freebsd)
|
|
|
|
package netmon
|
|
|
|
import "net"
|
|
|
|
func defaultRoute() (d DefaultRouteDetails, err error) {
|
|
idx, err := DefaultRouteInterfaceIndex()
|
|
if err != nil {
|
|
return d, err
|
|
}
|
|
iface, err := net.InterfaceByIndex(idx)
|
|
if err != nil {
|
|
return d, err
|
|
}
|
|
d.InterfaceName = iface.Name
|
|
d.InterfaceIndex = idx
|
|
return d, nil
|
|
}
|