- 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:
@ -1,4 +1,5 @@
|
||||
auto_start no
|
||||
log_level 2
|
||||
poll_method epoll
|
||||
sip_trans_bsize 128
|
||||
call_local_timeout 120
|
||||
@ -14,6 +15,8 @@ rtcp_mux no
|
||||
jitter_buffer_delay 5-10
|
||||
rtp_stats no
|
||||
dns_server 8.8.8.8:53
|
||||
dns_server [2001:4860:4860::8888]:53
|
||||
prefer_ipv6 no
|
||||
module opus.so
|
||||
module g711.so
|
||||
module opensles.so
|
||||
|
||||
@ -439,6 +439,14 @@ Java_com_tutpro_baresip_BaresipService_baresipStart(JNIEnv *env, jobject instanc
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
/* char debug_buf[2048];
|
||||
int l;
|
||||
l = re_snprintf(&(debug_buf[0]), 2047, "%H", net_debug, baresip_network());
|
||||
if (l != -1) {
|
||||
debug_buf[l] = '\0';
|
||||
LOGD("%s\n", debug_buf);
|
||||
} */
|
||||
|
||||
LOGI("running main loop ...\n");
|
||||
err = re_main(signal_handler);
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
<TextView
|
||||
android:id="@+id/DnsServersTitle"
|
||||
android:id="@+id/PreferIPv6Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
@ -55,20 +55,39 @@
|
||||
android:textSize="18sp"
|
||||
android:textColor="@android:color/black"
|
||||
android:onClick="onClick"
|
||||
android:text="DNS Servers" >
|
||||
android:text="Prefer IPv6" >
|
||||
</TextView>
|
||||
<EditText
|
||||
android:id="@+id/DnsServers"
|
||||
<CheckBox
|
||||
android:id="@+id/PreferIPv6"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_toEndOf="@+id/DnsServersTitle"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:textSize="18sp"
|
||||
android:scrollHorizontally="true" >
|
||||
</EditText>
|
||||
android:layout_gravity="end"
|
||||
android:checked="false" >
|
||||
</CheckBox>
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/DnsServersTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingTop="6dp"
|
||||
android:onClick="onClick"
|
||||
android:text="DNS Servers"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="18sp">
|
||||
</TextView>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/DnsServers"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:textSize="18sp">
|
||||
</EditText>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@ -20,7 +20,10 @@
|
||||
<string name="obProxies">SIP URI of one or two proxies that must be used when sending requests.
|
||||
If two is given, REGISTER requests are sent to both and other requests are sent to
|
||||
one that responds. If no outbound proxy is given, requests are sent based on
|
||||
DNS NAPTR/SRV/A record lookup of callee URI hostpart.\nExample:\nsip:foo.com:5060;transport=tls
|
||||
DNS NAPTR/SRV/A record lookup of callee URI hostpart. If hostpart of SIP URI is an IPv6
|
||||
address, the address must be written inside brackets [].\nExamples:\n
|
||||
• sip:foo.com:5060;transport=tls\n
|
||||
• sip:[2001:67c:223:777::10]:5060;transport=tcp
|
||||
</string>
|
||||
<string name="register">If checked, registration is enabled and REGISTER requests are sent at
|
||||
12 minute intervals.
|
||||
@ -51,8 +54,11 @@
|
||||
<string name="defaultAccount">If checked, this account is selected when baresip is started.
|
||||
</string>>
|
||||
<string name="autoStart">If checked, baresip starts automatically after device (re)start.</string>
|
||||
<string name="preferIPv6">Prefer IPv6 if both IPv4 and IPv6 are available.</string>
|
||||
<string name="dnsServers">Comma separated list of DNS servers. Each DNS server is of form
|
||||
server:port. Factory default value is \'8.8.8.8:53\' pointing to public Google DNS server.</string>
|
||||
\'server:port\'. If server is an IPv6 address, the address must be written inside brackets [].
|
||||
Factory default value is \'8.8.8.8:53,[2001:4860:4860::8888]:53\' pointing to public Google
|
||||
DNS servers.</string>
|
||||
<string name="opusBitRate">Average maximum bit rate used by Opus audio stream.
|
||||
Valid value are 6000-510000. Factory default is 28000.</string>
|
||||
<string name="iceLite">If checked, ICE Lite Mode is used.</string>
|
||||
|
||||
Reference in New Issue
Block a user