feat(proxy)!: убрать TCP-режим проброса и bond
Бэкенд на сервере теперь только UDP (WireGuard/AmneziaWG): выпилены -mode/-bond из конфига ядра, control.sh, share-ссылки и UI. hasRunArgs определяется по obf_profile - сервер отдаёт его всегда, когда параметры запуска нашлись.
This commit is contained in:
1 parent
429affa0a1
commit
215156ea44
32 files changed
+65
-235
No files matched your search
@@ -9,8 +9,6 @@ data class ClientConfig(
|
|||||||
val useUdp: Boolean = false,
|
val useUdp: Boolean = false,
|
||||||
val manualCaptcha: Boolean = false,
|
val manualCaptcha: Boolean = false,
|
||||||
val localPort: String = DEFAULT_LOCAL_PORT,
|
val localPort: String = DEFAULT_LOCAL_PORT,
|
||||||
val tcpForward: Boolean = false,
|
|
||||||
val bond: Boolean = false,
|
|
||||||
val debugMode: Boolean = false,
|
val debugMode: Boolean = false,
|
||||||
val useCarrierDns: Boolean = true,
|
val useCarrierDns: Boolean = true,
|
||||||
val dnsMode: String = DnsMode.AUTO,
|
val dnsMode: String = DnsMode.AUTO,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ data class CoreConfigJson(
|
|||||||
data class Turn(val n: Int, val transport: String, val host: String, val port: String)
|
data class Turn(val n: Int, val transport: String, val host: String, val port: String)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Proxy(val mode: String, val bond: Boolean, val listen: String)
|
data class Proxy(val listen: String)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Vk(
|
data class Vk(
|
||||||
@@ -57,8 +57,6 @@ data class CoreConfigJson(
|
|||||||
|
|
||||||
const val TRANSPORT_TCP = "tcp"
|
const val TRANSPORT_TCP = "tcp"
|
||||||
const val TRANSPORT_UDP = "udp"
|
const val TRANSPORT_UDP = "udp"
|
||||||
const val PROXY_MODE_TCP = "tcp"
|
|
||||||
const val PROXY_MODE_UDP = "udp"
|
|
||||||
const val TUNNEL_MODE_NONE = "none"
|
const val TUNNEL_MODE_NONE = "none"
|
||||||
const val TUNNEL_MODE_WG = "wg"
|
const val TUNNEL_MODE_WG = "wg"
|
||||||
const val PLATFORM_MOBILE = "mobile"
|
const val PLATFORM_MOBILE = "mobile"
|
||||||
@@ -104,11 +102,6 @@ fun ClientConfig.toCoreJson(
|
|||||||
port = "",
|
port = "",
|
||||||
),
|
),
|
||||||
proxy = CoreConfigJson.Proxy(
|
proxy = CoreConfigJson.Proxy(
|
||||||
// Ядро поднимает туннель только поверх udp; UI тоже гасит выбор tcp.
|
|
||||||
mode = if (tcpForward && !wireGuardActive) CoreConfigJson.PROXY_MODE_TCP
|
|
||||||
else CoreConfigJson.PROXY_MODE_UDP,
|
|
||||||
// bond работает только в tcp-режиме.
|
|
||||||
bond = tcpForward && !wireGuardActive && bond,
|
|
||||||
// В туннельном режиме порт не биндится (ядро берёт in-memory pipe),
|
// В туннельном режиме порт не биндится (ядро берёт in-memory pipe),
|
||||||
// но валидацию проходит и нужен прокси-режиму.
|
// но валидацию проходит и нужен прокси-режиму.
|
||||||
listen = localPort,
|
listen = localPort,
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ data class ProbeData(
|
|||||||
val version: String? = null,
|
val version: String? = null,
|
||||||
@SerialName("bin_sha256") val binSha256: String? = null,
|
@SerialName("bin_sha256") val binSha256: String? = null,
|
||||||
val running: Boolean = false,
|
val running: Boolean = false,
|
||||||
val mode: String? = null,
|
|
||||||
val obf: String? = null,
|
val obf: String? = null,
|
||||||
val runtime: String = "",
|
val runtime: String = "",
|
||||||
val euid: Int = -1,
|
val euid: Int = -1,
|
||||||
@@ -63,7 +62,6 @@ data class WgSetupInfo(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class ShareInfoData(
|
data class ShareInfoData(
|
||||||
@SerialName("wg_backend") val wgBackend: Boolean = false,
|
@SerialName("wg_backend") val wgBackend: Boolean = false,
|
||||||
val mode: String = "",
|
|
||||||
@SerialName("obf_profile") val obfProfile: String = "",
|
@SerialName("obf_profile") val obfProfile: String = "",
|
||||||
@SerialName("obf_key") val obfKey: String = "",
|
@SerialName("obf_key") val obfKey: String = "",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -52,9 +52,6 @@ internal object ServerJson {
|
|||||||
put("useUdp", p.client.useUdp)
|
put("useUdp", p.client.useUdp)
|
||||||
put("manualCaptcha", p.client.manualCaptcha)
|
put("manualCaptcha", p.client.manualCaptcha)
|
||||||
put("localPort", p.client.localPort)
|
put("localPort", p.client.localPort)
|
||||||
put("tcpForward", p.client.tcpForward)
|
|
||||||
put("bond", p.client.bond)
|
|
||||||
|
|
||||||
put("debugMode", p.client.debugMode)
|
put("debugMode", p.client.debugMode)
|
||||||
put("useCarrierDns", p.client.useCarrierDns)
|
put("useCarrierDns", p.client.useCarrierDns)
|
||||||
put("dnsMode", p.client.dnsMode)
|
put("dnsMode", p.client.dnsMode)
|
||||||
@@ -108,9 +105,6 @@ internal object ServerJson {
|
|||||||
useUdp = cliO.optBoolean("useUdp", false),
|
useUdp = cliO.optBoolean("useUdp", false),
|
||||||
manualCaptcha = cliO.optBoolean("manualCaptcha", false),
|
manualCaptcha = cliO.optBoolean("manualCaptcha", false),
|
||||||
localPort = cliO.optString("localPort", ClientConfig.DEFAULT_LOCAL_PORT),
|
localPort = cliO.optString("localPort", ClientConfig.DEFAULT_LOCAL_PORT),
|
||||||
tcpForward = cliO.optBoolean("tcpForward", false),
|
|
||||||
bond = cliO.optBoolean("bond", false),
|
|
||||||
|
|
||||||
debugMode = cliO.optBoolean("debugMode", false),
|
debugMode = cliO.optBoolean("debugMode", false),
|
||||||
useCarrierDns = cliO.optBoolean("useCarrierDns", true),
|
useCarrierDns = cliO.optBoolean("useCarrierDns", true),
|
||||||
dnsMode = cliO.optString("dnsMode", DnsMode.AUTO).let {
|
dnsMode = cliO.optString("dnsMode", DnsMode.AUTO).let {
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ data class FreeturnLink(
|
|||||||
val provider: String,
|
val provider: String,
|
||||||
val peer: String,
|
val peer: String,
|
||||||
val transport: String = "",
|
val transport: String = "",
|
||||||
val mode: String = "",
|
|
||||||
val bond: Boolean = false,
|
|
||||||
val obfProfile: String = "",
|
val obfProfile: String = "",
|
||||||
val obfKey: String = "",
|
val obfKey: String = "",
|
||||||
val n: Int = 0,
|
val n: Int = 0,
|
||||||
@@ -31,8 +29,6 @@ data class FreeturnLink(
|
|||||||
sb.field("provider", jsonString(provider))
|
sb.field("provider", jsonString(provider))
|
||||||
sb.field("peer", jsonString(peer))
|
sb.field("peer", jsonString(peer))
|
||||||
if (transport.isNotEmpty()) sb.field("transport", jsonString(transport))
|
if (transport.isNotEmpty()) sb.field("transport", jsonString(transport))
|
||||||
if (mode.isNotEmpty()) sb.field("mode", jsonString(mode))
|
|
||||||
if (bond) sb.field("bond", "true")
|
|
||||||
if (obfProfile.isNotEmpty() && obfProfile != "none") {
|
if (obfProfile.isNotEmpty() && obfProfile != "none") {
|
||||||
sb.field("obf", jsonString(obfProfile))
|
sb.field("obf", jsonString(obfProfile))
|
||||||
sb.field("key", jsonString(obfKey))
|
sb.field("key", jsonString(obfKey))
|
||||||
@@ -74,8 +70,6 @@ data class FreeturnLink(
|
|||||||
provider = provider,
|
provider = provider,
|
||||||
peer = peer,
|
peer = peer,
|
||||||
transport = o.optString("transport"),
|
transport = o.optString("transport"),
|
||||||
mode = o.optString("mode"),
|
|
||||||
bond = o.optBoolean("bond", false),
|
|
||||||
obfProfile = o.optString("obf"),
|
obfProfile = o.optString("obf"),
|
||||||
obfKey = o.optString("key"),
|
obfKey = o.optString("key"),
|
||||||
n = o.optInt("n", 0),
|
n = o.optInt("n", 0),
|
||||||
|
|||||||
@@ -5,13 +5,12 @@ package com.freeturn.app.data.share
|
|||||||
* Используется вместо локального [com.freeturn.app.data.server.ServerOpts] для точности.
|
* Используется вместо локального [com.freeturn.app.data.server.ServerOpts] для точности.
|
||||||
*/
|
*/
|
||||||
data class ShareInfo(
|
data class ShareInfo(
|
||||||
/** Режим бэкенда: "udp" | "tcp". Пусто = сервер не запускался из приложения. */
|
/** Пусто = сервер не запускался из приложения; при живых args хотя бы "none". */
|
||||||
val mode: String = "",
|
|
||||||
val obfProfile: String = "",
|
val obfProfile: String = "",
|
||||||
val obfKey: String = "",
|
val obfKey: String = "",
|
||||||
/** Есть WG-conf в /etc/wireguard -> шарим VPN-доступ (peer-add). Иначе - прокси. */
|
/** Есть WG-conf в /etc/wireguard -> шарим VPN-доступ (peer-add). Иначе - прокси. */
|
||||||
val wgBackend: Boolean = false
|
val wgBackend: Boolean = false
|
||||||
) {
|
) {
|
||||||
/** run.args найден - серверным значениям можно верить. */
|
/** run.args найден - серверным значениям можно верить. */
|
||||||
val hasRunArgs: Boolean get() = mode.isNotEmpty()
|
val hasRunArgs: Boolean get() = obfProfile.isNotEmpty()
|
||||||
}
|
}
|
||||||
@@ -16,15 +16,12 @@ object ShareLinkBuilder {
|
|||||||
wgConf: String?,
|
wgConf: String?,
|
||||||
clientId: String = ""
|
clientId: String = ""
|
||||||
): String {
|
): String {
|
||||||
val tcpMode = if (info.hasRunArgs) info.mode == "tcp" else server.client.tcpForward
|
|
||||||
val obfProfile = if (info.hasRunArgs) info.obfProfile else server.opts.obfProfile
|
val obfProfile = if (info.hasRunArgs) info.obfProfile else server.opts.obfProfile
|
||||||
val obfKey = if (info.hasRunArgs) info.obfKey else server.opts.obfKey
|
val obfKey = if (info.hasRunArgs) info.obfKey else server.opts.obfKey
|
||||||
return FreeturnLink(
|
return FreeturnLink(
|
||||||
provider = server.client.provider,
|
provider = server.client.provider,
|
||||||
peer = server.client.serverAddress,
|
peer = server.client.serverAddress,
|
||||||
transport = if (server.client.useUdp) "udp" else "",
|
transport = if (server.client.useUdp) "udp" else "",
|
||||||
mode = if (tcpMode) "tcp" else "",
|
|
||||||
bond = tcpMode && server.client.bond,
|
|
||||||
obfProfile = if (ObfProfile.isValidKey(obfKey)) obfProfile else "",
|
obfProfile = if (ObfProfile.isValidKey(obfKey)) obfProfile else "",
|
||||||
obfKey = if (ObfProfile.isValidKey(obfKey)) obfKey else "",
|
obfKey = if (ObfProfile.isValidKey(obfKey)) obfKey else "",
|
||||||
n = server.client.threads,
|
n = server.client.threads,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.freeturn.app.data.share
|
|||||||
|
|
||||||
import com.freeturn.app.data.control.ShareListData
|
import com.freeturn.app.data.control.ShareListData
|
||||||
|
|
||||||
/** Гость из allowlist без WG-пира (`share-list` clients): tcp/Xray-бэкенд. */
|
/** Гость из allowlist без WG-пира (`share-list` clients): свой бэкенд на стороне гостя. */
|
||||||
data class SharedClient(
|
data class SharedClient(
|
||||||
val clientId: String,
|
val clientId: String,
|
||||||
/** Имя = comment в clients.json. */
|
/** Имя = comment в clients.json. */
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ sealed class ServerState {
|
|||||||
data class Known(
|
data class Known(
|
||||||
val installed: Boolean,
|
val installed: Boolean,
|
||||||
val running: Boolean,
|
val running: Boolean,
|
||||||
val tcpMode: Boolean? = null,
|
|
||||||
val obfProfile: String? = null,
|
val obfProfile: String? = null,
|
||||||
val version: String? = null
|
val version: String? = null
|
||||||
) : ServerState()
|
) : ServerState()
|
||||||
|
|||||||
@@ -39,11 +39,9 @@ class ProxyOrchestrator(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val opts = prefs.serverOptsFlow.first()
|
val opts = prefs.serverOptsFlow.first()
|
||||||
val tcpMode = prefs.clientConfigFlow.first().tcpForward
|
|
||||||
sshRepository.stopServer()
|
sshRepository.stopServer()
|
||||||
sshRepository.startServer(
|
sshRepository.startServer(
|
||||||
listen = l, connect = c,
|
listen = l, connect = c,
|
||||||
tcpMode = tcpMode,
|
|
||||||
obfProfile = if (opts.obfEnabled) opts.obfProfile else "none",
|
obfProfile = if (opts.obfEnabled) opts.obfProfile else "none",
|
||||||
obfKey = if (opts.obfEnabled) opts.obfKey else "",
|
obfKey = if (opts.obfEnabled) opts.obfKey else "",
|
||||||
clientId = prefs.ownClientId()
|
clientId = prefs.ownClientId()
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ sealed class ServerCommand {
|
|||||||
add("start")
|
add("start")
|
||||||
add("--listen=${opts.listen}")
|
add("--listen=${opts.listen}")
|
||||||
add("--connect=${opts.connect}")
|
add("--connect=${opts.connect}")
|
||||||
if (opts.tcpMode) add("--mode=tcp")
|
|
||||||
if (opts.obfProfile != "none" && opts.obfKey.isNotBlank()) {
|
if (opts.obfProfile != "none" && opts.obfKey.isNotBlank()) {
|
||||||
add("--obf-profile=${opts.obfProfile}")
|
add("--obf-profile=${opts.obfProfile}")
|
||||||
add("--obf-key=${opts.obfKey}")
|
add("--obf-key=${opts.obfKey}")
|
||||||
@@ -86,7 +85,6 @@ sealed class ServerCommand {
|
|||||||
data class ServerStartOptions(
|
data class ServerStartOptions(
|
||||||
val listen: String,
|
val listen: String,
|
||||||
val connect: String,
|
val connect: String,
|
||||||
val tcpMode: Boolean = false,
|
|
||||||
val obfProfile: String = "none",
|
val obfProfile: String = "none",
|
||||||
val obfKey: String = "",
|
val obfKey: String = "",
|
||||||
val clientId: String = ""
|
val clientId: String = ""
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ShareRepository(context: Context, ssh: SSHManager) {
|
|||||||
suspend fun shareInfo(cfg: SshConfig): Result<ShareInfo> =
|
suspend fun shareInfo(cfg: SshConfig): Result<ShareInfo> =
|
||||||
control.run(cfg, ServerCommand.ShareInfo)
|
control.run(cfg, ServerCommand.ShareInfo)
|
||||||
.requireData<ShareInfoData>()
|
.requireData<ShareInfoData>()
|
||||||
.map { ShareInfo(it.mode, it.obfProfile, it.obfKey, it.wgBackend) }
|
.map { ShareInfo(it.obfProfile, it.obfKey, it.wgBackend) }
|
||||||
|
|
||||||
suspend fun addPeer(
|
suspend fun addPeer(
|
||||||
cfg: SshConfig,
|
cfg: SshConfig,
|
||||||
|
|||||||
@@ -149,7 +149,6 @@ class SshRepository(
|
|||||||
_serverState.value = ServerState.Known(
|
_serverState.value = ServerState.Known(
|
||||||
installed = d.installed,
|
installed = d.installed,
|
||||||
running = d.running,
|
running = d.running,
|
||||||
tcpMode = if (d.running) d.mode == "tcp" else null,
|
|
||||||
obfProfile = if (d.running) d.obf else null,
|
obfProfile = if (d.running) d.obf else null,
|
||||||
version = d.version
|
version = d.version
|
||||||
)
|
)
|
||||||
@@ -185,7 +184,6 @@ class SshRepository(
|
|||||||
suspend fun startServer(
|
suspend fun startServer(
|
||||||
listen: String,
|
listen: String,
|
||||||
connect: String,
|
connect: String,
|
||||||
tcpMode: Boolean = false,
|
|
||||||
obfProfile: String = "none",
|
obfProfile: String = "none",
|
||||||
obfKey: String = "",
|
obfKey: String = "",
|
||||||
clientId: String = ""
|
clientId: String = ""
|
||||||
@@ -200,7 +198,6 @@ class SshRepository(
|
|||||||
ServerStartOptions(
|
ServerStartOptions(
|
||||||
listen = listen,
|
listen = listen,
|
||||||
connect = connect,
|
connect = connect,
|
||||||
tcpMode = tcpMode,
|
|
||||||
obfProfile = obfProfile,
|
obfProfile = obfProfile,
|
||||||
obfKey = obfKey,
|
obfKey = obfKey,
|
||||||
clientId = clientId
|
clientId = clientId
|
||||||
|
|||||||
@@ -14,15 +14,13 @@ 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
|
||||||
import com.freeturn.app.ui.components.SettingsFieldSlot
|
import com.freeturn.app.ui.components.SettingsFieldSlot
|
||||||
import com.freeturn.app.ui.components.SettingsGroup
|
|
||||||
import com.freeturn.app.ui.components.SettingsGroupItem
|
|
||||||
import com.freeturn.app.ui.components.SettingsRowDivider
|
import com.freeturn.app.ui.components.SettingsRowDivider
|
||||||
import com.freeturn.app.ui.components.SettingsSwitchRow
|
import com.freeturn.app.ui.components.SettingsSwitchRow
|
||||||
import com.freeturn.app.ui.util.redact
|
import com.freeturn.app.ui.util.redact
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Дополнительно": транспорт TURN (tcp/udp, ортогонален режиму туннеля), сегментированная
|
* "Дополнительно": транспорт TURN (tcp/udp, ортогонален режиму туннеля), ручная капча,
|
||||||
* группа свитчей (капча + bond - bond только в TCP-режиме), альтернативный TURN-узел.
|
* альтернативный TURN-узел.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
internal fun AdvancedSection(
|
internal fun AdvancedSection(
|
||||||
@@ -30,9 +28,6 @@ internal fun AdvancedSection(
|
|||||||
onUseUdp: (Boolean) -> Unit,
|
onUseUdp: (Boolean) -> Unit,
|
||||||
manualCaptcha: Boolean,
|
manualCaptcha: Boolean,
|
||||||
onManualCaptcha: (Boolean) -> Unit,
|
onManualCaptcha: (Boolean) -> Unit,
|
||||||
showBond: Boolean,
|
|
||||||
bond: Boolean,
|
|
||||||
onBond: (Boolean) -> Unit,
|
|
||||||
magicSwitch: Boolean,
|
magicSwitch: Boolean,
|
||||||
onMagicSwitch: (Boolean) -> Unit,
|
onMagicSwitch: (Boolean) -> Unit,
|
||||||
magicTurn: String,
|
magicTurn: String,
|
||||||
@@ -62,28 +57,13 @@ internal fun AdvancedSection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Капча + Bond - сегментированная группа свитчей.
|
SettingsCard {
|
||||||
// Bond - client-only флаг (сервер детектит сам), только в TCP-режиме.
|
SettingsSwitchRow(
|
||||||
val toggleCount = if (showBond) 2 else 1
|
title = stringResource(R.string.manual_captcha),
|
||||||
SettingsGroup {
|
subtitle = stringResource(R.string.manual_captcha_desc),
|
||||||
SettingsGroupItem(0, toggleCount) {
|
checked = manualCaptcha,
|
||||||
SettingsSwitchRow(
|
onCheckedChange = onManualCaptcha
|
||||||
title = stringResource(R.string.manual_captcha),
|
)
|
||||||
subtitle = stringResource(R.string.manual_captcha_desc),
|
|
||||||
checked = manualCaptcha,
|
|
||||||
onCheckedChange = onManualCaptcha
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (showBond) {
|
|
||||||
SettingsGroupItem(1, toggleCount) {
|
|
||||||
SettingsSwitchRow(
|
|
||||||
title = stringResource(R.string.client_bond),
|
|
||||||
subtitle = stringResource(R.string.client_bond_desc),
|
|
||||||
checked = bond,
|
|
||||||
onCheckedChange = onBond
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Альтернативный TURN-узел - свитч + адрес (раскрывается при включении).
|
// Альтернативный TURN-узел - свитч + адрес (раскрывается при включении).
|
||||||
|
|||||||
@@ -61,15 +61,12 @@ fun ClientSetupScreen(
|
|||||||
val snapshot by settingsViewModel.serversSnapshot.collectAsStateWithLifecycle()
|
val snapshot by settingsViewModel.serversSnapshot.collectAsStateWithLifecycle()
|
||||||
val activeClient by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
val activeClient by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
||||||
val sshConfig by serverViewModel.sshConfig.collectAsStateWithLifecycle()
|
val sshConfig by serverViewModel.sshConfig.collectAsStateWithLifecycle()
|
||||||
val serverState by serverViewModel.serverState.collectAsStateWithLifecycle()
|
|
||||||
val activeProxyListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
val activeProxyListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
||||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
// Источник данных: конкретный сервер по id либо активный.
|
// Источник данных: конкретный сервер по id либо активный.
|
||||||
val server = serverId?.let { id -> snapshot.list.firstOrNull { it.id == id } }
|
val server = serverId?.let { id -> snapshot.list.firstOrNull { it.id == id } }
|
||||||
val saved = server?.client ?: activeClient
|
val saved = server?.client ?: activeClient
|
||||||
// Активный сервер рулит живым рантаймом, неактивный - только хранилищем.
|
|
||||||
val isActive = serverId == null || serverId == snapshot.activeId
|
|
||||||
val effSshIp = server?.ssh?.ip ?: sshConfig.ip
|
val effSshIp = server?.ssh?.ip ?: sshConfig.ip
|
||||||
val effProxyListen = server?.proxyListen ?: activeProxyListen
|
val effProxyListen = server?.proxyListen ?: activeProxyListen
|
||||||
|
|
||||||
@@ -82,12 +79,6 @@ fun ClientSetupScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val serverKnown = serverState as? com.freeturn.app.domain.ServerState.Known
|
|
||||||
// TCP-форвард: реальное состояние из probe (если запущен) или сохранённое.
|
|
||||||
val syncOn = saved.syncServerSwitches
|
|
||||||
val effectiveTcpForward = if (isActive && syncOn && serverKnown?.running == true)
|
|
||||||
serverKnown.tcpMode ?: saved.tcpForward else saved.tcpForward
|
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
// remember (не rememberSaveable), чтобы не восстанавливать stale-поля из bundle.
|
// remember (не rememberSaveable), чтобы не восстанавливать stale-поля из bundle.
|
||||||
@@ -223,10 +214,6 @@ fun ClientSetupScreen(
|
|||||||
},
|
},
|
||||||
manualCaptcha = saved.manualCaptcha,
|
manualCaptcha = saved.manualCaptcha,
|
||||||
onManualCaptcha = { v -> clientEdit { it.copy(manualCaptcha = v) } },
|
onManualCaptcha = { v -> clientEdit { it.copy(manualCaptcha = v) } },
|
||||||
showBond = effectiveTcpForward,
|
|
||||||
bond = saved.bond,
|
|
||||||
// bond триггерит рестарт прокси только у активного; иначе пишем данные.
|
|
||||||
onBond = { v -> if (isActive) settingsViewModel.setBond(v) else clientEdit { it.copy(bond = v) } },
|
|
||||||
magicSwitch = saved.magicSwitch,
|
magicSwitch = saved.magicSwitch,
|
||||||
onMagicSwitch = { v -> clientEdit { it.copy(magicSwitch = v) } },
|
onMagicSwitch = { v -> clientEdit { it.copy(magicSwitch = v) } },
|
||||||
magicTurn = magicTurn,
|
magicTurn = magicTurn,
|
||||||
|
|||||||
+2
-7
@@ -98,7 +98,6 @@ fun ServerManagementScreen(
|
|||||||
}
|
}
|
||||||
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) }
|
||||||
var tcpDraft by rememberSaveable(effClient.tcpForward) { mutableStateOf(effClient.tcpForward) }
|
|
||||||
var obfDraft by rememberSaveable(effServer.obfProfile) { mutableStateOf(effServer.obfProfile) }
|
var obfDraft by rememberSaveable(effServer.obfProfile) { mutableStateOf(effServer.obfProfile) }
|
||||||
var keyDraft by rememberSaveable(effServer.obfKey) { mutableStateOf(effServer.obfKey) }
|
var keyDraft by rememberSaveable(effServer.obfKey) { mutableStateOf(effServer.obfKey) }
|
||||||
|
|
||||||
@@ -114,7 +113,6 @@ fun ServerManagementScreen(
|
|||||||
val listenFull = "${proxyListenIp.ifBlank { "0.0.0.0" }}:$proxyListenPort"
|
val listenFull = "${proxyListenIp.ifBlank { "0.0.0.0" }}:$proxyListenPort"
|
||||||
val proxyDirty = listenFull != savedListen || proxyConnect != savedConnect
|
val proxyDirty = listenFull != savedListen || proxyConnect != savedConnect
|
||||||
val configDirty = proxyDirty ||
|
val configDirty = proxyDirty ||
|
||||||
tcpDraft != effClient.tcpForward ||
|
|
||||||
obfDraft != effServer.obfProfile ||
|
obfDraft != effServer.obfProfile ||
|
||||||
keyDraft != effServer.obfKey
|
keyDraft != effServer.obfKey
|
||||||
val keyOkForApply = obfDraft == ObfProfile.NONE || keyDraft.isBlank() ||
|
val keyOkForApply = obfDraft == ObfProfile.NONE || keyDraft.isBlank() ||
|
||||||
@@ -127,10 +125,10 @@ fun ServerManagementScreen(
|
|||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
// Активный - apply в живой рантайм (один рестарт). Неактивный - пишем только снимок сервера.
|
// Активный - apply в живой рантайм (один рестарт). Неактивный - пишем только снимок сервера.
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
settingsViewModel.applyServerConfig(listenFull, proxyConnect, tcpDraft, obfDraft, keyDraft)
|
settingsViewModel.applyServerConfig(listenFull, proxyConnect, obfDraft, keyDraft)
|
||||||
} else {
|
} else {
|
||||||
// !isActive ⇒ serverId != null (см. isActive выше) - smart cast.
|
// !isActive ⇒ serverId != null (см. isActive выше) - smart cast.
|
||||||
settingsViewModel.updateServerConfig(serverId, listenFull, proxyConnect, tcpDraft, obfDraft, keyDraft)
|
settingsViewModel.updateServerConfig(serverId, listenFull, proxyConnect, obfDraft, keyDraft)
|
||||||
}
|
}
|
||||||
onBack()
|
onBack()
|
||||||
}
|
}
|
||||||
@@ -282,9 +280,6 @@ fun ServerManagementScreen(
|
|||||||
// Гейт общий со входом в экран (ServerDetailScreen) - serverSettingsAvailable.
|
// Гейт общий со входом в экран (ServerDetailScreen) - serverSettingsAvailable.
|
||||||
if (serverSettingsAvailable(isConnected, syncOn)) {
|
if (serverSettingsAvailable(isConnected, syncOn)) {
|
||||||
ServerSyncCard(
|
ServerSyncCard(
|
||||||
tcp = tcpDraft,
|
|
||||||
onTcp = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); tcpDraft = it },
|
|
||||||
tcpBlocked = effClient.wireGuardActive,
|
|
||||||
obfProfile = obfDraft,
|
obfProfile = obfDraft,
|
||||||
onObfProfile = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); obfDraft = it },
|
onObfProfile = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); obfDraft = it },
|
||||||
keyDraft = keyDraft,
|
keyDraft = keyDraft,
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ import androidx.compose.material3.Icon
|
|||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
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.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -35,15 +32,12 @@ import com.freeturn.app.ui.components.SettingsRowDivider
|
|||||||
import com.freeturn.app.ui.util.redact
|
import com.freeturn.app.ui.util.redact
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Синхронные серверные настройки (apply-модель): проброс UDP/TCP, профиль обфускации и
|
* Синхронные серверные настройки (apply-модель): профиль обфускации и obf-ключ
|
||||||
* obf-ключ (черновик). Регенерация/копирование ключа - через колбэки; рестарт случается
|
* (черновик). Регенерация/копирование ключа - через колбэки; рестарт случается
|
||||||
* по общей кнопке "Применить" на экране.
|
* по общей кнопке "Применить" на экране.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
internal fun ServerSyncCard(
|
internal fun ServerSyncCard(
|
||||||
tcp: Boolean,
|
|
||||||
onTcp: (Boolean) -> Unit,
|
|
||||||
tcpBlocked: Boolean,
|
|
||||||
obfProfile: String,
|
obfProfile: String,
|
||||||
onObfProfile: (String) -> Unit,
|
onObfProfile: (String) -> Unit,
|
||||||
keyDraft: String,
|
keyDraft: String,
|
||||||
@@ -55,28 +49,6 @@ internal fun ServerSyncCard(
|
|||||||
) {
|
) {
|
||||||
SectionLabel(stringResource(R.string.server_sync_section))
|
SectionLabel(stringResource(R.string.server_sync_section))
|
||||||
SettingsCard {
|
SettingsCard {
|
||||||
// Проброс: UDP / TCP.
|
|
||||||
SettingsFieldSlot {
|
|
||||||
SettingsControlLabel(stringResource(R.string.tcp_forward_mode))
|
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
SegmentedButton(
|
|
||||||
selected = !tcp,
|
|
||||||
onClick = { onTcp(false) },
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
|
||||||
) { Text(stringResource(R.string.udp)) }
|
|
||||||
SegmentedButton(
|
|
||||||
selected = tcp,
|
|
||||||
onClick = { onTcp(true) },
|
|
||||||
// Ядро поднимает туннель только поверх udp-проброса.
|
|
||||||
enabled = !tcpBlocked,
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
|
||||||
) { Text(stringResource(R.string.tcp)) }
|
|
||||||
}
|
|
||||||
if (tcpBlocked) {
|
|
||||||
SettingsControlLabel(stringResource(R.string.tcp_blocked_by_tunnel))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SettingsRowDivider()
|
|
||||||
// Профиль обфускации.
|
// Профиль обфускации.
|
||||||
SettingsFieldSlot {
|
SettingsFieldSlot {
|
||||||
SettingsControlLabel(stringResource(R.string.obf_profile_title))
|
SettingsControlLabel(stringResource(R.string.obf_profile_title))
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ private fun serverCommandLine(server: Server, privacy: Boolean): String {
|
|||||||
val opts = ServerStartOptions(
|
val opts = ServerStartOptions(
|
||||||
listen = server.proxyListen,
|
listen = server.proxyListen,
|
||||||
connect = server.proxyConnect,
|
connect = server.proxyConnect,
|
||||||
tcpMode = server.client.tcpForward,
|
|
||||||
obfProfile = if (server.opts.obfEnabled) server.opts.obfProfile else ObfProfile.NONE,
|
obfProfile = if (server.opts.obfEnabled) server.opts.obfProfile else ObfProfile.NONE,
|
||||||
obfKey = if (server.opts.obfEnabled) server.opts.obfKey else ""
|
obfKey = if (server.opts.obfEnabled) server.opts.obfKey else ""
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -207,33 +207,6 @@ fun SetupConfigStep(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SettingsFieldSlot {
|
SettingsFieldSlot {
|
||||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
|
||||||
SegmentedButton(
|
|
||||||
selected = !draft.backendTcp,
|
|
||||||
onClick = {
|
|
||||||
if (draft.backendTcp) {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
onDraftChange(draft.copy(backendTcp = false))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
|
||||||
) { Text(stringResource(R.string.udp)) }
|
|
||||||
SegmentedButton(
|
|
||||||
selected = draft.backendTcp,
|
|
||||||
onClick = {
|
|
||||||
if (!draft.backendTcp) {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
|
||||||
onDraftChange(draft.copy(backendTcp = true))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
|
||||||
) { Text(stringResource(R.string.tcp)) }
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.setup_backend_protocol_desc),
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
)
|
|
||||||
BackendPortField(draft, showErrors, onDraftChange)
|
BackendPortField(draft, showErrors, onDraftChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ sealed interface ServerHubState {
|
|||||||
data class Online(
|
data class Online(
|
||||||
val running: Boolean,
|
val running: Boolean,
|
||||||
val installed: Boolean,
|
val installed: Boolean,
|
||||||
val tcpMode: Boolean?,
|
|
||||||
val obfProfile: String?,
|
val obfProfile: String?,
|
||||||
val version: String?,
|
val version: String?,
|
||||||
val sshIp: String
|
val sshIp: String
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ data class SetupConfigDraft(
|
|||||||
val wgCustomConf: Boolean = false,
|
val wgCustomConf: Boolean = false,
|
||||||
val wgConfText: String = "",
|
val wgConfText: String = "",
|
||||||
val backendPort: String = "",
|
val backendPort: String = "",
|
||||||
val backendTcp: Boolean = false,
|
|
||||||
val vkLink: String = ""
|
val vkLink: String = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -100,10 +99,7 @@ data class SetupUiState(
|
|||||||
val config: SetupConfigDraft = SetupConfigDraft(),
|
val config: SetupConfigDraft = SetupConfigDraft(),
|
||||||
val install: SetupInstallState? = null
|
val install: SetupInstallState? = null
|
||||||
) {
|
) {
|
||||||
/**
|
/** Внешний порт совпал с портом бэкенда на том же хосте - оба бинда конфликтуют. */
|
||||||
* Внешний порт совпал с UDP-портом бэкенда на том же хосте - оба бинда
|
|
||||||
* конфликтуют. TCP-бэкенд (Xray/sing-box) с UDP-listen не пересекается.
|
|
||||||
*/
|
|
||||||
val portsClash: Boolean
|
val portsClash: Boolean
|
||||||
get() {
|
get() {
|
||||||
val listen = config.listenPort.toIntOrNull() ?: return false
|
val listen = config.listenPort.toIntOrNull() ?: return false
|
||||||
@@ -111,8 +107,7 @@ data class SetupUiState(
|
|||||||
config.vpnMode && config.wgCustomConf -> config.backendPort.toIntOrNull()
|
config.vpnMode && config.wgCustomConf -> config.backendPort.toIntOrNull()
|
||||||
config.vpnMode && wgDetectedPort == null -> config.wgPort.toIntOrNull()
|
config.vpnMode && wgDetectedPort == null -> config.wgPort.toIntOrNull()
|
||||||
config.vpnMode -> wgDetectedPort
|
config.vpnMode -> wgDetectedPort
|
||||||
!config.backendTcp -> config.backendPort.toIntOrNull()
|
else -> config.backendPort.toIntOrNull()
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
return backend != null && backend == listen
|
return backend != null && backend == listen
|
||||||
}
|
}
|
||||||
@@ -295,7 +290,6 @@ class ServerSetupViewModel(
|
|||||||
ServerStartOptions(
|
ServerStartOptions(
|
||||||
listen = "0.0.0.0:${c.listenPort}",
|
listen = "0.0.0.0:${c.listenPort}",
|
||||||
connect = "127.0.0.1:$backendPort",
|
connect = "127.0.0.1:$backendPort",
|
||||||
tcpMode = !c.vpnMode && c.backendTcp,
|
|
||||||
obfProfile = c.obfProfile,
|
obfProfile = c.obfProfile,
|
||||||
obfKey = if (obfOn) obfKey else "",
|
obfKey = if (obfOn) obfKey else "",
|
||||||
// Авторизация по allowlist с первого запуска: владелец сидится
|
// Авторизация по allowlist с первого запуска: владелец сидится
|
||||||
@@ -344,7 +338,6 @@ class ServerSetupViewModel(
|
|||||||
client = ClientConfig(
|
client = ClientConfig(
|
||||||
serverAddress = "${cfg.ip}:${c.listenPort}",
|
serverAddress = "${cfg.ip}:${c.listenPort}",
|
||||||
vkLink = c.vkLink.trim(),
|
vkLink = c.vkLink.trim(),
|
||||||
tcpForward = !c.vpnMode && c.backendTcp,
|
|
||||||
tunnelTransport = if (c.vpnMode && !wgClientConf.isNullOrBlank())
|
tunnelTransport = if (c.vpnMode && !wgClientConf.isNullOrBlank())
|
||||||
TunnelTransport.WIREGUARD else TunnelTransport.NONE,
|
TunnelTransport.WIREGUARD else TunnelTransport.NONE,
|
||||||
wireGuardConfig = wgClientConf.orEmpty()
|
wireGuardConfig = wgClientConf.orEmpty()
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class ServerViewModel(
|
|||||||
ServerHubState.Online(
|
ServerHubState.Online(
|
||||||
running = server.running,
|
running = server.running,
|
||||||
installed = server.installed,
|
installed = server.installed,
|
||||||
tcpMode = server.tcpMode,
|
|
||||||
obfProfile = server.obfProfile,
|
obfProfile = server.obfProfile,
|
||||||
version = server.version,
|
version = server.version,
|
||||||
sshIp = ssh.ip
|
sshIp = ssh.ip
|
||||||
@@ -114,11 +113,9 @@ class ServerViewModel(
|
|||||||
sshRepository.updateServerState(ServerState.Error("Неверный формат адреса (ожидается host:port)"))
|
sshRepository.updateServerState(ServerState.Error("Неверный формат адреса (ожидается host:port)"))
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val tcpMode = prefs.clientConfigFlow.first().tcpForward
|
|
||||||
val opts = prefs.serverOptsFlow.first()
|
val opts = prefs.serverOptsFlow.first()
|
||||||
sshRepository.startServer(
|
sshRepository.startServer(
|
||||||
listen = l, connect = c,
|
listen = l, connect = c,
|
||||||
tcpMode = tcpMode,
|
|
||||||
obfProfile = if (opts.obfEnabled) opts.obfProfile else "none",
|
obfProfile = if (opts.obfEnabled) opts.obfProfile else "none",
|
||||||
obfKey = if (opts.obfEnabled) opts.obfKey else "",
|
obfKey = if (opts.obfEnabled) opts.obfKey else "",
|
||||||
clientId = prefs.ownClientId()
|
clientId = prefs.ownClientId()
|
||||||
|
|||||||
@@ -259,15 +259,6 @@ class SettingsViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setBond(enabled: Boolean) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
val changed = prefs.updateActiveServer {
|
|
||||||
it.copy(client = it.client.copy(bond = enabled))
|
|
||||||
}
|
|
||||||
if (changed) orchestrator.restartProxyIfRunning()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setActiveVkLink(link: String) {
|
fun setActiveVkLink(link: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
prefs.updateActiveServer {
|
prefs.updateActiveServer {
|
||||||
@@ -301,7 +292,6 @@ class SettingsViewModel(
|
|||||||
fun applyServerConfig(
|
fun applyServerConfig(
|
||||||
listen: String,
|
listen: String,
|
||||||
connect: String,
|
connect: String,
|
||||||
tcpForward: Boolean,
|
|
||||||
obfProfile: String,
|
obfProfile: String,
|
||||||
obfKey: String
|
obfKey: String
|
||||||
) {
|
) {
|
||||||
@@ -317,7 +307,6 @@ class SettingsViewModel(
|
|||||||
s.copy(
|
s.copy(
|
||||||
proxyListen = listen,
|
proxyListen = listen,
|
||||||
proxyConnect = connect,
|
proxyConnect = connect,
|
||||||
client = s.client.copy(tcpForward = tcpForward),
|
|
||||||
opts = s.opts.copy(obfProfile = obfProfile, obfKey = effKey)
|
opts = s.opts.copy(obfProfile = obfProfile, obfKey = effKey)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -337,7 +326,6 @@ class SettingsViewModel(
|
|||||||
id: String,
|
id: String,
|
||||||
listen: String,
|
listen: String,
|
||||||
connect: String,
|
connect: String,
|
||||||
tcpForward: Boolean,
|
|
||||||
obfProfile: String,
|
obfProfile: String,
|
||||||
obfKey: String
|
obfKey: String
|
||||||
) {
|
) {
|
||||||
@@ -351,7 +339,6 @@ class SettingsViewModel(
|
|||||||
target.copy(
|
target.copy(
|
||||||
proxyListen = listen,
|
proxyListen = listen,
|
||||||
proxyConnect = connect,
|
proxyConnect = connect,
|
||||||
client = target.client.copy(tcpForward = tcpForward),
|
|
||||||
opts = target.opts.copy(obfProfile = obfProfile, obfKey = effKey)
|
opts = target.opts.copy(obfProfile = obfProfile, obfKey = effKey)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ class ImportViewModel(
|
|||||||
serverAddress = link.peer,
|
serverAddress = link.peer,
|
||||||
vkLink = st.vkLink.trim(),
|
vkLink = st.vkLink.trim(),
|
||||||
provider = link.provider,
|
provider = link.provider,
|
||||||
tcpForward = link.mode == "tcp",
|
|
||||||
bond = link.bond,
|
|
||||||
useUdp = link.transport == "udp",
|
useUdp = link.transport == "udp",
|
||||||
threads = link.n.takeIf { it > 0 } ?: ClientConfig.DEFAULT_THREADS,
|
threads = link.n.takeIf { it > 0 } ?: ClientConfig.DEFAULT_THREADS,
|
||||||
streamsPerCred = link.streamsPerCred.takeIf { it > 0 }
|
streamsPerCred = link.streamsPerCred.takeIf { it > 0 }
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
<string name="setup_checking_ssh_desc">Проверка окружения сервера</string>
|
<string name="setup_checking_ssh_desc">Проверка окружения сервера</string>
|
||||||
<string name="setup_mode_section">Режим работы</string>
|
<string name="setup_mode_section">Режим работы</string>
|
||||||
<string name="setup_mode_vpn_desc">Поднимем WireGuard на сервере - весь трафик устройства пойдёт через туннель.</string>
|
<string name="setup_mode_vpn_desc">Поднимем WireGuard на сервере - весь трафик устройства пойдёт через туннель.</string>
|
||||||
<string name="setup_mode_proxy_desc">Прокси перенаправляет трафик на ваш бэкенд на сервере: Xray или WireGuard.</string>
|
<string name="setup_mode_proxy_desc">Прокси перенаправляет трафик на ваш UDP-бэкенд на сервере: WireGuard или AmneziaWG.</string>
|
||||||
<string name="setup_wg_found">WireGuard найден</string>
|
<string name="setup_wg_found">WireGuard найден</string>
|
||||||
<string name="setup_wg_found_desc">Порт %1$d станет бэкендом. Для этого устройства добавится отдельный пир - конфиг подставится сам.</string>
|
<string name="setup_wg_found_desc">Порт %1$d станет бэкендом. Для этого устройства добавится отдельный пир - конфиг подставится сам.</string>
|
||||||
<string name="setup_wg_missing">WireGuard не найден</string>
|
<string name="setup_wg_missing">WireGuard не найден</string>
|
||||||
@@ -128,7 +128,6 @@
|
|||||||
<string name="setup_port_roll">Сгенерировать порт</string>
|
<string name="setup_port_roll">Сгенерировать порт</string>
|
||||||
<string name="setup_backend_port_label">Порт бэкенда</string>
|
<string name="setup_backend_port_label">Порт бэкенда</string>
|
||||||
<string name="setup_backend_port_desc">Локальный порт вашего VPN/бэкенда на сервере (127.0.0.1)</string>
|
<string name="setup_backend_port_desc">Локальный порт вашего VPN/бэкенда на сервере (127.0.0.1)</string>
|
||||||
<string name="setup_backend_protocol_desc">UDP - WireGuard/AmneziaWG, TCP - Xray</string>
|
|
||||||
<string name="setup_turn_section">TURN-прокси</string>
|
<string name="setup_turn_section">TURN-прокси</string>
|
||||||
<string name="setup_listen_port_desc">Внешний UDP-порт сервера, случайный из диапазона 56000–56999</string>
|
<string name="setup_listen_port_desc">Внешний UDP-порт сервера, случайный из диапазона 56000–56999</string>
|
||||||
<string name="setup_obf_hint_rtpopus">Трафик маскируется под голосовой звонок. Ключ сгенерируется и подставится автоматически.</string>
|
<string name="setup_obf_hint_rtpopus">Трафик маскируется под голосовой звонок. Ключ сгенерируется и подставится автоматически.</string>
|
||||||
@@ -203,9 +202,6 @@
|
|||||||
<string name="streams_per_cred_recommendation">Сколько TURN-потоков обслуживает один VK-аккаунт</string>
|
<string name="streams_per_cred_recommendation">Сколько TURN-потоков обслуживает один VK-аккаунт</string>
|
||||||
<string name="streams_per_cred_format">Потоков на аккаунт: %1$d</string>
|
<string name="streams_per_cred_format">Потоков на аккаунт: %1$d</string>
|
||||||
|
|
||||||
<string name="tcp_forward_mode">Режим</string>
|
|
||||||
<string name="client_bond">Bond (стрипинг TCP)</string>
|
|
||||||
<string name="client_bond_desc">Распределяет TCP по smux-сессиям. Только в TCP-режиме.</string>
|
|
||||||
<string name="obf_profile_title">Обфускация</string>
|
<string name="obf_profile_title">Обфускация</string>
|
||||||
<string name="obf_none">Выкл</string>
|
<string name="obf_none">Выкл</string>
|
||||||
<string name="obf_rtpopus">rtpopus</string>
|
<string name="obf_rtpopus">rtpopus</string>
|
||||||
@@ -251,7 +247,7 @@
|
|||||||
<string name="listen_ip_desc">IP-адрес, который прослушивает сервер. 0.0.0.0 - все интерфейсы. Укажите конкретный WAN IP, если на хосте несколько адресов.</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/Xray-клиент на стороне сервера</string>
|
<string name="turn_client_desc">Локальный WireGuard-бэкенд на стороне сервера</string>
|
||||||
<string name="server_install">Установить</string>
|
<string name="server_install">Установить</string>
|
||||||
<string name="server_update">Обновить</string>
|
<string name="server_update">Обновить</string>
|
||||||
<string name="server_obf_key_label">Obf-ключ (64 hex)</string>
|
<string name="server_obf_key_label">Obf-ключ (64 hex)</string>
|
||||||
@@ -324,7 +320,6 @@
|
|||||||
<string name="notif_proxy_connect_error">Ошибка подключения</string>
|
<string name="notif_proxy_connect_error">Ошибка подключения</string>
|
||||||
<string name="notif_proxy_wireguard_error">Ошибка WireGuard</string>
|
<string name="notif_proxy_wireguard_error">Ошибка WireGuard</string>
|
||||||
<string name="notif_proxy_vpn_permission">Нужно разрешение VPN - откройте приложение</string>
|
<string name="notif_proxy_vpn_permission">Нужно разрешение VPN - откройте приложение</string>
|
||||||
<string name="tcp_blocked_by_tunnel">Туннель работает только поверх UDP-проброса</string>
|
|
||||||
|
|
||||||
<!-- CaptchaWebViewDialog -->
|
<!-- CaptchaWebViewDialog -->
|
||||||
<string name="captcha_title">Проверка VK</string>
|
<string name="captcha_title">Проверка VK</string>
|
||||||
@@ -526,6 +521,6 @@
|
|||||||
<!-- О проекте -->
|
<!-- О проекте -->
|
||||||
<string name="settings_about">О проекте</string>
|
<string name="settings_about">О проекте</string>
|
||||||
<string name="settings_about_desc">Версия, описание и ссылки</string>
|
<string name="settings_about_desc">Версия, описание и ссылки</string>
|
||||||
<string name="about_description">Free Turn проксирует WireGuard и Xray-трафик через публичные TURN-сервера. Открытый исходный код и никакой телеметрии: все настройки хранятся только на вашем устройстве.</string>
|
<string name="about_description">Free Turn проксирует WireGuard-трафик через публичные TURN-сервера. Открытый исходный код и никакой телеметрии: все настройки хранятся только на вашем устройстве.</string>
|
||||||
<string name="about_links">Ссылки</string>
|
<string name="about_links">Ссылки</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -43,27 +43,22 @@ class CoreConfigJsonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun tunnelForcesUdpProxyMode() {
|
fun tunnelCarriesWgConfig() {
|
||||||
val wg = base.copy(
|
val wg = base.copy(
|
||||||
tcpForward = true,
|
|
||||||
bond = true,
|
|
||||||
tunnelTransport = TunnelTransport.WIREGUARD,
|
tunnelTransport = TunnelTransport.WIREGUARD,
|
||||||
wireGuardConfig = "[Interface]\nAddress = 10.8.0.2/32\n",
|
wireGuardConfig = "[Interface]\nAddress = 10.8.0.2/32\n",
|
||||||
)
|
)
|
||||||
val proxy = parse(wg)["proxy"]!!.jsonObject
|
|
||||||
assertEquals("udp", proxy["mode"]!!.jsonPrimitive.content)
|
|
||||||
assertEquals(false, proxy["bond"]!!.jsonPrimitive.content.toBoolean())
|
|
||||||
|
|
||||||
val tunnel = parse(wg)["tunnel"]!!.jsonObject
|
val tunnel = parse(wg)["tunnel"]!!.jsonObject
|
||||||
assertEquals("wg", tunnel["mode"]!!.jsonPrimitive.content)
|
assertEquals("wg", tunnel["mode"]!!.jsonPrimitive.content)
|
||||||
assertEquals(ClientConfig.WG_MTU, tunnel["mtu"]!!.jsonPrimitive.content.toInt())
|
assertEquals(ClientConfig.WG_MTU, tunnel["mtu"]!!.jsonPrimitive.content.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Лишний ключ в proxy валит старт ядра (DisallowUnknownFields), а не тест схемы.
|
||||||
@Test
|
@Test
|
||||||
fun tcpModeKeepsBondWithoutTunnel() {
|
fun proxyHasOnlyListen() {
|
||||||
val proxy = parse(base.copy(tcpForward = true, bond = true))["proxy"]!!.jsonObject
|
val proxy = parse(base.copy(localPort = "127.0.0.1:9001"))["proxy"]!!.jsonObject
|
||||||
assertEquals("tcp", proxy["mode"]!!.jsonPrimitive.content)
|
assertEquals(setOf("listen"), proxy.keys)
|
||||||
assertEquals(true, proxy["bond"]!!.jsonPrimitive.content.toBoolean())
|
assertEquals("127.0.0.1:9001", proxy["listen"]!!.jsonPrimitive.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class FreeturnLinkTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `golden typical - encode matches Go field order and omitempty`() {
|
fun `golden typical - encode matches Go field order and omitempty`() {
|
||||||
// Эталон: байт-в-байт вывод Go json.Marshal(wire) для типового конфига.
|
// Эталон: байт-в-байт вывод Go json.Marshal(wire) для типового конфига.
|
||||||
val goldenJson = """{"v":1,"provider":"vk","peer":"1.2.3.4:56000","mode":"udp",""" +
|
val goldenJson = """{"v":1,"provider":"vk","peer":"1.2.3.4:56000","transport":"udp",""" +
|
||||||
""""obf":"rtpopus","key":"d823fa01cb3e0609b67322f7cf984c4ee2e4ce2e294936fc24ef38c9e59f4799","name":"Papa"}"""
|
""""obf":"rtpopus","key":"d823fa01cb3e0609b67322f7cf984c4ee2e4ce2e294936fc24ef38c9e59f4799","name":"Papa"}"""
|
||||||
val golden = "freeturn://" + Base64.getUrlEncoder().withoutPadding()
|
val golden = "freeturn://" + Base64.getUrlEncoder().withoutPadding()
|
||||||
.encodeToString(goldenJson.toByteArray(Charsets.UTF_8))
|
.encodeToString(goldenJson.toByteArray(Charsets.UTF_8))
|
||||||
@@ -44,7 +44,7 @@ class FreeturnLinkTest {
|
|||||||
val link = FreeturnLink(
|
val link = FreeturnLink(
|
||||||
provider = "vk",
|
provider = "vk",
|
||||||
peer = "1.2.3.4:56000",
|
peer = "1.2.3.4:56000",
|
||||||
mode = "udp",
|
transport = "udp",
|
||||||
obfProfile = "rtpopus",
|
obfProfile = "rtpopus",
|
||||||
obfKey = "d823fa01cb3e0609b67322f7cf984c4ee2e4ce2e294936fc24ef38c9e59f4799",
|
obfKey = "d823fa01cb3e0609b67322f7cf984c4ee2e4ce2e294936fc24ef38c9e59f4799",
|
||||||
name = "Papa"
|
name = "Papa"
|
||||||
@@ -58,8 +58,6 @@ class FreeturnLinkTest {
|
|||||||
provider = "vk",
|
provider = "vk",
|
||||||
peer = "example.com:56000",
|
peer = "example.com:56000",
|
||||||
transport = "udp",
|
transport = "udp",
|
||||||
mode = "tcp",
|
|
||||||
bond = true,
|
|
||||||
obfProfile = "rtpopus",
|
obfProfile = "rtpopus",
|
||||||
obfKey = "00".repeat(32),
|
obfKey = "00".repeat(32),
|
||||||
n = 10,
|
n = 10,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.freeturn.app.data.config.ClientConfig
|
|||||||
import com.freeturn.app.data.server.Server
|
import com.freeturn.app.data.server.Server
|
||||||
import com.freeturn.app.data.server.ServerOpts
|
import com.freeturn.app.data.server.ServerOpts
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertTrue
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class ShareLinkBuilderTest {
|
class ShareLinkBuilderTest {
|
||||||
@@ -12,16 +11,12 @@ class ShareLinkBuilderTest {
|
|||||||
private val key = "ab".repeat(32)
|
private val key = "ab".repeat(32)
|
||||||
|
|
||||||
private fun server(
|
private fun server(
|
||||||
tcpForward: Boolean = false,
|
|
||||||
bond: Boolean = false,
|
|
||||||
useUdp: Boolean = false,
|
useUdp: Boolean = false,
|
||||||
opts: ServerOpts = ServerOpts()
|
opts: ServerOpts = ServerOpts()
|
||||||
) = Server(
|
) = Server(
|
||||||
name = "Мой сервер",
|
name = "Мой сервер",
|
||||||
client = ClientConfig(
|
client = ClientConfig(
|
||||||
serverAddress = "1.2.3.4:56000",
|
serverAddress = "1.2.3.4:56000",
|
||||||
tcpForward = tcpForward,
|
|
||||||
bond = bond,
|
|
||||||
useUdp = useUdp
|
useUdp = useUdp
|
||||||
),
|
),
|
||||||
opts = opts
|
opts = opts
|
||||||
@@ -29,26 +24,34 @@ class ShareLinkBuilderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `server run args take priority over local opts`() {
|
fun `server run args take priority over local opts`() {
|
||||||
val srv = server(tcpForward = true, opts = ServerOpts("rtpopus", "ff".repeat(32)))
|
val srv = server(opts = ServerOpts("rtpopus", "ff".repeat(32)))
|
||||||
val info = ShareInfo(mode = "udp", obfProfile = "rtpopus", obfKey = key, wgBackend = true)
|
val info = ShareInfo(obfProfile = "rtpopus", obfKey = key, wgBackend = true)
|
||||||
val link = FreeturnLink.parse(ShareLinkBuilder.build(srv, info, "Гость", null)).getOrThrow()
|
val link = FreeturnLink.parse(ShareLinkBuilder.build(srv, info, "Гость", null)).getOrThrow()
|
||||||
assertEquals("", link.mode) // сервер реально в udp, не локальный tcpForward
|
|
||||||
assertEquals(key, link.obfKey) // ключ с сервера, не локальный
|
assertEquals(key, link.obfKey) // ключ с сервера, не локальный
|
||||||
assertEquals("Гость", link.name)
|
assertEquals("Гость", link.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `fallback to local opts when server never started`() {
|
fun `fallback to local opts when server never started`() {
|
||||||
val srv = server(tcpForward = true, bond = true, opts = ServerOpts("rtpopus", key))
|
val srv = server(opts = ServerOpts("rtpopus", key))
|
||||||
val link = FreeturnLink.parse(
|
val link = FreeturnLink.parse(
|
||||||
ShareLinkBuilder.build(srv, ShareInfo(), "u", null)
|
ShareLinkBuilder.build(srv, ShareInfo(), "u", null)
|
||||||
).getOrThrow()
|
).getOrThrow()
|
||||||
assertEquals("tcp", link.mode)
|
|
||||||
assertTrue(link.bond)
|
|
||||||
assertEquals("rtpopus", link.obfProfile)
|
assertEquals("rtpopus", link.obfProfile)
|
||||||
assertEquals(key, link.obfKey)
|
assertEquals(key, link.obfKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Сервер стартовал без обфускации - локальные opts всё равно не подмешиваем.
|
||||||
|
@Test
|
||||||
|
fun `started server without obf wins over local opts`() {
|
||||||
|
val srv = server(opts = ServerOpts("rtpopus", key))
|
||||||
|
val link = FreeturnLink.parse(
|
||||||
|
ShareLinkBuilder.build(srv, ShareInfo(obfProfile = "none"), "u", null)
|
||||||
|
).getOrThrow()
|
||||||
|
assertEquals("", link.obfProfile)
|
||||||
|
assertEquals("", link.obfKey)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `invalid obf key is dropped`() {
|
fun `invalid obf key is dropped`() {
|
||||||
val srv = server(opts = ServerOpts("rtpopus", "короткий"))
|
val srv = server(opts = ServerOpts("rtpopus", "короткий"))
|
||||||
@@ -77,10 +80,8 @@ class ShareLinkBuilderTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `proxy share has no wg field`() {
|
fun `proxy share has no wg field`() {
|
||||||
val raw = ShareLinkBuilder.build(server(), ShareInfo(mode = "tcp"), "u", null)
|
val raw = ShareLinkBuilder.build(server(), ShareInfo(obfProfile = "none"), "u", null)
|
||||||
val link = FreeturnLink.parse(raw).getOrThrow()
|
assertEquals("", FreeturnLink.parse(raw).getOrThrow().wgConf)
|
||||||
assertEquals("", link.wgConf)
|
|
||||||
assertEquals("tcp", link.mode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -116,14 +116,12 @@ UNIT_EOF
|
|||||||
systemctl enable "$UNIT_NAME" >/dev/null 2>&1 || true
|
systemctl enable "$UNIT_NAME" >/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Bond не задаётся - ядро детектит его по magic-префиксу стрима.
|
|
||||||
_write_args_file() {
|
_write_args_file() {
|
||||||
local tmp="$ARGSFILE.tmp"
|
local tmp="$ARGSFILE.tmp"
|
||||||
( umask 077; : > "$tmp" )
|
( umask 077; : > "$tmp" )
|
||||||
{
|
{
|
||||||
echo "-listen"; echo "$ARG_LISTEN"
|
echo "-listen"; echo "$ARG_LISTEN"
|
||||||
echo "-connect"; echo "$ARG_CONNECT"
|
echo "-connect"; echo "$ARG_CONNECT"
|
||||||
if [ "$ARG_MODE" = "tcp" ]; then echo "-mode"; echo "tcp"; fi
|
|
||||||
if [ "$ARG_OBF_PROFILE" != "none" ] && [ -n "$ARG_OBF_KEY" ]; then
|
if [ "$ARG_OBF_PROFILE" != "none" ] && [ -n "$ARG_OBF_KEY" ]; then
|
||||||
echo "-obf-profile"; echo "$ARG_OBF_PROFILE"
|
echo "-obf-profile"; echo "$ARG_OBF_PROFILE"
|
||||||
echo "-obf-key"; echo "$ARG_OBF_KEY"
|
echo "-obf-key"; echo "$ARG_OBF_KEY"
|
||||||
@@ -184,7 +182,6 @@ _rt_start_nohup() {
|
|||||||
_write_env_file
|
_write_env_file
|
||||||
if [ -f "$ENVFILE" ]; then set -a; . "$ENVFILE"; set +a; fi
|
if [ -f "$ENVFILE" ]; then set -a; . "$ENVFILE"; set +a; fi
|
||||||
local args=(-listen "$ARG_LISTEN" -connect "$ARG_CONNECT")
|
local args=(-listen "$ARG_LISTEN" -connect "$ARG_CONNECT")
|
||||||
[ "$ARG_MODE" = "tcp" ] && args+=(-mode tcp)
|
|
||||||
[ -n "$ARG_CLIENT_ID" ] && args+=(-clients-file "$CLIENTSFILE")
|
[ -n "$ARG_CLIENT_ID" ] && args+=(-clients-file "$CLIENTSFILE")
|
||||||
if [ "$ARG_OBF_PROFILE" != "none" ] && [ -n "$ARG_OBF_KEY" ]; then
|
if [ "$ARG_OBF_PROFILE" != "none" ] && [ -n "$ARG_OBF_KEY" ]; then
|
||||||
( umask 077; printf '%s' "$ARG_OBF_KEY" > "$OBFFILE" ); chmod 600 "$OBFFILE"
|
( umask 077; printf '%s' "$ARG_OBF_KEY" > "$OBFFILE" ); chmod 600 "$OBFFILE"
|
||||||
|
|||||||
@@ -102,24 +102,23 @@ _peer_in_conf() { # CONF PUBKEY
|
|||||||
' "$1"
|
' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# obf_profile отдаётся всегда, когда параметры запуска нашлись (пусть и "none"):
|
||||||
|
# по нему клиент отличает "сервер стартовал из приложения" от "данных нет".
|
||||||
share_info_emit() {
|
share_info_emit() {
|
||||||
local backend=false mode="" obf="" key=""
|
local backend=false obf="" key=""
|
||||||
if wg_present && wg_is_ours; then backend=true; fi
|
if wg_present && wg_is_ours; then backend=true; fi
|
||||||
if [ -f "$ARGSFILE" ]; then
|
if [ -f "$ARGSFILE" ]; then
|
||||||
mode=$(awk 'prev=="-mode"{print;exit}{prev=$0}' "$ARGSFILE"); mode=${mode:-udp}
|
obf=$(awk 'prev=="-obf-profile"{print;exit}{prev=$0}' "$ARGSFILE"); obf=${obf:-none}
|
||||||
obf=$(awk 'prev=="-obf-profile"{print;exit}{prev=$0}' "$ARGSFILE")
|
|
||||||
key=$(awk 'prev=="-obf-key"{print;exit}{prev=$0}' "$ARGSFILE")
|
key=$(awk 'prev=="-obf-key"{print;exit}{prev=$0}' "$ARGSFILE")
|
||||||
else
|
else
|
||||||
local cmdline
|
local cmdline
|
||||||
cmdline=$(current_cmdline)
|
cmdline=$(current_cmdline)
|
||||||
if [ -n "$cmdline" ]; then
|
if [ -n "$cmdline" ]; then
|
||||||
if printf '%s' "$cmdline" | grep -q -- '-mode tcp'; then mode=tcp; else mode=udp; fi
|
obf=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-profile[= ]+([a-z0-9]+).*/\1/p'); obf=${obf:-none}
|
||||||
obf=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-profile[= ]+([a-z0-9]+).*/\1/p')
|
|
||||||
key=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-key[= ]+([0-9a-fA-F]{64}).*/\1/p')
|
key=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-key[= ]+([0-9a-fA-F]{64}).*/\1/p')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
d_bool wg_backend "$backend"
|
d_bool wg_backend "$backend"
|
||||||
if [ -n "$mode" ]; then d_str mode "$mode"; fi
|
|
||||||
if [ -n "$obf" ]; then d_str obf_profile "$obf"; fi
|
if [ -n "$obf" ]; then d_str obf_profile "$obf"; fi
|
||||||
if [ -n "$key" ]; then d_str obf_key "$key"; fi
|
if [ -n "$key" ]; then d_str obf_key "$key"; fi
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
ARG_LISTEN=""
|
ARG_LISTEN=""
|
||||||
ARG_CONNECT=""
|
ARG_CONNECT=""
|
||||||
ARG_MODE=""
|
|
||||||
ARG_OBF_PROFILE="none"
|
ARG_OBF_PROFILE="none"
|
||||||
ARG_OBF_KEY=""
|
ARG_OBF_KEY=""
|
||||||
ARG_TAIL=80
|
ARG_TAIL=80
|
||||||
@@ -23,9 +22,6 @@ parse_args() {
|
|||||||
--connect=*)
|
--connect=*)
|
||||||
ARG_CONNECT="${1#*=}"
|
ARG_CONNECT="${1#*=}"
|
||||||
[[ "$ARG_CONNECT" =~ ^[a-zA-Z0-9.:_-]+$ ]] || fail bad_arg "bad --connect" ;;
|
[[ "$ARG_CONNECT" =~ ^[a-zA-Z0-9.:_-]+$ ]] || fail bad_arg "bad --connect" ;;
|
||||||
--mode=*)
|
|
||||||
ARG_MODE="${1#*=}"
|
|
||||||
[[ "$ARG_MODE" =~ ^(udp|tcp)$ ]] || fail bad_arg "bad --mode (need udp|tcp)" ;;
|
|
||||||
--obf-profile=*)
|
--obf-profile=*)
|
||||||
ARG_OBF_PROFILE="${1#*=}"
|
ARG_OBF_PROFILE="${1#*=}"
|
||||||
[[ "$ARG_OBF_PROFILE" =~ ^(none|rtpopus|rtpopus2|rtpopus3)$ ]] || fail bad_arg "bad --obf-profile" ;;
|
[[ "$ARG_OBF_PROFILE" =~ ^(none|rtpopus|rtpopus2|rtpopus3)$ ]] || fail bad_arg "bad --obf-profile" ;;
|
||||||
@@ -71,7 +67,7 @@ parse_args() {
|
|||||||
cmd_probe() {
|
cmd_probe() {
|
||||||
stage probe
|
stage probe
|
||||||
|
|
||||||
local arch bin="" installed=false running=false version="" sha="" mode="" obf=""
|
local arch bin="" installed=false running=false version="" sha="" obf=""
|
||||||
arch=$(detect_arch) || arch=""
|
arch=$(detect_arch) || arch=""
|
||||||
[ -n "$arch" ] && bin="$PREFIX/$arch"
|
[ -n "$arch" ] && bin="$PREFIX/$arch"
|
||||||
if [ -n "$bin" ] && [ -x "$bin" ]; then
|
if [ -n "$bin" ] && [ -x "$bin" ]; then
|
||||||
@@ -86,7 +82,6 @@ cmd_probe() {
|
|||||||
running=true
|
running=true
|
||||||
local cmdline
|
local cmdline
|
||||||
cmdline=$(current_cmdline)
|
cmdline=$(current_cmdline)
|
||||||
if printf '%s' "$cmdline" | grep -q -- '-mode tcp'; then mode=tcp; else mode=udp; fi
|
|
||||||
obf=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-profile[= ]+([a-z0-9]+).*/\1/p')
|
obf=$(printf '%s' "$cmdline" | sed -nE 's/.*-obf-profile[= ]+([a-z0-9]+).*/\1/p')
|
||||||
[ -z "$obf" ] && obf=none
|
[ -z "$obf" ] && obf=none
|
||||||
fi
|
fi
|
||||||
@@ -114,7 +109,6 @@ cmd_probe() {
|
|||||||
[ -n "$sha" ] && d_str bin_sha256 "$sha"
|
[ -n "$sha" ] && d_str bin_sha256 "$sha"
|
||||||
d_bool running "$running"
|
d_bool running "$running"
|
||||||
if [ "$running" = true ]; then
|
if [ "$running" = true ]; then
|
||||||
d_str mode "$mode"
|
|
||||||
d_str obf "$obf"
|
d_str obf "$obf"
|
||||||
fi
|
fi
|
||||||
d_str runtime "$runtime"
|
d_str runtime "$runtime"
|
||||||
@@ -246,9 +240,8 @@ cmd_start() {
|
|||||||
# Порт занят ЧУЖИМ процессом? Честный отказ - НЕ убиваем (в отличие от fuser).
|
# Порт занят ЧУЖИМ процессом? Честный отказ - НЕ убиваем (в отличие от fuser).
|
||||||
# Проверка ДО rt_stop: fail после остановки оставил бы сервер лежать.
|
# Проверка ДО rt_stop: fail после остановки оставил бы сервер лежать.
|
||||||
# Свой процесс на порту - не конфликт (ниже он же перезапускается).
|
# Свой процесс на порту - не конфликт (ниже он же перезапускается).
|
||||||
local port proto owner opid
|
local port proto=udp owner opid
|
||||||
port=${ARG_LISTEN##*:}
|
port=${ARG_LISTEN##*:}
|
||||||
if [ "$ARG_MODE" = tcp ]; then proto=tcp; else proto=udp; fi
|
|
||||||
if [[ "$port" =~ ^[0-9]+$ ]]; then
|
if [[ "$port" =~ ^[0-9]+$ ]]; then
|
||||||
owner=$(port_owner "$proto" "$port")
|
owner=$(port_owner "$proto" "$port")
|
||||||
case "$owner" in
|
case "$owner" in
|
||||||
@@ -401,7 +394,7 @@ cmd_peer_remove() {
|
|||||||
ok
|
ok
|
||||||
}
|
}
|
||||||
|
|
||||||
# tcp/Xray-бэкенд: гость только в allowlist, без WG-пира.
|
# Прокси-бэкенд: гость только в allowlist, без WG-пира.
|
||||||
cmd_client_add() {
|
cmd_client_add() {
|
||||||
stage client_add
|
stage client_add
|
||||||
[ -n "$ARG_CLIENT_ID" ] || fail bad_arg "--client-id required"
|
[ -n "$ARG_CLIENT_ID" ] || fail bad_arg "--client-id required"
|
||||||
|
|||||||
@@ -86,17 +86,24 @@ EOF
|
|||||||
[ "$status" -ne 0 ]
|
[ "$status" -ne 0 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "share_info_emit: из run.args (mode/obf)" {
|
@test "share_info_emit: из run.args (obf)" {
|
||||||
printf -- '-listen\n:8443\n-mode\ntcp\n-obf-profile\nrtpopus\n-obf-key\ndeadbeef\n' > "$FT_PREFIX/run.args"
|
printf -- '-listen\n:8443\n-obf-profile\nrtpopus\n-obf-key\ndeadbeef\n' > "$FT_PREFIX/run.args"
|
||||||
_two_peers
|
_two_peers
|
||||||
_DATA=()
|
_DATA=()
|
||||||
share_info_emit
|
share_info_emit
|
||||||
out=$(IFS=,; printf '%s' "${_DATA[*]}")
|
out=$(IFS=,; printf '%s' "${_DATA[*]}")
|
||||||
[[ "$out" == *'"wg_backend":true'* ]]
|
[[ "$out" == *'"wg_backend":true'* ]]
|
||||||
[[ "$out" == *'"mode":"tcp"'* ]]
|
|
||||||
[[ "$out" == *'"obf_profile":"rtpopus"'* ]]
|
[[ "$out" == *'"obf_profile":"rtpopus"'* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "share_info_emit: run.args без obf -> obf_profile none" {
|
||||||
|
printf -- '-listen\n:8443\n-connect\n127.0.0.1:51820\n' > "$FT_PREFIX/run.args"
|
||||||
|
_DATA=()
|
||||||
|
share_info_emit
|
||||||
|
out=$(IFS=,; printf '%s' "${_DATA[*]}")
|
||||||
|
[[ "$out" == *'"obf_profile":"none"'* ]]
|
||||||
|
}
|
||||||
|
|
||||||
@test "clients_json: нет бинаря -> []" {
|
@test "clients_json: нет бинаря -> []" {
|
||||||
[ "$(clients_json)" = "[]" ]
|
[ "$(clients_json)" = "[]" ]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user