feat(proxy): провайдер Relay/Direct в листе серверов, без упоминаний зла
This commit is contained in:
1 parent
0350afaa41
commit
0d0be57044
19 files changed
+194
-163
No files matched your search
@@ -2,8 +2,8 @@ package com.freeturn.app.data.config
|
|||||||
|
|
||||||
data class ClientConfig(
|
data class ClientConfig(
|
||||||
val serverAddress: String = "",
|
val serverAddress: String = "",
|
||||||
val vkLink: String = "",
|
val callLink: String = "",
|
||||||
val provider: String = Provider.VK,
|
val provider: String = Provider.RELAY,
|
||||||
val threads: Int = DEFAULT_THREADS,
|
val threads: Int = DEFAULT_THREADS,
|
||||||
val streamsPerCred: Int = DEFAULT_STREAMS_PER_CRED,
|
val streamsPerCred: Int = DEFAULT_STREAMS_PER_CRED,
|
||||||
val useUdp: Boolean = false,
|
val useUdp: Boolean = false,
|
||||||
@@ -34,10 +34,12 @@ data class ClientConfig(
|
|||||||
companion object {
|
companion object {
|
||||||
const val DEFAULT_LOCAL_PORT = "127.0.0.1:9000"
|
const val DEFAULT_LOCAL_PORT = "127.0.0.1:9000"
|
||||||
const val DEFAULT_THREADS = 12
|
const val DEFAULT_THREADS = 12
|
||||||
|
// Без реле нет лимитов на аллокацию: второй поток только делит очередь и добавляет handshake.
|
||||||
|
const val DIRECT_THREADS = 1
|
||||||
const val DEFAULT_STREAMS_PER_CRED = 12
|
const val DEFAULT_STREAMS_PER_CRED = 12
|
||||||
// Не настройка, а константа транспорта: WG идёт поверх TURN (STUN-обёртка +
|
// Не настройка, а константа транспорта: WG идёт поверх TURN (STUN-обёртка +
|
||||||
// UDP + IP), дефолтные 1420 фрагментируются. 1280 - минимум IPv6, живёт везде.
|
// UDP + IP), дефолтные 1420 фрагментируются. 1280 - минимум IPv6, живёт везде.
|
||||||
// Серверная сторона держит то же значение (control.sh, WG_MTU).
|
// Серверная сторона держит то же значение (install.sh, WG_MTU).
|
||||||
const val WG_MTU = 1280
|
const val WG_MTU = 1280
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.freeturn.app.data.config
|
|||||||
|
|
||||||
import com.freeturn.app.data.DnsList
|
import com.freeturn.app.data.DnsList
|
||||||
import com.freeturn.app.data.server.ServerOpts
|
import com.freeturn.app.data.server.ServerOpts
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ data class CoreConfigJson(
|
|||||||
val routes: Boolean,
|
val routes: Boolean,
|
||||||
val turn: Turn,
|
val turn: Turn,
|
||||||
val proxy: Proxy,
|
val proxy: Proxy,
|
||||||
val vk: Vk,
|
@SerialName("vk") val relay: Relay,
|
||||||
val obf: Obf,
|
val obf: Obf,
|
||||||
val dns: Dns,
|
val dns: Dns,
|
||||||
val log: Log,
|
val log: Log,
|
||||||
@@ -46,7 +47,7 @@ data class CoreConfigJson(
|
|||||||
)
|
)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Vk(
|
data class Relay(
|
||||||
val links: List<String>,
|
val links: List<String>,
|
||||||
val streamsPerCred: Int,
|
val streamsPerCred: Int,
|
||||||
val manualCaptcha: Boolean,
|
val manualCaptcha: Boolean,
|
||||||
@@ -128,7 +129,8 @@ fun ClientConfig.toCoreJson(
|
|||||||
routes = false,
|
routes = false,
|
||||||
turn = CoreConfigJson.Turn(
|
turn = CoreConfigJson.Turn(
|
||||||
// Поле обязательное, а CLI без -n брал свой дефолт.
|
// Поле обязательное, а CLI без -n брал свой дефолт.
|
||||||
n = threads.takeIf { it > 0 } ?: ClientConfig.DEFAULT_THREADS,
|
n = if (provider == Provider.DIRECT) ClientConfig.DIRECT_THREADS
|
||||||
|
else threads.takeIf { it > 0 } ?: ClientConfig.DEFAULT_THREADS,
|
||||||
transport = if (useUdp) CoreConfigJson.TRANSPORT_UDP else CoreConfigJson.TRANSPORT_TCP,
|
transport = if (useUdp) CoreConfigJson.TRANSPORT_UDP else CoreConfigJson.TRANSPORT_TCP,
|
||||||
host = if (magicSwitch) magicTurn.trim() else "",
|
host = if (magicSwitch) magicTurn.trim() else "",
|
||||||
port = "",
|
port = "",
|
||||||
@@ -139,8 +141,8 @@ fun ClientConfig.toCoreJson(
|
|||||||
// но валидацию проходит и нужен прокси-режиму.
|
// но валидацию проходит и нужен прокси-режиму.
|
||||||
listen = localPort,
|
listen = localPort,
|
||||||
),
|
),
|
||||||
vk = CoreConfigJson.Vk(
|
relay = CoreConfigJson.Relay(
|
||||||
links = listOf(vkLink),
|
links = listOf(callLink),
|
||||||
streamsPerCred = streamsPerCred.takeIf { it > 0 }
|
streamsPerCred = streamsPerCred.takeIf { it > 0 }
|
||||||
?: ClientConfig.DEFAULT_STREAMS_PER_CRED,
|
?: ClientConfig.DEFAULT_STREAMS_PER_CRED,
|
||||||
manualCaptcha = manualCaptcha,
|
manualCaptcha = manualCaptcha,
|
||||||
|
|||||||
@@ -22,8 +22,11 @@ object DnsMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Provider {
|
object Provider {
|
||||||
const val VK = "vk"
|
// Через TURN-реле звонков. "vk" - wire-значение ядра (config.ClientJSON, freeturn://).
|
||||||
val VALUES = listOf(VK)
|
const val RELAY = "vk"
|
||||||
|
/** Без реле: DTLS+OBF прямо на peer; не спасает, если IP VPS недоступен. */
|
||||||
|
const val DIRECT = "direct"
|
||||||
|
val VALUES = listOf(RELAY, DIRECT)
|
||||||
}
|
}
|
||||||
|
|
||||||
object ObfProfile {
|
object ObfProfile {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ val DEFAULT_BYPASS_APPS: Set<String> = linkedSetOf(
|
|||||||
"ru.yandex.yandexmaps",
|
"ru.yandex.yandexmaps",
|
||||||
"ru.yandex.music",
|
"ru.yandex.music",
|
||||||
"ru.kinopoisk",
|
"ru.kinopoisk",
|
||||||
// VK / соцсети / медиа
|
// Соцсети / медиа
|
||||||
"ru.oneme.app",
|
"ru.oneme.app",
|
||||||
"ru.vk.store",
|
"ru.vk.store",
|
||||||
"ru.ok.android",
|
"ru.ok.android",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ data class TunnelSetup(
|
|||||||
* остановки, `Mobile.start` синхронно валидирует конфиг и поднимает устройство.
|
* остановки, `Mobile.start` синхронно валидирует конфиг и поднимает устройство.
|
||||||
*
|
*
|
||||||
* [stateDir] - каталог, где ядро держит состояние между запусками (поколение
|
* [stateDir] - каталог, где ядро держит состояние между запусками (поколение
|
||||||
* VK-персоны, кэш TURN-реквизитов). Свои дефолты ядра из app-uid не пишутся.
|
* персоны провайдера, кэш TURN-реквизитов). Свои дефолты ядра из app-uid не пишутся.
|
||||||
*/
|
*/
|
||||||
class ProxyEngine(
|
class ProxyEngine(
|
||||||
private val stateDir: String,
|
private val stateDir: String,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.freeturn.app.ui.components
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import com.freeturn.app.R
|
||||||
|
import com.freeturn.app.data.config.Provider
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun providerLabel(value: String): String = when (value) {
|
||||||
|
Provider.RELAY -> stringResource(R.string.provider_relay)
|
||||||
|
Provider.DIRECT -> stringResource(R.string.provider_direct)
|
||||||
|
else -> value
|
||||||
|
}
|
||||||
|
|
||||||
|
@DrawableRes
|
||||||
|
fun providerIcon(value: String): Int = when (value) {
|
||||||
|
Provider.RELAY -> R.drawable.conversion_path_24px
|
||||||
|
else -> R.drawable.bolt_24px
|
||||||
|
}
|
||||||
@@ -12,9 +12,8 @@ import android.webkit.WebViewClient
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
@@ -35,6 +34,7 @@ import androidx.compose.ui.window.Dialog
|
|||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
|
import com.freeturn.app.ui.components.BusyProgressIndicator
|
||||||
|
|
||||||
/** Только локальный captcha-прокси ядра допускается к загрузке в WebView. */
|
/** Только локальный captcha-прокси ядра допускается к загрузке в WebView. */
|
||||||
private fun isLocalCaptchaUrl(url: String): Boolean {
|
private fun isLocalCaptchaUrl(url: String): Boolean {
|
||||||
@@ -44,8 +44,8 @@ private fun isLocalCaptchaUrl(url: String): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ручная VK-капча во встроенном WebView. Грузит локальный прокси ядра
|
* Ручная капча провайдера во встроенном WebView. Грузит локальный прокси ядра
|
||||||
* (127.0.0.1:8765), который переписывает VK-страницы так, чтобы весь трафик шёл
|
* (127.0.0.1:8765), который переписывает страницы провайдера так, чтобы весь трафик шёл
|
||||||
* через loopback. Диалог закрывается, когда ядро отрапортует о решении капчи
|
* через loopback. Диалог закрывается, когда ядро отрапортует о решении капчи
|
||||||
* (onCaptcha("") -> ProxyStore.setCaptcha("") -> пустой captchaUrl в status).
|
* (onCaptcha("") -> ProxyStore.setCaptcha("") -> пустой captchaUrl в status).
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +81,7 @@ fun CaptchaWebViewDialog(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
TextButton(onClick = onDismiss) {
|
TextButton(shapes = ButtonDefaults.shapes(), onClick = onDismiss) {
|
||||||
Text(stringResource(R.string.captcha_close))
|
Text(stringResource(R.string.captcha_close))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,9 +139,9 @@ private fun CaptchaWebView(url: String) {
|
|||||||
onRelease = { it.destroy() }
|
onRelease = { it.destroy() }
|
||||||
)
|
)
|
||||||
if (progress < 1f) {
|
if (progress < 1f) {
|
||||||
LinearProgressIndicator(
|
BusyProgressIndicator(
|
||||||
progress = { progress },
|
progress = { progress },
|
||||||
modifier = Modifier.fillMaxWidth().align(Alignment.TopCenter)
|
modifier = Modifier.align(Alignment.TopCenter)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ package com.freeturn.app.ui.screens.clientsetup
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.SegmentedButton
|
|
||||||
import androidx.compose.material3.SegmentedButtonDefaults
|
|
||||||
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
|
import com.freeturn.app.ui.components.ChoiceOption
|
||||||
|
import com.freeturn.app.ui.components.ConnectedChoiceRow
|
||||||
import com.freeturn.app.ui.components.SectionLabel
|
import com.freeturn.app.ui.components.SectionLabel
|
||||||
import com.freeturn.app.ui.components.SettingsCard
|
import com.freeturn.app.ui.components.SettingsCard
|
||||||
import com.freeturn.app.ui.components.SettingsControlLabel
|
import com.freeturn.app.ui.components.SettingsControlLabel
|
||||||
@@ -42,18 +41,14 @@ internal fun AdvancedSection(
|
|||||||
title = stringResource(R.string.transport_protocol),
|
title = stringResource(R.string.transport_protocol),
|
||||||
desc = stringResource(R.string.transport_protocol_desc)
|
desc = stringResource(R.string.transport_protocol_desc)
|
||||||
)
|
)
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
ConnectedChoiceRow(
|
||||||
SegmentedButton(
|
options = listOf(
|
||||||
selected = !useUdp,
|
ChoiceOption(false, stringResource(R.string.tcp)),
|
||||||
onClick = { onUseUdp(false) },
|
ChoiceOption(true, stringResource(R.string.udp))
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
),
|
||||||
) { Text(stringResource(R.string.tcp)) }
|
|
||||||
SegmentedButton(
|
|
||||||
selected = useUdp,
|
selected = useUdp,
|
||||||
onClick = { onUseUdp(true) },
|
onSelect = onUseUdp
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
)
|
||||||
) { Text(stringResource(R.string.udp)) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import androidx.compose.foundation.layout.widthIn
|
|||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LargeFlexibleTopAppBar
|
import androidx.compose.material3.LargeFlexibleTopAppBar
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
@@ -84,7 +86,7 @@ fun ClientSetupScreen(
|
|||||||
// remember (не rememberSaveable), чтобы не восстанавливать stale-поля из bundle.
|
// remember (не rememberSaveable), чтобы не восстанавливать stale-поля из bundle.
|
||||||
val fieldsKey = serverId ?: snapshot.activeId
|
val fieldsKey = serverId ?: snapshot.activeId
|
||||||
var serverAddress by remember(fieldsKey) { mutableStateOf(saved.serverAddress) }
|
var serverAddress by remember(fieldsKey) { mutableStateOf(saved.serverAddress) }
|
||||||
var vkLink by remember(fieldsKey) { mutableStateOf(saved.vkLink) }
|
var callLink by remember(fieldsKey) { mutableStateOf(saved.callLink) }
|
||||||
var threads by remember(fieldsKey) { mutableFloatStateOf(saved.threads.toFloat()) }
|
var threads by remember(fieldsKey) { mutableFloatStateOf(saved.threads.toFloat()) }
|
||||||
var streamsPerCred by remember(fieldsKey) { mutableFloatStateOf(saved.streamsPerCred.toFloat()) }
|
var streamsPerCred by remember(fieldsKey) { mutableFloatStateOf(saved.streamsPerCred.toFloat()) }
|
||||||
var localPort by remember(fieldsKey) { mutableStateOf(saved.localPort) }
|
var localPort by remember(fieldsKey) { mutableStateOf(saved.localPort) }
|
||||||
@@ -97,7 +99,7 @@ fun ClientSetupScreen(
|
|||||||
LaunchedEffect(fieldsKey, saved) {
|
LaunchedEffect(fieldsKey, saved) {
|
||||||
if (fieldsDirty) return@LaunchedEffect
|
if (fieldsDirty) return@LaunchedEffect
|
||||||
serverAddress = saved.serverAddress
|
serverAddress = saved.serverAddress
|
||||||
vkLink = saved.vkLink
|
callLink = saved.callLink
|
||||||
threads = saved.threads.toFloat()
|
threads = saved.threads.toFloat()
|
||||||
streamsPerCred = saved.streamsPerCred.toFloat()
|
streamsPerCred = saved.streamsPerCred.toFloat()
|
||||||
localPort = saved.localPort
|
localPort = saved.localPort
|
||||||
@@ -118,7 +120,7 @@ fun ClientSetupScreen(
|
|||||||
clientEdit { current ->
|
clientEdit { current ->
|
||||||
current.copy(
|
current.copy(
|
||||||
serverAddress = serverAddress.trim(),
|
serverAddress = serverAddress.trim(),
|
||||||
vkLink = vkLink.trim(),
|
callLink = callLink.trim(),
|
||||||
threads = threads.roundToInt(),
|
threads = threads.roundToInt(),
|
||||||
streamsPerCred = streamsPerCred.roundToInt(),
|
streamsPerCred = streamsPerCred.roundToInt(),
|
||||||
localPort = localPort.trim(),
|
localPort = localPort.trim(),
|
||||||
@@ -130,7 +132,7 @@ fun ClientSetupScreen(
|
|||||||
|
|
||||||
var pendingSave by remember(fieldsKey) { mutableStateOf(false) }
|
var pendingSave by remember(fieldsKey) { mutableStateOf(false) }
|
||||||
LaunchedEffect(
|
LaunchedEffect(
|
||||||
fieldsKey, serverAddress, vkLink, threads, streamsPerCred, localPort, magicTurn, customDns
|
fieldsKey, serverAddress, callLink, threads, streamsPerCred, localPort, magicTurn, customDns
|
||||||
) {
|
) {
|
||||||
if (!fieldsDirty) return@LaunchedEffect
|
if (!fieldsDirty) return@LaunchedEffect
|
||||||
pendingSave = true
|
pendingSave = true
|
||||||
@@ -152,7 +154,7 @@ fun ClientSetupScreen(
|
|||||||
title = { Text(stringResource(R.string.provider_connection_settings)) },
|
title = { Text(stringResource(R.string.provider_connection_settings)) },
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
if (onBack != null) {
|
if (onBack != null) {
|
||||||
IconButton(onClick = onBack) {
|
IconButton(shapes = IconButtonDefaults.shapes(), onClick = onBack) {
|
||||||
Icon(
|
Icon(
|
||||||
painterResource(R.drawable.arrow_back_24px),
|
painterResource(R.drawable.arrow_back_24px),
|
||||||
contentDescription = stringResource(R.string.back)
|
contentDescription = stringResource(R.string.back)
|
||||||
@@ -183,14 +185,16 @@ fun ClientSetupScreen(
|
|||||||
ConnectionCard(
|
ConnectionCard(
|
||||||
serverAddress = serverAddress,
|
serverAddress = serverAddress,
|
||||||
onServerAddress = { serverAddress = it; fieldsDirty = true },
|
onServerAddress = { serverAddress = it; fieldsDirty = true },
|
||||||
showVkLink = saved.provider == Provider.VK,
|
showCallLink = saved.provider == Provider.RELAY,
|
||||||
vkLink = vkLink,
|
callLink = callLink,
|
||||||
onVkLink = { vkLink = it; fieldsDirty = true },
|
onCallLink = { callLink = it; fieldsDirty = true },
|
||||||
localPort = localPort,
|
localPort = localPort,
|
||||||
onLocalPort = { localPort = it; fieldsDirty = true },
|
onLocalPort = { localPort = it; fieldsDirty = true },
|
||||||
privacyMode = privacyMode
|
privacyMode = privacyMode
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// В direct поток всегда один (toCoreJson) - настраивать нечего.
|
||||||
|
if (saved.provider == Provider.RELAY) {
|
||||||
PerformanceCard(
|
PerformanceCard(
|
||||||
threads = threads,
|
threads = threads,
|
||||||
// потоки-на-аккаунт не могут превышать общее число потоков
|
// потоки-на-аккаунт не могут превышать общее число потоков
|
||||||
@@ -203,25 +207,22 @@ fun ClientSetupScreen(
|
|||||||
onStreamsPerCred = { streamsPerCred = it.coerceAtMost(threads); fieldsDirty = true },
|
onStreamsPerCred = { streamsPerCred = it.coerceAtMost(threads); fieldsDirty = true },
|
||||||
onTick = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) }
|
onTick = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
DnsCard(
|
DnsCard(
|
||||||
dnsMode = saved.dnsMode,
|
dnsMode = saved.dnsMode,
|
||||||
onDnsMode = { mode ->
|
onDnsMode = { mode -> clientEdit { it.copy(dnsMode = mode) } },
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
clientEdit { it.copy(dnsMode = mode) }
|
|
||||||
},
|
|
||||||
customDns = customDns,
|
customDns = customDns,
|
||||||
onCustomDns = { customDns = it; fieldsDirty = true },
|
onCustomDns = { customDns = it; fieldsDirty = true },
|
||||||
useCarrierDns = saved.useCarrierDns,
|
useCarrierDns = saved.useCarrierDns,
|
||||||
onUseCarrierDns = { v -> clientEdit { it.copy(useCarrierDns = v) } }
|
onUseCarrierDns = { v -> clientEdit { it.copy(useCarrierDns = v) } }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Транспорт до реле, captcha и свой TURN - всё про relay; direct их игнорирует.
|
||||||
|
if (saved.provider == Provider.RELAY) {
|
||||||
AdvancedSection(
|
AdvancedSection(
|
||||||
useUdp = saved.useUdp,
|
useUdp = saved.useUdp,
|
||||||
onUseUdp = { v ->
|
onUseUdp = { v -> clientEdit { it.copy(useUdp = v) } },
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
clientEdit { it.copy(useUdp = v) }
|
|
||||||
},
|
|
||||||
manualCaptcha = saved.manualCaptcha,
|
manualCaptcha = saved.manualCaptcha,
|
||||||
onManualCaptcha = { v -> clientEdit { it.copy(manualCaptcha = v) } },
|
onManualCaptcha = { v -> clientEdit { it.copy(manualCaptcha = v) } },
|
||||||
magicSwitch = saved.magicSwitch,
|
magicSwitch = saved.magicSwitch,
|
||||||
@@ -230,6 +231,7 @@ fun ClientSetupScreen(
|
|||||||
onMagicTurn = { magicTurn = it; fieldsDirty = true },
|
onMagicTurn = { magicTurn = it; fieldsDirty = true },
|
||||||
privacyMode = privacyMode
|
privacyMode = privacyMode
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(24.dp))
|
Spacer(Modifier.height(24.dp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import com.freeturn.app.ui.components.SettingsFieldSlot
|
|||||||
import com.freeturn.app.ui.components.SettingsRowDivider
|
import com.freeturn.app.ui.components.SettingsRowDivider
|
||||||
import com.freeturn.app.ui.util.redact
|
import com.freeturn.app.ui.util.redact
|
||||||
|
|
||||||
/** Адреса подключения: сервер, ссылка звонка (только VK), локальный listen. */
|
/** Адреса подключения: сервер, ссылка звонка (только relay), локальный listen. */
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ConnectionCard(
|
internal fun ConnectionCard(
|
||||||
serverAddress: String,
|
serverAddress: String,
|
||||||
onServerAddress: (String) -> Unit,
|
onServerAddress: (String) -> Unit,
|
||||||
showVkLink: Boolean,
|
showCallLink: Boolean,
|
||||||
vkLink: String,
|
callLink: String,
|
||||||
onVkLink: (String) -> Unit,
|
onCallLink: (String) -> Unit,
|
||||||
localPort: String,
|
localPort: String,
|
||||||
onLocalPort: (String) -> Unit,
|
onLocalPort: (String) -> Unit,
|
||||||
privacyMode: Boolean
|
privacyMode: Boolean
|
||||||
@@ -37,12 +37,12 @@ internal fun ConnectionCard(
|
|||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri)
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (showVkLink) {
|
if (showCallLink) {
|
||||||
SettingsRowDivider()
|
SettingsRowDivider()
|
||||||
SettingsFieldSlot {
|
SettingsFieldSlot {
|
||||||
LabeledTextField(
|
LabeledTextField(
|
||||||
value = vkLink.redact(privacyMode),
|
value = callLink.redact(privacyMode),
|
||||||
onValueChange = { if (!privacyMode) onVkLink(it) },
|
onValueChange = { if (!privacyMode) onCallLink(it) },
|
||||||
labelRes = R.string.call_link_label,
|
labelRes = R.string.call_link_label,
|
||||||
placeholderRes = R.string.call_link_placeholder,
|
placeholderRes = R.string.call_link_placeholder,
|
||||||
supportingRes = R.string.call_link_support,
|
supportingRes = R.string.call_link_support,
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ package com.freeturn.app.ui.screens.clientsetup
|
|||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
import androidx.compose.material3.SegmentedButton
|
|
||||||
import androidx.compose.material3.SegmentedButtonDefaults
|
|
||||||
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
@@ -16,6 +13,8 @@ import androidx.compose.ui.text.input.KeyboardType
|
|||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
import com.freeturn.app.data.DnsList
|
import com.freeturn.app.data.DnsList
|
||||||
import com.freeturn.app.data.config.DnsMode
|
import com.freeturn.app.data.config.DnsMode
|
||||||
|
import com.freeturn.app.ui.components.ChoiceOption
|
||||||
|
import com.freeturn.app.ui.components.ConnectedChoiceRow
|
||||||
import com.freeturn.app.ui.components.SectionLabel
|
import com.freeturn.app.ui.components.SectionLabel
|
||||||
import com.freeturn.app.ui.components.SettingsCard
|
import com.freeturn.app.ui.components.SettingsCard
|
||||||
import com.freeturn.app.ui.components.SettingsControlLabel
|
import com.freeturn.app.ui.components.SettingsControlLabel
|
||||||
@@ -46,20 +45,15 @@ internal fun DnsCard(
|
|||||||
title = stringResource(R.string.dns_mode_title),
|
title = stringResource(R.string.dns_mode_title),
|
||||||
desc = stringResource(R.string.dns_mode_desc)
|
desc = stringResource(R.string.dns_mode_desc)
|
||||||
)
|
)
|
||||||
val dnsOptions = listOf(
|
ConnectedChoiceRow(
|
||||||
DnsMode.AUTO to stringResource(R.string.dns_mode_auto),
|
options = listOf(
|
||||||
DnsMode.PLAIN to stringResource(R.string.dns_mode_udp),
|
ChoiceOption(DnsMode.AUTO, stringResource(R.string.dns_mode_auto)),
|
||||||
DnsMode.DOH to stringResource(R.string.dns_mode_doh)
|
ChoiceOption(DnsMode.PLAIN, stringResource(R.string.dns_mode_udp)),
|
||||||
|
ChoiceOption(DnsMode.DOH, stringResource(R.string.dns_mode_doh))
|
||||||
|
),
|
||||||
|
selected = dnsMode,
|
||||||
|
onSelect = onDnsMode
|
||||||
)
|
)
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
dnsOptions.forEachIndexed { idx, (value, label) ->
|
|
||||||
SegmentedButton(
|
|
||||||
selected = dnsMode == value,
|
|
||||||
onClick = { onDnsMode(value) },
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = dnsOptions.size)
|
|
||||||
) { Text(label) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
SettingsRowDivider()
|
SettingsRowDivider()
|
||||||
SettingsFieldSlot {
|
SettingsFieldSlot {
|
||||||
|
|||||||
@@ -127,9 +127,8 @@ fun HomeScreen(
|
|||||||
ServersSheetContent(
|
ServersSheetContent(
|
||||||
snapshot = serversSnapshot,
|
snapshot = serversSnapshot,
|
||||||
privacyMode = privacyMode,
|
privacyMode = privacyMode,
|
||||||
callLink = clientConfig.vkLink,
|
callLink = clientConfig.callLink,
|
||||||
// Правка ссылки только пока прокси стоит (новая комната = реконнект).
|
providerLocked = status.busy,
|
||||||
callLinkLocked = status.busy,
|
|
||||||
onApplyServer = { id ->
|
onApplyServer = { id ->
|
||||||
serverConfigViewModel.applyServer(id)
|
serverConfigViewModel.applyServer(id)
|
||||||
scope.launch { sheetScaffoldState.bottomSheetState.partialExpand() }
|
scope.launch { sheetScaffoldState.bottomSheetState.partialExpand() }
|
||||||
@@ -139,7 +138,8 @@ fun HomeScreen(
|
|||||||
scope.launch { sheetScaffoldState.bottomSheetState.partialExpand() }
|
scope.launch { sheetScaffoldState.bottomSheetState.partialExpand() }
|
||||||
onOpenServerSettings(id)
|
onOpenServerSettings(id)
|
||||||
},
|
},
|
||||||
onSaveCallLink = { serverConfigViewModel.setActiveVkLink(it) }
|
onSaveCallLink = { serverConfigViewModel.setActiveCallLink(it) },
|
||||||
|
onSetProvider = { serverConfigViewModel.setActiveProvider(it) }
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
snackbarHost = { SnackbarHost(snackbarHostState) }
|
snackbarHost = { SnackbarHost(snackbarHostState) }
|
||||||
|
|||||||
@@ -5,14 +5,19 @@
|
|||||||
|
|
||||||
package com.freeturn.app.ui.screens.home
|
package com.freeturn.app.ui.screens.home
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.EnterTransition
|
||||||
|
import androidx.compose.animation.ExitTransition
|
||||||
|
import androidx.compose.animation.expandVertically
|
||||||
|
import androidx.compose.animation.fadeIn
|
||||||
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.shrinkVertically
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.RowScope
|
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
@@ -22,9 +27,8 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -55,6 +59,12 @@ import androidx.compose.ui.text.style.TextAlign
|
|||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.freeturn.app.R
|
import com.freeturn.app.R
|
||||||
|
import com.freeturn.app.ui.components.ChoiceOption
|
||||||
|
import com.freeturn.app.ui.components.ConnectedChoiceRow
|
||||||
|
import com.freeturn.app.ui.components.SettingsEntryRow
|
||||||
|
import com.freeturn.app.ui.components.providerIcon
|
||||||
|
import com.freeturn.app.ui.components.providerLabel
|
||||||
|
import com.freeturn.app.ui.theme.LocalReducedMotion
|
||||||
import com.freeturn.app.ui.util.HapticUtil
|
import com.freeturn.app.ui.util.HapticUtil
|
||||||
import com.freeturn.app.data.config.Provider
|
import com.freeturn.app.data.config.Provider
|
||||||
import com.freeturn.app.data.server.ServersSnapshot
|
import com.freeturn.app.data.server.ServersSnapshot
|
||||||
@@ -69,15 +79,15 @@ internal fun ServersSheetContent(
|
|||||||
snapshot: ServersSnapshot,
|
snapshot: ServersSnapshot,
|
||||||
privacyMode: Boolean = false,
|
privacyMode: Boolean = false,
|
||||||
callLink: String = "",
|
callLink: String = "",
|
||||||
// Прокси запущен - правку ссылки на звонок блокируем (новая комната = реконнект).
|
// Прокси запущен - провайдер и ссылку не меняем (иначе реконнект).
|
||||||
callLinkLocked: Boolean = false,
|
providerLocked: Boolean = false,
|
||||||
onApplyServer: (String) -> Unit = {},
|
onApplyServer: (String) -> Unit = {},
|
||||||
onOpenServerSettings: (String) -> Unit = {},
|
onOpenServerSettings: (String) -> Unit = {},
|
||||||
onSaveCallLink: (String) -> Unit = {}
|
onSaveCallLink: (String) -> Unit = {},
|
||||||
|
onSetProvider: (String) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
val active = snapshot.active
|
val active = snapshot.active
|
||||||
// Менять ссылку можно только у сохранённого активного сервера и пока прокси стоит.
|
val providerEditable = active != null && !providerLocked
|
||||||
val callLinkEditable = active != null && !callLinkLocked
|
|
||||||
var showCallLinkDialog by rememberSaveable { mutableStateOf(false) }
|
var showCallLinkDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -125,11 +135,14 @@ internal fun ServersSheetContent(
|
|||||||
|
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(16.dp))
|
||||||
|
|
||||||
ProviderChip(
|
ProviderPicker(
|
||||||
current = active?.client?.provider ?: Provider.VK,
|
current = active?.client?.provider ?: Provider.RELAY,
|
||||||
editable = callLinkEditable,
|
editable = providerEditable,
|
||||||
onClick = { showCallLinkDialog = true },
|
showLockHint = active != null && providerLocked,
|
||||||
modifier = Modifier.align(Alignment.CenterHorizontally)
|
callLink = callLink,
|
||||||
|
onProvider = onSetProvider,
|
||||||
|
onEditCallLink = { showCallLinkDialog = true },
|
||||||
|
modifier = Modifier.padding(horizontal = Spacing.lg)
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(20.dp))
|
Spacer(Modifier.height(20.dp))
|
||||||
@@ -160,7 +173,7 @@ internal fun ServersSheetContent(
|
|||||||
inactiveContainer = MaterialTheme.colorScheme.surfaceContainerHigh,
|
inactiveContainer = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||||
onClick = { if (!isActive) onApplyServer(p.id) },
|
onClick = { if (!isActive) onApplyServer(p.id) },
|
||||||
trailing = {
|
trailing = {
|
||||||
IconButton(onClick = { onOpenServerSettings(p.id) }) {
|
IconButton(shapes = IconButtonDefaults.shapes(), onClick = { onOpenServerSettings(p.id) }) {
|
||||||
Icon(
|
Icon(
|
||||||
painterResource(R.drawable.settings_outlined_24px),
|
painterResource(R.drawable.settings_outlined_24px),
|
||||||
contentDescription = stringResource(R.string.nav_settings),
|
contentDescription = stringResource(R.string.nav_settings),
|
||||||
@@ -183,72 +196,57 @@ internal fun ServersSheetContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Провайдер активного сервера и ссылка звонка под ним (только relay). */
|
||||||
@Composable
|
@Composable
|
||||||
private fun ProviderChip(
|
private fun ProviderPicker(
|
||||||
current: String,
|
current: String,
|
||||||
editable: Boolean = false,
|
editable: Boolean,
|
||||||
onClick: () -> Unit = {},
|
showLockHint: Boolean,
|
||||||
|
callLink: String,
|
||||||
|
onProvider: (String) -> Unit,
|
||||||
|
onEditCallLink: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val chipPadding = PaddingValues(start = Spacing.sm, end = Spacing.lg, top = Spacing.sm, bottom = Spacing.sm)
|
val reducedMotion = LocalReducedMotion.current
|
||||||
if (editable) {
|
Column(modifier = modifier, verticalArrangement = Arrangement.spacedBy(Spacing.sm)) {
|
||||||
Button(
|
ConnectedChoiceRow(
|
||||||
onClick = onClick,
|
options = Provider.VALUES.map { ChoiceOption(it, providerLabel(it), providerIcon(it)) },
|
||||||
shapes = ButtonDefaults.shapes(),
|
selected = current,
|
||||||
colors = ButtonDefaults.filledTonalButtonColors(),
|
onSelect = onProvider,
|
||||||
contentPadding = chipPadding,
|
enabled = editable
|
||||||
modifier = modifier
|
|
||||||
) {
|
|
||||||
ProviderChipContent(current, showEdit = true)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Surface(
|
|
||||||
shape = CircleShape,
|
|
||||||
color = MaterialTheme.colorScheme.secondaryContainer,
|
|
||||||
modifier = modifier
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.padding(chipPadding),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(Spacing.sm)
|
|
||||||
) {
|
|
||||||
ProviderChipContent(current, showEdit = false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun RowScope.ProviderChipContent(current: String, showEdit: Boolean) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(24.dp)
|
|
||||||
.background(MaterialTheme.colorScheme.primary, MaterialShapes.Sunny.toShape()),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
painterResource(R.drawable.nearby_24px),
|
|
||||||
contentDescription = null,
|
|
||||||
tint = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
modifier = Modifier.size(14.dp)
|
|
||||||
)
|
)
|
||||||
}
|
if (showLockHint) {
|
||||||
Text(
|
Text(
|
||||||
providerLabel(current),
|
stringResource(R.string.provider_locked),
|
||||||
style = MaterialTheme.typography.labelLarge,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSecondaryContainer,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
modifier = Modifier.padding(start = Spacing.sm)
|
textAlign = TextAlign.Center,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
if (showEdit) {
|
}
|
||||||
Icon(
|
AnimatedVisibility(
|
||||||
painterResource(R.drawable.edit_24px),
|
visible = current == Provider.RELAY,
|
||||||
contentDescription = stringResource(R.string.call_link_edit),
|
enter = if (reducedMotion) EnterTransition.None
|
||||||
tint = MaterialTheme.colorScheme.onSecondaryContainer,
|
else expandVertically(MaterialTheme.motionScheme.defaultSpatialSpec()) +
|
||||||
modifier = Modifier
|
fadeIn(MaterialTheme.motionScheme.defaultEffectsSpec()),
|
||||||
.padding(start = Spacing.sm)
|
exit = if (reducedMotion) ExitTransition.None
|
||||||
.size(18.dp)
|
else shrinkVertically(MaterialTheme.motionScheme.fastSpatialSpec()) +
|
||||||
|
fadeOut(MaterialTheme.motionScheme.fastEffectsSpec())
|
||||||
|
) {
|
||||||
|
Surface(
|
||||||
|
shape = settingsItemShape(0, 1),
|
||||||
|
color = MaterialTheme.colorScheme.surfaceContainerHigh
|
||||||
|
) {
|
||||||
|
SettingsEntryRow(
|
||||||
|
iconRes = R.drawable.link_24px,
|
||||||
|
title = stringResource(R.string.call_link_label),
|
||||||
|
trailingRes = if (editable) R.drawable.edit_24px else null,
|
||||||
|
enabled = editable,
|
||||||
|
onClick = onEditCallLink
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -287,7 +285,7 @@ private fun CallLinkDialog(
|
|||||||
singleLine = true,
|
singleLine = true,
|
||||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
|
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
IconButton(onClick = {
|
IconButton(shapes = IconButtonDefaults.shapes(), onClick = {
|
||||||
context.pasteFromClipboard()?.takeIf { it.isNotBlank() }?.let {
|
context.pasteFromClipboard()?.takeIf { it.isNotBlank() }?.let {
|
||||||
link = it.trim()
|
link = it.trim()
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
@@ -304,6 +302,7 @@ private fun CallLinkDialog(
|
|||||||
},
|
},
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
|
shapes = ButtonDefaults.shapes(),
|
||||||
onClick = {
|
onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.SUCCESS)
|
HapticUtil.perform(context, HapticUtil.Pattern.SUCCESS)
|
||||||
onSave(link.trim())
|
onSave(link.trim())
|
||||||
@@ -312,14 +311,8 @@ private fun CallLinkDialog(
|
|||||||
) { Text(stringResource(R.string.save)) }
|
) { Text(stringResource(R.string.save)) }
|
||||||
},
|
},
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) }
|
TextButton(shapes = ButtonDefaults.shapes(), onClick = onDismiss) { Text(stringResource(R.string.cancel)) }
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun providerLabel(value: String): String = when (value) {
|
|
||||||
Provider.VK -> stringResource(R.string.provider_vk)
|
|
||||||
else -> value
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M422,728L629,480L469,480L498,253L313,520L452,520L422,728ZM320,880L360,600L160,600L520,80L600,80L560,400L800,400L400,880L320,880ZM471,490L471,490L471,490L471,490L471,490L471,490Z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M760,840Q721,840 690,817.5Q659,795 647,760L440,760Q374,760 327,713Q280,666 280,600Q280,534 327,487Q374,440 440,440L520,440Q553,440 576.5,416.5Q600,393 600,360Q600,327 576.5,303.5Q553,280 520,280L313,280Q300,315 269.5,337.5Q239,360 200,360Q150,360 115,325Q80,290 80,240Q80,190 115,155Q150,120 200,120Q239,120 269.5,142.5Q300,165 313,200L520,200Q586,200 633,247Q680,294 680,360Q680,426 633,473Q586,520 520,520L440,520Q407,520 383.5,543.5Q360,567 360,600Q360,633 383.5,656.5Q407,680 440,680L647,680Q660,645 690.5,622.5Q721,600 760,600Q810,600 845,635Q880,670 880,720Q880,770 845,805Q810,840 760,840ZM228.5,268.5Q240,257 240,240Q240,223 228.5,211.5Q217,200 200,200Q183,200 171.5,211.5Q160,223 160,240Q160,257 171.5,268.5Q183,280 200,280Q217,280 228.5,268.5Z"/>
|
||||||
|
</vector>
|
||||||
@@ -4,6 +4,6 @@
|
|||||||
<!-- DataStore хранит профили с SSH-секретами в открытом виде - не бэкапим.
|
<!-- DataStore хранит профили с SSH-секретами в открытом виде - не бэкапим.
|
||||||
Перенос - через зашифрованный паролем экспорт/импорт. -->
|
Перенос - через зашифрованный паролем экспорт/импорт. -->
|
||||||
<exclude domain="file" path="datastore/"/>
|
<exclude domain="file" path="datastore/"/>
|
||||||
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка VK, obf-ключ. -->
|
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка звонка, obf-ключ. -->
|
||||||
<exclude domain="file" path="logs/"/>
|
<exclude domain="file" path="logs/"/>
|
||||||
</full-backup-content>
|
</full-backup-content>
|
||||||
@@ -4,12 +4,12 @@
|
|||||||
<!-- DataStore хранит профили с SSH-секретами в открытом виде - в облако не отдаём.
|
<!-- DataStore хранит профили с SSH-секретами в открытом виде - в облако не отдаём.
|
||||||
Перенос на новое устройство - через зашифрованный паролем экспорт/импорт. -->
|
Перенос на новое устройство - через зашифрованный паролем экспорт/импорт. -->
|
||||||
<exclude domain="file" path="datastore/"/>
|
<exclude domain="file" path="datastore/"/>
|
||||||
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка VK, obf-ключ. -->
|
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка звонка, obf-ключ. -->
|
||||||
<exclude domain="file" path="logs/"/>
|
<exclude domain="file" path="logs/"/>
|
||||||
</cloud-backup>
|
</cloud-backup>
|
||||||
<device-transfer>
|
<device-transfer>
|
||||||
<exclude domain="file" path="datastore/"/>
|
<exclude domain="file" path="datastore/"/>
|
||||||
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка VK, obf-ключ. -->
|
<!-- Лог сессии: при выключенной приватности в нём peer, ссылка звонка, obf-ключ. -->
|
||||||
<exclude domain="file" path="logs/"/>
|
<exclude domain="file" path="logs/"/>
|
||||||
</device-transfer>
|
</device-transfer>
|
||||||
</data-extraction-rules>
|
</data-extraction-rules>
|
||||||
@@ -8,13 +8,13 @@ import org.junit.Test
|
|||||||
class CoreCommandTest {
|
class CoreCommandTest {
|
||||||
|
|
||||||
// Строка в формате Mobile.configToArgs.
|
// Строка в формате Mobile.configToArgs.
|
||||||
private val argv = "-peer 1.2.3.4:56000 -links https://vk.com/call/join/secret " +
|
private val argv = "-peer 1.2.3.4:56000 -links https://call.example/call/join/secret " +
|
||||||
"-obf-profile rtpopus -obf-key 00ff -turn 5.6.7.8 -client-id abcd -sub https://sub"
|
"-obf-profile rtpopus -obf-key 00ff -turn 5.6.7.8 -client-id abcd -sub https://sub"
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun masksEverySecretFlag() {
|
fun masksEverySecretFlag() {
|
||||||
val out = CoreCommand.redact(argv, privacy = true)
|
val out = CoreCommand.redact(argv, privacy = true)
|
||||||
listOf("1.2.3.4", "vk.com", "00ff", "5.6.7.8", "abcd", "https://sub").forEach {
|
listOf("1.2.3.4", "call.example", "00ff", "5.6.7.8", "abcd", "https://sub").forEach {
|
||||||
assertFalse("leaked $it", out.contains(it))
|
assertFalse("leaked $it", out.contains(it))
|
||||||
}
|
}
|
||||||
assertTrue(out.contains("-obf-profile rtpopus"))
|
assertTrue(out.contains("-obf-profile rtpopus"))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class CoreConfigJsonTest {
|
|||||||
|
|
||||||
private val base = ClientConfig(
|
private val base = ClientConfig(
|
||||||
serverAddress = "1.2.3.4:56000",
|
serverAddress = "1.2.3.4:56000",
|
||||||
vkLink = "https://vk.com/x",
|
callLink = "https://call.example/x",
|
||||||
clientId = "0123456789abcdef0123456789abcdef",
|
clientId = "0123456789abcdef0123456789abcdef",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ class CoreConfigJsonTest {
|
|||||||
fun mapsFlatFields() {
|
fun mapsFlatFields() {
|
||||||
val o = parse(base)
|
val o = parse(base)
|
||||||
assertEquals("1.2.3.4:56000", o["peer"]!!.jsonPrimitive.content)
|
assertEquals("1.2.3.4:56000", o["peer"]!!.jsonPrimitive.content)
|
||||||
assertEquals(Provider.VK, o["provider"]!!.jsonPrimitive.content)
|
assertEquals(Provider.RELAY, o["provider"]!!.jsonPrimitive.content)
|
||||||
// Маршрутами рулит VpnService, подписок в приложении нет.
|
// Маршрутами рулит VpnService, подписок в приложении нет.
|
||||||
assertEquals(false, o["routes"]!!.jsonPrimitive.content.toBoolean())
|
assertEquals(false, o["routes"]!!.jsonPrimitive.content.toBoolean())
|
||||||
assertEquals("", o["subUrl"]!!.jsonPrimitive.content)
|
assertEquals("", o["subUrl"]!!.jsonPrimitive.content)
|
||||||
|
|||||||
Reference in new issue
Block a user