feat: порт прослушивания — только цифры

This commit is contained in:
samosvalishe committed 2026-04-05 23:16:25 +03:00
1 parent 64d032e9c1
commit 1d27a01448
2 files changed
+10 -7

No files matched your search

@@ -55,6 +55,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.freeturn.app.ui.HapticUtil
@@ -77,7 +79,7 @@ fun ServerManagementScreen(
val savedConnect by viewModel.proxyConnect.collectAsStateWithLifecycle()
val sshLog by viewModel.sshLog.collectAsStateWithLifecycle()
var proxyListen by rememberSaveable(savedListen) { mutableStateOf(savedListen) }
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
val context = LocalContext.current
@@ -155,12 +157,13 @@ fun ServerManagementScreen(
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
OutlinedTextField(
value = proxyListen,
onValueChange = { proxyListen = it },
value = proxyListenPort,
onValueChange = { proxyListenPort = it.filter { c -> c.isDigit() } },
label = { Text(stringResource(R.string.listen_port)) },
placeholder = { Text(stringResource(R.string.listen_port_placeholder)) },
modifier = Modifier.fillMaxWidth(),
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
supportingText = { Text(stringResource(R.string.listen_port_desc)) }
)
@@ -178,7 +181,7 @@ fun ServerManagementScreen(
FilledTonalButton(
onClick = {
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
viewModel.saveProxyServerConfig(proxyListen, proxyConnect)
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
viewModel.installServer()
},
enabled = isConnected && !isWorking,
@@ -195,7 +198,7 @@ fun ServerManagementScreen(
Button(
onClick = {
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
viewModel.saveProxyServerConfig(proxyListen, proxyConnect)
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
viewModel.startServer()
},
enabled = (isConnected && !isWorking
+2 -2
View File
@@ -46,7 +46,7 @@
<string name="server_address_label">Адрес vk-turn-proxy сервера</string>
<string name="server_address_placeholder">1.2.3.4:56000</string>
<string name="server_address_support">IP и порт vk-turn-proxy на вашем VPS</string>
<string name="vk_link_label">Ссылка VK-звонок / Yandex Telemost</string>
<string name="vk_link_label">Ссылка VK-звонок</string>
<string name="vk_link_placeholder">https://vk.com/call/…</string>
<string name="vk_link_support">VK: Звонки → Создать → Скопировать ссылку (не нажимайте «Завершить»)</string>
<string name="local_listen_address">Локальный адрес прослушивания</string>
@@ -80,7 +80,7 @@
<string name="error_format">Ошибка: %1$s</string>
<string name="server_config">Конфигурация сервера</string>
<string name="listen_port">Порт прослушивания</string>
<string name="listen_port_placeholder">0.0.0.0:56000</string>
<string name="listen_port_placeholder">56000</string>
<string name="listen_port_desc">Порт, на котором сервер принимает подключения от клиентов</string>
<string name="turn_client_address">Адрес TURN‑клиента</string>
<string name="turn_client_placeholder">127.0.0.1:40537</string>