- Fixed checking of Configuration DNS Servers.
This commit is contained in:
@ -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'
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user