From e8e07c73c9e8a802c30e2a5dc6cd7cbad118f7d5 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 8 Aug 2019 10:22:10 +0300 Subject: [PATCH] - Fixed checking of Configuration DNS Servers. --- app/build.gradle | 4 +-- .../com/tutpro/baresip/AccountActivity.kt | 2 +- .../com/tutpro/baresip/ConfigActivity.kt | 2 +- .../main/kotlin/com/tutpro/baresip/Utils.kt | 31 +++++++------------ .../android/en-US/changelogs/8.5.2.txt | 1 + 5 files changed, 17 insertions(+), 23 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/8.5.2.txt diff --git a/app/build.gradle b/app/build.gradle index d57cd0b2..3c5c4bb2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId = 'com.tutpro.baresip' minSdkVersion 21 targetSdkVersion 28 - versionCode = 80 - versionName = '8.5.1' + versionCode = 81 + versionName = '8.5.2' externalNativeBuild { cmake { cFlags '-DHAVE_INTTYPES_H' diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt index e30b4e79..1bba6674 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountActivity.kt @@ -286,7 +286,7 @@ class AccountActivity : AppCompatActivity() { if (mediaNat != "") { val newStunServer = stunServer.text.toString().trim() if (acc.stunServer != newStunServer) { - if (!Utils.checkHostPort(newStunServer, false)) { + if (!Utils.checkHostPort(newStunServer)) { Utils.alertView(this, "Notice", "Invalid STUN Server '$newStunServer'") return false diff --git a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt index d257ee96..bfe38483 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/ConfigActivity.kt @@ -309,7 +309,7 @@ class ConfigActivity : AppCompatActivity() { private fun checkDnsServers(dnsServers: String): Boolean { if (dnsServers.length == 0) return true for (server in dnsServers.split(",")) - if (!Utils.checkHostPort(server.trim(), true)) return false + if (!Utils.checkIpPort(server.trim())) return false return true } diff --git a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt index 9c1ef77d..c22819a0 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Utils.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Utils.kt @@ -107,7 +107,6 @@ object Utils { Log.e("Baresip", "Failed to read asset " + asset + ": " + e.toString()) } - } fun alertView(context: Context, title: String, message: String) { @@ -201,22 +200,6 @@ object Utils { return (number > 0) && (number < 65536) } - fun checkHost(host: String): Boolean { - return checkIp(host) || checkDomain(host) - } - - fun checkHostPort(hostPort: String, portMandatory: Boolean): Boolean { - if (portMandatory) { - return checkHost(hostPort.substringBeforeLast(":")) && - checkPort(hostPort.substringAfterLast(":")) - } else { - if (hostPort.substringAfterLast(":").contains(Regex("^[0-9]+\$"))) - return checkHostPort(hostPort, true) - else - return checkHost(hostPort) - } - } - fun checkIpPort(ipPort: String): Boolean { if (ipPort.startsWith("[")) return checkIpv6InBrackets(ipPort.substringBeforeLast(":")) && @@ -226,6 +209,16 @@ object Utils { checkPort(ipPort.substringAfterLast(":")) } + fun checkDomainPort(domainPort: String): Boolean { + return checkDomain(domainPort.substringBeforeLast(":")) && + checkPort(domainPort.substringAfterLast(":")) + } + + fun checkHostPort(hostPort: String): Boolean { + return checkIp(hostPort) || checkDomain(hostPort) || + checkIpPort(hostPort) || checkDomainPort(hostPort) + } + fun checkParams(params: String): Boolean { for (param in params.split(";")) if (!checkParam(param)) return false @@ -246,9 +239,9 @@ object Utils { fun checkHostPortParams(hpp: String) : Boolean { val restParams = hpp.split(";", limit = 2) if (restParams.size == 1) - return checkHostPort(restParams[0], false) + return checkHostPort(restParams[0]) else - return checkHostPort(restParams[0], false) && checkParams(restParams[1]) + return checkHostPort(restParams[0]) && checkParams(restParams[1]) } fun checkSipUri(uri: String): Boolean { diff --git a/fastlane/metadata/android/en-US/changelogs/8.5.2.txt b/fastlane/metadata/android/en-US/changelogs/8.5.2.txt new file mode 100644 index 00000000..af3df476 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/8.5.2.txt @@ -0,0 +1 @@ +- Fixed checking of Configuration DNS Servers.