- Update DNS servers and register UAs also when network becomes available.

This commit is contained in:
Juha Heinanen
2019-06-22 10:51:51 +03:00
parent b3c63455cc
commit 82e9a4d053

View File

@ -70,7 +70,13 @@ class BaresipService: Service() {
override fun onAvailable(network: Network) {
super.onAvailable(network)
Log.d(LOG_TAG, "Network '$network' is available")
// This is followed by onLinkPropertiesChanged
if (dynDns) {
val linkProperties = cm.getLinkProperties(network)
val dnsServers = linkProperties.dnsServers
if (Config.updateDnsServers(dnsServers) != 0)
Log.w(LOG_TAG, "Failed to update DNS servers '$dnsServers'")
}
UserAgent.register()
}
override fun onLost(network: Network) {
@ -82,7 +88,7 @@ class BaresipService: Service() {
super.onLinkPropertiesChanged(network, linkProperties)
Log.d(LOG_TAG, "Network $network link properties changed")
if (dynDns) {
val dnsServers = linkProperties.getDnsServers()
val dnsServers = linkProperties.dnsServers
if (Config.updateDnsServers(dnsServers) != 0)
Log.w(LOG_TAG, "Failed to update DNS servers '$dnsServers'")
}