diff --git a/android/src/main/java/com/tailscale/ipn/App.kt b/android/src/main/java/com/tailscale/ipn/App.kt index 92b9b23136..7a9d564eee 100644 --- a/android/src/main/java/com/tailscale/ipn/App.kt +++ b/android/src/main/java/com/tailscale/ipn/App.kt @@ -166,14 +166,14 @@ class App : Application(), libtailscale.AppContext { } if (dns.updateDNSFromNetwork(sb.toString())) { - Libtailscale.onDnsConfigChanged(linkProperties?.getInterfaceName()) + Libtailscale.onDnsConfigChanged() } } override fun onLost(network: Network) { super.onLost(network) if (dns.updateDNSFromNetwork("")) { - Libtailscale.onDnsConfigChanged("") + Libtailscale.onDnsConfigChanged() } } }) diff --git a/libtailscale/backend.go b/libtailscale/backend.go index bbe73c3f6b..a5610c6d3d 100644 --- a/libtailscale/backend.go +++ b/libtailscale/backend.go @@ -222,9 +222,9 @@ func (a *App) runBackend(ctx context.Context) error { netns.SetAndroidProtectFunc(nil) service = nil } - case i := <-onDNSConfigChanged: + case <-onDNSConfigChanged: if b != nil { - go b.NetworkChanged(i) + go b.NetworkChanged() } } } diff --git a/libtailscale/callbacks.go b/libtailscale/callbacks.go index d35a8a0a55..bc3e489d1e 100644 --- a/libtailscale/callbacks.go +++ b/libtailscale/callbacks.go @@ -23,14 +23,13 @@ var ( // onGoogleToken receives google ID tokens. onGoogleToken = make(chan string) - // onDNSConfigChanged is notified when the network changes and the DNS config needs to be updated. It receives the updated interface name. - onDNSConfigChanged = make(chan string, 1) + // onDNSConfigChanged is notified when the network changes and the DNS config needs to be updated. + onDNSConfigChanged = make(chan struct{}, 1) ) -// ifname is the interface name retrieved from LinkProperties on network change, if any. -func OnDnsConfigChanged(ifname string) { +func OnDnsConfigChanged() { select { - case onDNSConfigChanged <- ifname: + case onDNSConfigChanged <- struct{}{}: default: } } diff --git a/libtailscale/net.go b/libtailscale/net.go index 8d61a3d8d7..49ced685d5 100644 --- a/libtailscale/net.go +++ b/libtailscale/net.go @@ -227,8 +227,7 @@ func (b *backend) CloseTUNs() { b.devices.Shutdown() } -// ifname is the interface name retrieved from LinkProperties on network change. If a network is lost, an empty string is passed in. -func (b *backend) NetworkChanged(ifname string) { +func (b *backend) NetworkChanged() { defer func() { if p := recover(); p != nil { log.Printf("panic in NetworkChanged %s: %s", p, debug.Stack()) @@ -240,7 +239,6 @@ func (b *backend) NetworkChanged(ifname string) { if nm, ok := b.sys.NetMon.GetOK(); ok { nm.InjectEvent() } - interfaces.UpdateLastKnownDefaultRouteInterface(ifname) } }