Added Transport Protocols setting
This commit is contained in:
@ -53,6 +53,10 @@ object Config {
|
|||||||
BaresipService.addressFamily = addressFamily
|
BaresipService.addressFamily = addressFamily
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val transportProtocols = previousVariable("sip_transports")
|
||||||
|
if (transportProtocols != "")
|
||||||
|
config = "${config}sip_transports $transportProtocols\n"
|
||||||
|
|
||||||
val sipCertificate = previousVariable("sip_certificate")
|
val sipCertificate = previousVariable("sip_certificate")
|
||||||
if (sipCertificate != "")
|
if (sipCertificate != "")
|
||||||
config = "${config}sip_certificate $sipCertificate\n"
|
config = "${config}sip_certificate $sipCertificate\n"
|
||||||
|
|||||||
@ -397,6 +397,34 @@ private fun SettingsContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun TransportProtocols() {
|
||||||
|
Row(
|
||||||
|
Modifier.fillMaxWidth().padding(end = 10.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.Start
|
||||||
|
) {
|
||||||
|
val ctx = LocalContext.current
|
||||||
|
val transportProtocols by viewModel.transportProtocols.collectAsState()
|
||||||
|
OutlinedTextField(
|
||||||
|
value = transportProtocols,
|
||||||
|
onValueChange = {
|
||||||
|
viewModel.transportProtocols.value = it
|
||||||
|
},
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable {
|
||||||
|
alertTitle.value = ctx.getString(R.string.transport_protocols)
|
||||||
|
alertMessage.value = ctx.getString(R.string.transport_protocols_help)
|
||||||
|
showAlert.value = true
|
||||||
|
},
|
||||||
|
textStyle = androidx.compose.ui.text.TextStyle(fontSize = 18.sp),
|
||||||
|
label = { Text(stringResource(R.string.transport_protocols)) },
|
||||||
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DnsServers() {
|
fun DnsServers() {
|
||||||
Row(
|
Row(
|
||||||
@ -1193,6 +1221,7 @@ private fun SettingsContent(
|
|||||||
item { StartAutomatically() }
|
item { StartAutomatically() }
|
||||||
item { ListenAddress() }
|
item { ListenAddress() }
|
||||||
item { AddressFamily() }
|
item { AddressFamily() }
|
||||||
|
item { TransportProtocols() }
|
||||||
item { DnsServers() }
|
item { DnsServers() }
|
||||||
item { TlsCertificateFile(activity) }
|
item { TlsCertificateFile(activity) }
|
||||||
item { VerifyServer() }
|
item { VerifyServer() }
|
||||||
@ -1246,6 +1275,23 @@ private fun checkOnClick(ctx: Context, viewModel: SettingsViewModel): Boolean {
|
|||||||
restart = true
|
restart = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val transportProtocols = viewModel.transportProtocols.value
|
||||||
|
.lowercase(Locale.ROOT).replace(" ", "")
|
||||||
|
if (transportProtocols != viewModel.oldTransportProtocols) {
|
||||||
|
if (!checkTransportProtocols(transportProtocols)) {
|
||||||
|
alertTitle.value = ctx.getString(R.string.notice)
|
||||||
|
alertMessage.value = "${ctx.getString(R.string.invalid_transport_protocols)}: " +
|
||||||
|
transportProtocols
|
||||||
|
showAlert.value = true
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Config.removeVariable("sip_transports")
|
||||||
|
if (transportProtocols.isNotEmpty())
|
||||||
|
Config.replaceVariable("sip_transports", transportProtocols)
|
||||||
|
save = true
|
||||||
|
restart = true
|
||||||
|
}
|
||||||
|
|
||||||
val dnsServers = addMissingPorts(viewModel.dnsServers.value
|
val dnsServers = addMissingPorts(viewModel.dnsServers.value
|
||||||
.lowercase(Locale.ROOT).replace(" ", ""))
|
.lowercase(Locale.ROOT).replace(" ", ""))
|
||||||
if (dnsServers != viewModel.oldDnsServers) {
|
if (dnsServers != viewModel.oldDnsServers) {
|
||||||
@ -1414,6 +1460,15 @@ private fun addMissingPorts(addressList: String): String {
|
|||||||
return result.substring(1)
|
return result.substring(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkTransportProtocols(transportProtocols: String): Boolean {
|
||||||
|
if (transportProtocols.isEmpty())
|
||||||
|
return true
|
||||||
|
for (protocol in transportProtocols.split(","))
|
||||||
|
if (protocol !in listOf("udp", "tcp", "tls", "ws", "wss"))
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkDnsServers(dnsServers: String): Boolean {
|
private fun checkDnsServers(dnsServers: String): Boolean {
|
||||||
if (dnsServers.isEmpty()) return true
|
if (dnsServers.isEmpty()) return true
|
||||||
for (server in dnsServers.split(","))
|
for (server in dnsServers.split(","))
|
||||||
|
|||||||
@ -18,8 +18,11 @@ class SettingsViewModel: ViewModel() {
|
|||||||
val autoStart = MutableStateFlow(false)
|
val autoStart = MutableStateFlow(false)
|
||||||
val listenAddress = MutableStateFlow("")
|
val listenAddress = MutableStateFlow("")
|
||||||
val addressFamily = MutableStateFlow("")
|
val addressFamily = MutableStateFlow("")
|
||||||
val dnsServers = MutableStateFlow("")
|
|
||||||
|
|
||||||
|
val transportProtocols = MutableStateFlow("")
|
||||||
|
val oldTransportProtocols = Config.variable("sip_transports")
|
||||||
|
|
||||||
|
val dnsServers = MutableStateFlow("")
|
||||||
val oldDnsServers = if (Config.variable("dyn_dns") == "yes")
|
val oldDnsServers = if (Config.variable("dyn_dns") == "yes")
|
||||||
""
|
""
|
||||||
else {
|
else {
|
||||||
@ -59,6 +62,8 @@ class SettingsViewModel: ViewModel() {
|
|||||||
mutableIntStateOf(familyValues.indexOf(Config.variable("net_af").lowercase()))
|
mutableIntStateOf(familyValues.indexOf(Config.variable("net_af").lowercase()))
|
||||||
addressFamily.value = familyValues[itemPosition.intValue]
|
addressFamily.value = familyValues[itemPosition.intValue]
|
||||||
|
|
||||||
|
transportProtocols.value = oldTransportProtocols
|
||||||
|
|
||||||
dnsServers.value = oldDnsServers
|
dnsServers.value = oldDnsServers
|
||||||
|
|
||||||
tlsCertificateFile.value = File(BaresipService.filesPath + "/cert.pem").exists()
|
tlsCertificateFile.value = File(BaresipService.filesPath + "/cert.pem").exists()
|
||||||
|
|||||||
@ -338,6 +338,12 @@
|
|||||||
on valittu, baresip käyttää ainoastaan IPv4- tai IPv6-osoitteita. Jos kumpaakaan ei ole
|
on valittu, baresip käyttää ainoastaan IPv4- tai IPv6-osoitteita. Jos kumpaakaan ei ole
|
||||||
valittu, baresip käyttää sekä IPv4- että IPv6-osoitteita.
|
valittu, baresip käyttää sekä IPv4- että IPv6-osoitteita.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="transport_protocols">Kuljetusprotokollat</string>
|
||||||
|
<string name="transport_protocols_help">Pilkulla toisistaan erotettu lista tuettuja SIP sanomien
|
||||||
|
kuljetusprotokollia. Jos jätetään tyhjäksi, oletusarvo on \'udp,tcp,tls,ws,wss\', joka
|
||||||
|
kaikki tuetut siirtoprotokollat.
|
||||||
|
</string>
|
||||||
|
<string name="invalid_transport_protocols">Virheellinen kuljetusprotokollalista</string>s
|
||||||
<string name="dns_servers">DNS-palvelimet</string>
|
<string name="dns_servers">DNS-palvelimet</string>
|
||||||
<string name="dns_servers_help">Pilkulla toisistaan erotettu luettelo DNS-palvelijoiden
|
<string name="dns_servers_help">Pilkulla toisistaan erotettu luettelo DNS-palvelijoiden
|
||||||
osoitteita. Jos jätetään antamatta (oletus), osoitteet hankitaan dynaamisesti järjestelmästä.
|
osoitteita. Jos jätetään antamatta (oletus), osoitteet hankitaan dynaamisesti järjestelmästä.
|
||||||
|
|||||||
@ -324,6 +324,12 @@
|
|||||||
using. If IPv4 or IPv6 is chosen, baresip uses only IPv4 or IPv6 addresses. If neither is
|
using. If IPv4 or IPv6 is chosen, baresip uses only IPv4 or IPv6 addresses. If neither is
|
||||||
chosen, baresip uses both IPv4 and IPv6 addresses.
|
chosen, baresip uses both IPv4 and IPv6 addresses.
|
||||||
</string>
|
</string>
|
||||||
|
<string name="transport_protocols">Transport Protocols</string>
|
||||||
|
<string name="transport_protocols_help">Comma separated list of supported SIP request/response
|
||||||
|
transport protocols. If left empty, default value is \'udp,tcp,tls,ws,wss\' that includes
|
||||||
|
all supported transport protocols.
|
||||||
|
</string>
|
||||||
|
<string name="invalid_transport_protocols">Invalid Transport Protocols list</string>
|
||||||
<string name="dns_servers">DNS Servers</string>
|
<string name="dns_servers">DNS Servers</string>
|
||||||
<string name="dns_servers_help">Comma separated list of addresses of DNS servers. If not given,
|
<string name="dns_servers_help">Comma separated list of addresses of DNS servers. If not given,
|
||||||
DNS server addresses are obtained dynamically from the system. Each DNS address is of form
|
DNS server addresses are obtained dynamically from the system. Each DNS address is of form
|
||||||
|
|||||||
Reference in New Issue
Block a user