Documentation
¶
Overview ¶
Package interfaces contains helpers for looking up system network interfaces.
Index ¶
- func ForeachInterfaceAddress(fn func(Interface, net.IP)) error
- func HTTPOfListener(ln net.Listener) string
- func HaveIPv6GlobalAddress() (bool, error)
- func IsTailscaleIP(ip net.IP) bool
- func LocalAddresses() (regular, loopback []string, err error)
- func Tailscale() (net.IP, *net.Interface, error)
- type Interface
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForeachInterfaceAddress ¶
ForeachInterfaceAddress calls fn for each interface's address on the machine.
func HTTPOfListener ¶ added in v0.98.0
HTTPOfListener returns the HTTP address to ln. If the listener is listening on the unspecified address, it it tries to find a reasonable interface address on the machine to use.
func HaveIPv6GlobalAddress ¶
HaveIPv6GlobalAddress reports whether the machine appears to have a global scope unicast IPv6 address.
It only returns an error if there's a problem querying the system interfaces.
func IsTailscaleIP ¶
IsTailscaleIP reports whether ip is an IP in a range used by Tailscale virtual network interfaces.
func LocalAddresses ¶
LocalAddresses returns the machine's IP addresses, separated by whether they're loopback addresses.
Types ¶
type Interface ¶
Interface is a wrapper around Go's net.Interface with some extra methods.
func (Interface) IsLoopback ¶
type State ¶
type State struct { InterfaceIPs map[string][]net.IP InterfaceUp map[string]bool // IsExpensive is whether the current network interface is // considered "expensive", which currently means LTE/etc // instead of Wifi. This field is not populated by GetState. IsExpensive bool }
State is intended to store the state of the machine's network interfaces, routing table, and other network configuration. For now it's pretty basic.
func GetState ¶
GetState returns the state of all the current machine's network interfaces.
It does not set the returned State.IsExpensive. The caller can populate that.
func (*State) RemoveTailscaleInterfaces ¶
func (s *State) RemoveTailscaleInterfaces()
RemoveTailscaleInterfaces modifes s to remove any interfaces that are owned by this process. (TODO: make this true; currently it makes the Linux-only assumption that the interface is named /^tailscale/)