Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ object NetworkChangeCallback {

if (dns.updateDNSFromNetwork(sb.toString())) {
TSLog.d(TAG, "$why: updated DNS config for iface=${info.linkProps.interfaceName}")

val gatewayIP =
info.linkProps.routes
.filter { it.isDefaultRoute && it.gateway != null }
.sortedBy { if (it.gateway is java.net.Inet4Address) 0 else 1 }
.firstNotNullOfOrNull { it.gateway?.hostAddress } ?: ""

Libtailscale.onGatewayChanged(gatewayIP)
Libtailscale.onDNSConfigChanged(info.linkProps.interfaceName)
}
}
Expand Down
7 changes: 7 additions & 0 deletions libtailscale/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package libtailscale

import (
"sync"

"tailscale.com/net/netmon"
)

var (
Expand Down Expand Up @@ -36,6 +38,11 @@ func OnDNSConfigChanged(ifname string) {
}
}

// OnGatewayChanged is called when LinkProperties provides an updated default gateway IP.
func OnGatewayChanged(gatewayIP string) {
netmon.UpdateLastKnownDefaultGateway(gatewayIP)
}

var android struct {
// mu protects all fields of this structure. However, once a
// non-nil jvm is returned from javaVM, all the other fields may
Expand Down
Loading