We were updating DNS configs when capabilities changed, without LinkProperties having been filled in. Because onAvailable always happened first, LinkProperties were created with default value, and onCapabilitiesChanged sent a DNS update using those LinkProperties.
This change only updates DNS configs on LinkProperties, which is the last update sent on a network change.
Updates tailscale/tailscale#13173
Signed-off-by: kari-ts <kari@tailscale.com>
privatevalactiveNetworks=mutableMapOf<Network,NetworkInfo>()// keyed by Network
// monitorDnsChanges sets up a network callback to monitor changes to the
@ -36,7 +33,9 @@ object NetworkChangeCallback {
.build()
// Use registerNetworkCallback to listen for updates from all networks, and
// then update DNS configs for the best network.
// then update DNS configs for the best network when LinkProperties are changed.
// Per
// https://developer.android.com/reference/android/net/ConnectivityManager.NetworkCallback#onAvailable(android.net.Network), this happens after all other updates.
//
// Note that we can't use registerDefaultNetworkCallback because the
// default network used by Tailscale will always show up with capability