From 36054fd508b91553801baaddb55568f793ac6fc8 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Fri, 30 Aug 2019 10:04:58 +0300 Subject: [PATCH] - Try to update dynamic DNS information if registration fails due to "Invalid argument" error. --- .../kotlin/com/tutpro/baresip/BaresipService.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index fddacf57..40283ebf 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -357,6 +357,22 @@ class BaresipService: Service() { "registering failed" -> { status[account_index] = R.drawable.dot_red updateStatusNotification() + if ((ev.size > 1) && (ev[1] == "Invalid argument")) { + // Most likely this error is due to DNS lookup failure + newEvent = "registering failed,DNS lookup failed" + if (dynDns) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + val activeNetwork = cm.activeNetwork + if (activeNetwork != null) { + val dnsServers = cm.getLinkProperties(activeNetwork).dnsServers + Log.d(LOG_TAG, "Updating DNS Servers = $dnsServers") + if (Config.updateDnsServers(dnsServers) != 0) + Log.w(LOG_TAG, "Failed to update DNS servers '$dnsServers'") + } else { + Log.d(LOG_TAG, "No active network!") + } + } + } if (!Utils.isVisible()) return }