feat(server): явное задание bind IP для listen
Добавлено поле "IP прослушивания" в ServerManagementScreen рядом с портом. Listen теперь собирается как "$ip:$port" с дефолтом 0.0.0.0:56000. Позволяет обойти баг ядра vk-turn-proxy, которое некорректно обрабатывает -listen 0.0.0.0:port на хостах с несколькими WAN IP — пользователь может указать конкретный адрес.
This commit is contained in:
1 parent
ce7aa335ff
commit
3eff9b8f1e
2 files changed
+21
-4
No files matched your search
@@ -87,12 +87,16 @@ fun ServerManagementScreen(
|
|||||||
val clientCfg by viewModel.clientConfig.collectAsStateWithLifecycle()
|
val clientCfg by viewModel.clientConfig.collectAsStateWithLifecycle()
|
||||||
val serverLogs by viewModel.serverLogs.collectAsStateWithLifecycle()
|
val serverLogs by viewModel.serverLogs.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
|
var proxyListenIp by rememberSaveable(savedListen) {
|
||||||
|
mutableStateOf(savedListen.substringBeforeLast(":", "0.0.0.0").ifBlank { "0.0.0.0" })
|
||||||
|
}
|
||||||
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
||||||
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
||||||
|
|
||||||
LaunchedEffect(proxyListenPort, proxyConnect) {
|
LaunchedEffect(proxyListenIp, proxyListenPort, proxyConnect) {
|
||||||
kotlinx.coroutines.delay(400)
|
kotlinx.coroutines.delay(400)
|
||||||
val listen = "0.0.0.0:$proxyListenPort"
|
val ip = proxyListenIp.ifBlank { "0.0.0.0" }
|
||||||
|
val listen = "$ip:$proxyListenPort"
|
||||||
if (listen != savedListen || proxyConnect != savedConnect) {
|
if (listen != savedListen || proxyConnect != savedConnect) {
|
||||||
viewModel.saveProxyServerConfig(listen, proxyConnect)
|
viewModel.saveProxyServerConfig(listen, proxyConnect)
|
||||||
}
|
}
|
||||||
@@ -220,6 +224,16 @@ fun ServerManagementScreen(
|
|||||||
// Server config
|
// Server config
|
||||||
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
|
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = proxyListenIp,
|
||||||
|
onValueChange = { v -> proxyListenIp = v.filter { c -> c.isDigit() || c == '.' || c == ':' } },
|
||||||
|
label = { Text(stringResource(R.string.listen_ip)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.listen_ip_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
supportingText = { Text(stringResource(R.string.listen_ip_desc)) }
|
||||||
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = proxyListenPort,
|
value = proxyListenPort,
|
||||||
onValueChange = { proxyListenPort = it.filter { c -> c.isDigit() } },
|
onValueChange = { proxyListenPort = it.filter { c -> c.isDigit() } },
|
||||||
@@ -257,7 +271,7 @@ fun ServerManagementScreen(
|
|||||||
FilledTonalButton(
|
FilledTonalButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
viewModel.saveProxyServerConfig("${proxyListenIp.ifBlank { "0.0.0.0" }}:$proxyListenPort", proxyConnect)
|
||||||
viewModel.installServer()
|
viewModel.installServer()
|
||||||
},
|
},
|
||||||
enabled = isConnected && !isWorking,
|
enabled = isConnected && !isWorking,
|
||||||
@@ -272,7 +286,7 @@ fun ServerManagementScreen(
|
|||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.saveProxyServerConfig("0.0.0.0:$proxyListenPort", proxyConnect)
|
viewModel.saveProxyServerConfig("${proxyListenIp.ifBlank { "0.0.0.0" }}:$proxyListenPort", proxyConnect)
|
||||||
viewModel.startServer()
|
viewModel.startServer()
|
||||||
},
|
},
|
||||||
enabled = (isConnected && !isWorking
|
enabled = (isConnected && !isWorking
|
||||||
|
|||||||
@@ -108,6 +108,9 @@
|
|||||||
<string name="listen_port">Порт прослушивания</string>
|
<string name="listen_port">Порт прослушивания</string>
|
||||||
<string name="listen_port_placeholder">56000</string>
|
<string name="listen_port_placeholder">56000</string>
|
||||||
<string name="listen_port_desc">Порт, на котором сервер принимает подключения от клиентов</string>
|
<string name="listen_port_desc">Порт, на котором сервер принимает подключения от клиентов</string>
|
||||||
|
<string name="listen_ip">IP прослушивания</string>
|
||||||
|
<string name="listen_ip_placeholder">0.0.0.0</string>
|
||||||
|
<string name="listen_ip_desc">IP-адрес, к которому биндится сервер. 0.0.0.0 — все интерфейсы. Укажите конкретный WAN IP, если на хосте несколько адресов.</string>
|
||||||
<string name="turn_client_address">Адрес TURN‑клиента</string>
|
<string name="turn_client_address">Адрес TURN‑клиента</string>
|
||||||
<string name="turn_client_placeholder">127.0.0.1:40537</string>
|
<string name="turn_client_placeholder">127.0.0.1:40537</string>
|
||||||
<string name="turn_client_desc">Локальный WireGuard/Hysteria-клиент на стороне сервера</string>
|
<string name="turn_client_desc">Локальный WireGuard/Hysteria-клиент на стороне сервера</string>
|
||||||
|
|||||||
Reference in new issue
Block a user