@ -461,21 +461,22 @@ func isTailscaleInterface(name string, ips []netip.Prefix) bool {
// getPAC, if non-nil, returns the current PAC file URL.
// getPAC, if non-nil, returns the current PAC file URL.
var getPAC func ( ) string
var getPAC func ( ) string
// G etState returns the state of all the current machine's network interfaces.
// g etState returns the state of all the current machine's network interfaces.
//
//
// It does not set the returned State.IsExpensive. The caller can populate that.
// It does not set the returned State.IsExpensive. The caller can populate that.
//
//
// Deprecated: use netmon.Monitor.InterfaceState instead .
// optTSInterfaceName is the name of the Tailscale interface, if known .
func getState ( ) ( * State , error ) {
func getState ( optTSInterfaceName string ) ( * State , error ) {
s := & State {
s := & State {
InterfaceIPs : make ( map [ string ] [ ] netip . Prefix ) ,
InterfaceIPs : make ( map [ string ] [ ] netip . Prefix ) ,
Interface : make ( map [ string ] Interface ) ,
Interface : make ( map [ string ] Interface ) ,
}
}
if err := ForeachInterface ( func ( ni Interface , pfxs [ ] netip . Prefix ) {
if err := ForeachInterface ( func ( ni Interface , pfxs [ ] netip . Prefix ) {
isTSInterfaceName := optTSInterfaceName != "" && ni . Name == optTSInterfaceName
ifUp := ni . IsUp ( )
ifUp := ni . IsUp ( )
s . Interface [ ni . Name ] = ni
s . Interface [ ni . Name ] = ni
s . InterfaceIPs [ ni . Name ] = append ( s . InterfaceIPs [ ni . Name ] , pfxs ... )
s . InterfaceIPs [ ni . Name ] = append ( s . InterfaceIPs [ ni . Name ] , pfxs ... )
if ! ifUp || isTailscaleInterface ( ni . Name , pfxs ) {
if ! ifUp || isTSInterfaceName || isTailscaleInterface ( ni . Name , pfxs ) {
return
return
}
}
for _ , pfx := range pfxs {
for _ , pfx := range pfxs {
@ -755,11 +756,12 @@ func DefaultRoute() (DefaultRouteDetails, error) {
// HasCGNATInterface reports whether there are any non-Tailscale interfaces that
// HasCGNATInterface reports whether there are any non-Tailscale interfaces that
// use a CGNAT IP range.
// use a CGNAT IP range.
func HasCGNATInterface ( ) ( bool , error ) {
func ( m * Monitor ) HasCGNATInterface ( ) ( bool , error ) {
hasCGNATInterface := false
hasCGNATInterface := false
cgnatRange := tsaddr . CGNATRange ( )
cgnatRange := tsaddr . CGNATRange ( )
err := ForeachInterface ( func ( i Interface , pfxs [ ] netip . Prefix ) {
err := ForeachInterface ( func ( i Interface , pfxs [ ] netip . Prefix ) {
if hasCGNATInterface || ! i . IsUp ( ) || isTailscaleInterface ( i . Name , pfxs ) {
isTSInterfaceName := m . tsIfName != "" && i . Name == m . tsIfName
if hasCGNATInterface || ! i . IsUp ( ) || isTSInterfaceName || isTailscaleInterface ( i . Name , pfxs ) {
return
return
}
}
for _ , pfx := range pfxs {
for _ , pfx := range pfxs {