- added support for IPv6 (not tested due to lack of IPv6 network)
- new "Prefer IPv6" config option - IPv6 address is allowed in DNS Server and Outbound Proxy - added log_level config file variable - added Google IPv6 DNS server address
This commit is contained in:
@@ -212,7 +212,7 @@ class AccountActivity : AppCompatActivity() {
|
||||
if (ob != acc.outbound) {
|
||||
val outbound = ArrayList<String>()
|
||||
for (i in ob.indices) {
|
||||
if ((ob[i] == "") || Utils.checkOutboundUri(ob[i])) {
|
||||
if ((ob[i] == "") || checkOutboundUri(ob[i])) {
|
||||
if (account_set_outbound(acc.accp, ob[i], i) == 0) {
|
||||
if (ob[i] != "")
|
||||
outbound.add(account_outbound(acc.accp, i))
|
||||
@@ -413,6 +413,11 @@ class AccountActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkOutboundUri(uri: String): Boolean {
|
||||
if (!uri.startsWith("sip:")) return false
|
||||
return Utils.checkHostPortParams(uri.substring(4))
|
||||
}
|
||||
|
||||
private fun checkDisplayName(dn: String): Boolean {
|
||||
if (dn == "") return true
|
||||
val dnRegex = Regex("^([* .!%_`'~]|[+]|[-a-zA-Z0-9]){1,63}\$")
|
||||
|
||||
@@ -155,8 +155,12 @@ class BaresipService: Service() {
|
||||
Api.log_level_set(ll)
|
||||
Log.logLevelSet(ll)
|
||||
}
|
||||
if (!contents.contains("prefer_ipv6")) {
|
||||
contents = "prefer_ipv6 no\n${contents}"
|
||||
write = true
|
||||
}
|
||||
if (write) {
|
||||
Log.d(LOG_TAG, "Writing $contents")
|
||||
Log.d(LOG_TAG, "Writing '$contents'")
|
||||
Utils.putFileContents(file, contents)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@ class ConfigActivity : AppCompatActivity() {
|
||||
|
||||
internal lateinit var configFile: File
|
||||
internal lateinit var autoStart: CheckBox
|
||||
internal lateinit var preferIPv6: CheckBox
|
||||
internal lateinit var dnsServers: EditText
|
||||
internal lateinit var opusBitRate: EditText
|
||||
internal lateinit var iceLite: CheckBox
|
||||
internal lateinit var debug: CheckBox
|
||||
|
||||
private var oldAutoStart = ""
|
||||
private var oldPreferIPv6 = ""
|
||||
private var oldDnsServers = ""
|
||||
private var oldOpusBitrate = ""
|
||||
private var oldIceMode = ""
|
||||
@@ -47,6 +49,11 @@ class ConfigActivity : AppCompatActivity() {
|
||||
oldAutoStart = if (asCv.size == 0) "no" else asCv[0]
|
||||
autoStart.isChecked = oldAutoStart == "yes"
|
||||
|
||||
preferIPv6 = findViewById(R.id.PreferIPv6) as CheckBox
|
||||
val piCv = Utils.getNameValue(config, "prefer_ipv6")
|
||||
oldPreferIPv6 = if (piCv.size == 0) "no" else piCv[0]
|
||||
preferIPv6.isChecked = oldPreferIPv6 == "yes"
|
||||
|
||||
dnsServers = findViewById(R.id.DnsServers) as EditText
|
||||
val dsCv = Utils.getNameValue(config, "dns_server")
|
||||
var dsTv = ""
|
||||
@@ -96,7 +103,16 @@ class ConfigActivity : AppCompatActivity() {
|
||||
restart = false
|
||||
}
|
||||
|
||||
val dnsServers = dnsServers.text.toString().trim()
|
||||
var preferIPv6String = "no"
|
||||
if (preferIPv6.isChecked) preferIPv6String = "yes"
|
||||
if (oldPreferIPv6 != preferIPv6String) {
|
||||
config = Utils.removeLinesStartingWithName(config, "prefer_ipv6")
|
||||
config = "prefer_ipv6 $preferIPv6String\n$config"
|
||||
save = true
|
||||
restart = true
|
||||
}
|
||||
|
||||
val dnsServers = dnsServers.text.toString().trim().toLowerCase()
|
||||
if (dnsServers != oldDnsServers) {
|
||||
if (!checkDnsServers(dnsServers)) {
|
||||
Utils.alertView(this, "Notice", "Invalid DNS Servers: $dnsServers")
|
||||
@@ -148,6 +164,7 @@ class ConfigActivity : AppCompatActivity() {
|
||||
// Log.d("Baresip", "Config line $trimmedLine")
|
||||
newConfig += trimmedLine.split("#")[0] + "\n"
|
||||
}
|
||||
Log.d("Baresip", "New config '$newConfig'")
|
||||
Utils.putFileContents(configFile, newConfig)
|
||||
// Api.reload_config()
|
||||
}
|
||||
@@ -172,6 +189,9 @@ class ConfigActivity : AppCompatActivity() {
|
||||
findViewById(R.id.AutoStartTitle) as TextView-> {
|
||||
Utils.alertView(this, "Start Automatically", getString(R.string.autoStart))
|
||||
}
|
||||
findViewById(R.id.PreferIPv6Title) as TextView-> {
|
||||
Utils.alertView(this, "Prefer IPv6", getString(R.string.preferIPv6))
|
||||
}
|
||||
findViewById(R.id.DnsServersTitle) as TextView -> {
|
||||
Utils.alertView(this, "DNS Servers", getString(R.string.dnsServers))
|
||||
}
|
||||
|
||||
@@ -244,11 +244,6 @@ object Utils {
|
||||
return checkDomain(userDomain[1]) || checkIP(userDomain[1])
|
||||
}
|
||||
|
||||
fun checkOutboundUri(uri: String): Boolean {
|
||||
if (!uri.startsWith("sip:")) return false
|
||||
return checkHostPortParams(uri.substring(4))
|
||||
}
|
||||
|
||||
fun checkPrintAscii(s: String): Boolean {
|
||||
if (s == "") return true
|
||||
return Regex("^[ -~]*\$").matches(s)
|
||||
|
||||
Reference in New Issue
Block a user