refactor(data): распил AppPreferences, пакеты config/ и server/, имена VALUES
AppPreferences разгружен: SshConfig/ClientConfig/флаги вынесены в отдельные файлы. Модель конфигурации сгруппирована в data/config/, аггрегат сервера (Server/ServersSnapshot/ServerJson/ServerOpts) - в data/server/, ServerJson выделен из Server.kt. Списки валидных значений объектов-флагов унифицированы под имя VALUES.
This commit is contained in:
1 parent
a2d8320e3d
commit
4038c885ac
40 files changed
+263
-234
No files matched your search
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
package com.freeturn.app.data
|
||||
|
||||
import android.content.Context
|
||||
@@ -7,13 +5,19 @@ import androidx.datastore.core.DataStore
|
||||
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
|
||||
import androidx.datastore.preferences.core.*
|
||||
import androidx.datastore.preferences.preferencesDataStore
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.ClientId
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.server.ServerJson
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
import com.freeturn.app.data.server.ServersSnapshot
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.io.IOException
|
||||
import java.security.SecureRandom
|
||||
|
||||
// Битый файл переживаем с дефолтами: чтение/запись на пути старта туннеля
|
||||
// (ownClientId, оркестратор) не должны ронять процесс.
|
||||
@@ -22,138 +26,6 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(
|
||||
corruptionHandler = ReplaceFileCorruptionHandler { emptyPreferences() }
|
||||
)
|
||||
|
||||
data class SshConfig(
|
||||
val ip: String = "",
|
||||
val port: Int = 22,
|
||||
val username: String = "root",
|
||||
val password: String = "",
|
||||
val authType: String = AUTH_PASSWORD,
|
||||
val sshKey: String = "",
|
||||
val hostFingerprint: String = ""
|
||||
) {
|
||||
companion object {
|
||||
// Значения authType - контракт хранения (ServerJson).
|
||||
const val AUTH_PASSWORD = "PASSWORD"
|
||||
const val AUTH_SSH_KEY = "SSH_KEY"
|
||||
}
|
||||
}
|
||||
|
||||
object DnsMode {
|
||||
const val AUTO = "auto"
|
||||
const val PLAIN = "plain"
|
||||
const val DOH = "doh"
|
||||
val ALL = listOf(AUTO, PLAIN, DOH)
|
||||
}
|
||||
|
||||
/** Источник TURN-creds (флаг -provider ядра). Client-only. */
|
||||
object Provider {
|
||||
const val VK = "vk"
|
||||
val ALL = listOf(VK)
|
||||
}
|
||||
|
||||
/** Wire-профиль обфускации payload (флаг -obf-profile ядра). Должен совпадать с сервером. */
|
||||
object ObfProfile {
|
||||
const val NONE = "none"
|
||||
const val RTPOPUS = "rtpopus"
|
||||
val ALL = listOf(NONE, RTPOPUS)
|
||||
|
||||
private val KEY_REGEX = Regex("^[0-9a-fA-F]{64}$")
|
||||
|
||||
/** Ключ -obf-key, который примет ядро (DecodeKey). Единая проверка для argv, UI и regen. */
|
||||
fun isValidKey(key: String): Boolean = key.matches(KEY_REGEX)
|
||||
|
||||
/** Новый случайный obf-ключ (32 байта -> 64-hex). Ядру важен только формат. */
|
||||
fun generateKey(): String =
|
||||
ByteArray(32).also { SecureRandom().nextBytes(it) }.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** Client ID (флаг -client-id ядра): авторизация по allowlist clients.json на сервере. */
|
||||
object ClientId {
|
||||
private val ID_REGEX = Regex("^[0-9a-f]{32}$")
|
||||
|
||||
/** Формат, который генерирует и валидирует приложение (16 байт -> 32-hex, как автоген ядра). */
|
||||
fun isValid(id: String): Boolean = id.matches(ID_REGEX)
|
||||
|
||||
fun generate(): String =
|
||||
ByteArray(16).also { SecureRandom().nextBytes(it) }.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** Транспорт VPN-туннеля (пока только WireGuard) поверх локального прокси. */
|
||||
object TunnelTransport {
|
||||
const val NONE = "none"
|
||||
const val WIREGUARD = "wireguard"
|
||||
const val DEFAULT_TUNNEL_NAME = "freeturn-wg"
|
||||
val PERSISTED = listOf(NONE, WIREGUARD)
|
||||
}
|
||||
|
||||
/** Режим split-tunneling для WireGuard-интерфейса. */
|
||||
object SplitTunnelMode {
|
||||
/** Весь трафик в туннель (только сам прокси исключён). */
|
||||
const val ALL = "all"
|
||||
/** Только перечисленные приложения идут в туннель (IncludedApplications). */
|
||||
const val INCLUDE = "include"
|
||||
/** Перечисленные приложения исключены из туннеля (ExcludedApplications). */
|
||||
const val EXCLUDE = "exclude"
|
||||
val VALUES = listOf(ALL, INCLUDE, EXCLUDE)
|
||||
}
|
||||
|
||||
data class ClientConfig(
|
||||
val serverAddress: String = "",
|
||||
val vkLink: String = "",
|
||||
/** Источник TURN-creds (-provider). Пока только "vk". */
|
||||
val provider: String = Provider.VK,
|
||||
val threads: Int = 12,
|
||||
/** Соответствует флагу `-streams-per-cred` ядра. Дефолт ядра = 10, наш = 6. */
|
||||
val streamsPerCred: Int = DEFAULT_STREAMS_PER_CRED,
|
||||
/** TURN-транспорт UDP (-transport udp). false = TCP/TLS (дефолт ядра и наш). */
|
||||
val useUdp: Boolean = false,
|
||||
val manualCaptcha: Boolean = false,
|
||||
val localPort: String = DEFAULT_LOCAL_PORT,
|
||||
val isRawMode: Boolean = false,
|
||||
val rawCommand: String = "",
|
||||
/** Режим туннеля TCP-форвард (-mode tcp, Xray/sing-box). false = UDP-релей (WireGuard). */
|
||||
val tcpForward: Boolean = false,
|
||||
/** Bonding TCP по smux-сессиям (-bond). Только при tcpForward. Client-only в новом ядре. */
|
||||
val bond: Boolean = false,
|
||||
|
||||
// Если true - добавляется флаг -debug для расширенного вывода в логах.
|
||||
val debugMode: Boolean = false,
|
||||
// Если true - в argv передаётся -dns-servers с DNS активной сети (оператор связи).
|
||||
val useCarrierDns: Boolean = true,
|
||||
// "auto" | "plain" | "doh" - соответствует флагу -dns-mode ядра.
|
||||
val dnsMode: String = DnsMode.AUTO,
|
||||
/** Ручной список DNS (-dns-servers), приоритет над [useCarrierDns]. */
|
||||
val customDns: String = "",
|
||||
/** true - изменения tcpForward/obfEnabled перезапускают удаленный сервер. */
|
||||
val syncServerSwitches: Boolean = true,
|
||||
val magicSwitch: Boolean = false,
|
||||
/** Адрес для флага -turn ядра, если magicSwitch включён. Пусто = не передавать. */
|
||||
val magicTurn: String = "",
|
||||
/** Транспорт туннеля: NONE (proxy) либо WIREGUARD (VPN). По умолчанию - без туннеля. */
|
||||
val tunnelTransport: String = TunnelTransport.NONE,
|
||||
/** Конфиг WireGuard (.conf). Пусто = WG-туннель не поднимается. */
|
||||
val wireGuardConfig: String = "",
|
||||
/** Имя WG-туннеля для GoBackend. */
|
||||
val wireGuardTunnelName: String = TunnelTransport.DEFAULT_TUNNEL_NAME,
|
||||
/** Режим split-tunneling: all | include | exclude. */
|
||||
val splitTunnelMode: String = SplitTunnelMode.ALL,
|
||||
/** Список package-имён для include/exclude (разделители: запятая/пробел/перенос строки). */
|
||||
val splitTunnelApps: String = "",
|
||||
/** Сбор логов ядра в UI. false = ProxyServiceState.addLog глотает строки. */
|
||||
val logsEnabled: Boolean = true,
|
||||
/** -client-id для сервера (cid из share-ссылки). Пусто = общий ID устройства. */
|
||||
val clientId: String = ""
|
||||
) {
|
||||
/** WG реально активен только если выбран WG-транспорт и задан непустой конфиг. */
|
||||
val wireGuardActive: Boolean
|
||||
get() = tunnelTransport == TunnelTransport.WIREGUARD && wireGuardConfig.isNotBlank()
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_LOCAL_PORT = "127.0.0.1:9000"
|
||||
const val DEFAULT_STREAMS_PER_CRED = 6
|
||||
}
|
||||
}
|
||||
|
||||
class AppPreferences(context: Context) {
|
||||
private val context = context.applicationContext
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.freeturn.app.data
|
||||
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.DnsMode
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.config.Provider
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
|
||||
/**
|
||||
* Единый источник истины для argv клиентского ядра.
|
||||
* Возвращает аргументы без имени бинарника. [carrierDns] и [ownClientId] резолвятся движком.
|
||||
*/
|
||||
object CoreArgs {
|
||||
object
|
||||
CoreArgs {
|
||||
|
||||
fun client(
|
||||
cfg: ClientConfig,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.freeturn.app.data.config
|
||||
|
||||
data class ClientConfig(
|
||||
val serverAddress: String = "",
|
||||
val vkLink: String = "",
|
||||
/** Источник TURN-creds (-provider). Пока только "vk". */
|
||||
val provider: String = Provider.VK,
|
||||
val threads: Int = 12,
|
||||
/** Соответствует флагу `-streams-per-cred` ядра. Дефолт ядра = 10, наш = 6. */
|
||||
val streamsPerCred: Int = DEFAULT_STREAMS_PER_CRED,
|
||||
/** TURN-транспорт UDP (-transport udp). false = TCP/TLS (дефолт ядра и наш). */
|
||||
val useUdp: Boolean = false,
|
||||
val manualCaptcha: Boolean = false,
|
||||
val localPort: String = DEFAULT_LOCAL_PORT,
|
||||
val isRawMode: Boolean = false,
|
||||
val rawCommand: String = "",
|
||||
/** Режим туннеля TCP-форвард (-mode tcp, Xray/sing-box). false = UDP-релей (WireGuard). */
|
||||
val tcpForward: Boolean = false,
|
||||
/** Bonding TCP по smux-сессиям (-bond). Только при tcpForward. Client-only в новом ядре. */
|
||||
val bond: Boolean = false,
|
||||
|
||||
// Если true - добавляется флаг -debug для расширенного вывода в логах.
|
||||
val debugMode: Boolean = false,
|
||||
// Если true - в argv передаётся -dns-servers с DNS активной сети (оператор связи).
|
||||
val useCarrierDns: Boolean = true,
|
||||
// "auto" | "plain" | "doh" - соответствует флагу -dns-mode ядра.
|
||||
val dnsMode: String = DnsMode.AUTO,
|
||||
/** Ручной список DNS (-dns-servers), приоритет над [useCarrierDns]. */
|
||||
val customDns: String = "",
|
||||
/** true - изменения tcpForward/obfEnabled перезапускают удаленный сервер. */
|
||||
val syncServerSwitches: Boolean = true,
|
||||
val magicSwitch: Boolean = false,
|
||||
/** Адрес для флага -turn ядра, если magicSwitch включён. Пусто = не передавать. */
|
||||
val magicTurn: String = "",
|
||||
/** Транспорт туннеля: NONE (proxy) либо WIREGUARD (VPN). По умолчанию - без туннеля. */
|
||||
val tunnelTransport: String = TunnelTransport.NONE,
|
||||
/** Конфиг WireGuard (.conf). Пусто = WG-туннель не поднимается. */
|
||||
val wireGuardConfig: String = "",
|
||||
/** Имя WG-туннеля для GoBackend. */
|
||||
val wireGuardTunnelName: String = TunnelTransport.DEFAULT_TUNNEL_NAME,
|
||||
/** Режим split-tunneling: all | include | exclude. */
|
||||
val splitTunnelMode: String = SplitTunnelMode.ALL,
|
||||
/** Список package-имён для include/exclude (разделители: запятая/пробел/перенос строки). */
|
||||
val splitTunnelApps: String = "",
|
||||
/** Сбор логов ядра в UI. false = ProxyServiceState.addLog глотает строки. */
|
||||
val logsEnabled: Boolean = true,
|
||||
/** -client-id для сервера (cid из share-ссылки). Пусто = общий ID устройства. */
|
||||
val clientId: String = ""
|
||||
) {
|
||||
/** WG реально активен только если выбран WG-транспорт и задан непустой конфиг. */
|
||||
val wireGuardActive: Boolean
|
||||
get() = tunnelTransport == TunnelTransport.WIREGUARD && wireGuardConfig.isNotBlank()
|
||||
|
||||
companion object {
|
||||
const val DEFAULT_LOCAL_PORT = "127.0.0.1:9000"
|
||||
const val DEFAULT_STREAMS_PER_CRED = 6
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.freeturn.app.data.config
|
||||
|
||||
import java.security.SecureRandom
|
||||
|
||||
object DnsMode {
|
||||
const val AUTO = "auto"
|
||||
const val PLAIN = "plain"
|
||||
const val DOH = "doh"
|
||||
val VALUES = listOf(AUTO, PLAIN, DOH)
|
||||
}
|
||||
|
||||
/** Источник TURN-creds (флаг -provider ядра). Client-only. */
|
||||
object Provider {
|
||||
const val VK = "vk"
|
||||
val VALUES = listOf(VK)
|
||||
}
|
||||
|
||||
/** Wire-профиль обфускации payload (флаг -obf-profile ядра). Должен совпадать с сервером. */
|
||||
object ObfProfile {
|
||||
const val NONE = "none"
|
||||
const val RTPOPUS = "rtpopus"
|
||||
val VALUES = listOf(NONE, RTPOPUS)
|
||||
|
||||
private val KEY_REGEX = Regex("^[0-9a-fA-F]{64}$")
|
||||
|
||||
/** Ключ -obf-key, который примет ядро (DecodeKey). Единая проверка для argv, UI и regen. */
|
||||
fun isValidKey(key: String): Boolean = key.matches(KEY_REGEX)
|
||||
|
||||
/** Новый случайный obf-ключ (32 байта -> 64-hex). Ядру важен только формат. */
|
||||
fun generateKey(): String =
|
||||
ByteArray(32).also { SecureRandom().nextBytes(it) }.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** Client ID (флаг -client-id ядра): авторизация по allowlist clients.json на сервере. */
|
||||
object ClientId {
|
||||
private val ID_REGEX = Regex("^[0-9a-f]{32}$")
|
||||
|
||||
/** Формат, который генерирует и валидирует приложение (16 байт -> 32-hex, как автоген ядра). */
|
||||
fun isValid(id: String): Boolean = id.matches(ID_REGEX)
|
||||
|
||||
fun generate(): String =
|
||||
ByteArray(16).also { SecureRandom().nextBytes(it) }.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
/** Транспорт VPN-туннеля (пока только WireGuard) поверх локального прокси. */
|
||||
object TunnelTransport {
|
||||
const val NONE = "none"
|
||||
const val WIREGUARD = "wireguard"
|
||||
const val DEFAULT_TUNNEL_NAME = "freeturn-wg"
|
||||
val VALUES = listOf(NONE, WIREGUARD)
|
||||
}
|
||||
|
||||
/** Режим split-tunneling для WireGuard-интерфейса. */
|
||||
object SplitTunnelMode {
|
||||
/** Весь трафик в туннель (только сам прокси исключён). */
|
||||
const val ALL = "all"
|
||||
/** Только перечисленные приложения идут в туннель (IncludedApplications). */
|
||||
const val INCLUDE = "include"
|
||||
/** Перечисленные приложения исключены из туннеля (ExcludedApplications). */
|
||||
const val EXCLUDE = "exclude"
|
||||
val VALUES = listOf(ALL, INCLUDE, EXCLUDE)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.freeturn.app.data.config
|
||||
|
||||
data class SshConfig(
|
||||
val ip: String = "",
|
||||
val port: Int = 22,
|
||||
val username: String = "root",
|
||||
val password: String = "",
|
||||
val authType: String = AUTH_PASSWORD,
|
||||
val sshKey: String = "",
|
||||
val hostFingerprint: String = ""
|
||||
) {
|
||||
companion object {
|
||||
// Значения authType - контракт хранения (ServerJson).
|
||||
const val AUTH_PASSWORD = "PASSWORD"
|
||||
const val AUTH_SSH_KEY = "SSH_KEY"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.freeturn.app.data.server
|
||||
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Именованный сервер: SSH-доступ + клиентские параметры + серверные опции.
|
||||
* Список сериализуется в DataStore (SERVERS_JSON) через [ServerJson].
|
||||
*/
|
||||
data class Server(
|
||||
val id: String = UUID.randomUUID().toString(),
|
||||
val name: String,
|
||||
val ssh: SshConfig = SshConfig(),
|
||||
val client: ClientConfig = ClientConfig(),
|
||||
val proxyListen: String = "0.0.0.0:56000",
|
||||
val proxyConnect: String = "127.0.0.1:40537",
|
||||
val opts: ServerOpts = ServerOpts()
|
||||
) {
|
||||
companion object {
|
||||
/** Имя-заглушка для записей без имени (data-слой, ресурсы недоступны). */
|
||||
const val FALLBACK_NAME = "Без названия"
|
||||
}
|
||||
}
|
||||
|
||||
data class ServersSnapshot(
|
||||
val list: List<Server> = emptyList(),
|
||||
val activeId: String? = null,
|
||||
/** false = initial-значение stateIn до первой эмиссии DataStore. */
|
||||
val loaded: Boolean = false
|
||||
) {
|
||||
val active: Server? get() = list.firstOrNull { it.id == activeId }
|
||||
}
|
||||
+12
-34
@@ -1,38 +1,16 @@
|
||||
package com.freeturn.app.data
|
||||
package com.freeturn.app.data.server
|
||||
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.DnsMode
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.config.Provider
|
||||
import com.freeturn.app.data.config.SplitTunnelMode
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.data.config.TunnelTransport
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.UUID
|
||||
|
||||
|
||||
/**
|
||||
* Именованный сервер: SSH-доступ + клиентские параметры + серверные опции.
|
||||
* Список сериализуется в DataStore (SERVERS_JSON).
|
||||
*/
|
||||
data class Server(
|
||||
val id: String = UUID.randomUUID().toString(),
|
||||
val name: String,
|
||||
val ssh: SshConfig = SshConfig(),
|
||||
val client: ClientConfig = ClientConfig(),
|
||||
val proxyListen: String = "0.0.0.0:56000",
|
||||
val proxyConnect: String = "127.0.0.1:40537",
|
||||
val opts: ServerOpts = ServerOpts()
|
||||
) {
|
||||
companion object {
|
||||
/** Имя-заглушка для записей без имени (data-слой, ресурсы недоступны). */
|
||||
const val FALLBACK_NAME = "Без названия"
|
||||
}
|
||||
}
|
||||
|
||||
data class ServersSnapshot(
|
||||
val list: List<Server> = emptyList(),
|
||||
val activeId: String? = null,
|
||||
/** false = initial-значение stateIn до первой эмиссии DataStore. */
|
||||
val loaded: Boolean = false
|
||||
) {
|
||||
val active: Server? get() = list.firstOrNull { it.id == activeId }
|
||||
}
|
||||
|
||||
// Имена JSON-ключей - контракт с сохранёнными данными: менять только с миграцией.
|
||||
internal object ServerJson {
|
||||
fun encodeList(list: List<Server>): String {
|
||||
@@ -120,7 +98,7 @@ internal object ServerJson {
|
||||
serverAddress = cliO.optString("serverAddress"),
|
||||
vkLink = cliO.optString("vkLink"),
|
||||
provider = cliO.optString("provider", Provider.VK).let {
|
||||
if (it in Provider.ALL) it else Provider.VK
|
||||
if (it in Provider.VALUES) it else Provider.VK
|
||||
},
|
||||
// Фоллбэки = дефолты ClientConfig (для новых полей).
|
||||
threads = cliO.optInt("threads", 12),
|
||||
@@ -136,14 +114,14 @@ internal object ServerJson {
|
||||
debugMode = cliO.optBoolean("debugMode", false),
|
||||
useCarrierDns = cliO.optBoolean("useCarrierDns", true),
|
||||
dnsMode = cliO.optString("dnsMode", DnsMode.AUTO).let {
|
||||
if (it in DnsMode.ALL) it else DnsMode.AUTO
|
||||
if (it in DnsMode.VALUES) it else DnsMode.AUTO
|
||||
},
|
||||
customDns = cliO.optString("customDns"),
|
||||
syncServerSwitches = cliO.optBoolean("syncServerSwitches", true),
|
||||
magicSwitch = cliO.optBoolean("magicSwitch", false),
|
||||
magicTurn = cliO.optString("magicTurn"),
|
||||
tunnelTransport = cliO.optString("tunnelTransport", TunnelTransport.NONE).let {
|
||||
if (it in TunnelTransport.PERSISTED) it else TunnelTransport.NONE
|
||||
if (it in TunnelTransport.VALUES) it else TunnelTransport.NONE
|
||||
},
|
||||
wireGuardConfig = cliO.optString("wireGuardConfig"),
|
||||
wireGuardTunnelName = cliO.optString("wireGuardTunnelName").ifBlank { TunnelTransport.DEFAULT_TUNNEL_NAME },
|
||||
@@ -158,7 +136,7 @@ internal object ServerJson {
|
||||
proxyConnect = o.optString("proxyConnect").ifBlank { "127.0.0.1:40537" },
|
||||
opts = ServerOpts(
|
||||
obfProfile = optsO.optString("obfProfile", ObfProfile.NONE).let {
|
||||
if (it in ObfProfile.ALL) it else ObfProfile.NONE
|
||||
if (it in ObfProfile.VALUES) it else ObfProfile.NONE
|
||||
},
|
||||
obfKey = optsO.optString("obfKey", "")
|
||||
)
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
package com.freeturn.app.data
|
||||
package com.freeturn.app.data.server
|
||||
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
|
||||
/** Снимок серверных obf-опций. obfKey хранится в шифрованном хранилище AppPreferences. */
|
||||
data class ServerOpts(
|
||||
@@ -2,7 +2,7 @@ package com.freeturn.app.data.share
|
||||
|
||||
/**
|
||||
* Фактическое состояние сервера для построения share-ссылки (из `share-info`).
|
||||
* Используется вместо локального [com.freeturn.app.data.ServerOpts] для точности.
|
||||
* Используется вместо локального [com.freeturn.app.data.server.ServerOpts] для точности.
|
||||
*/
|
||||
data class ShareInfo(
|
||||
/** Режим бэкенда: "udp" | "tcp". Пусто = сервер не запускался из приложения. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.freeturn.app.data.share
|
||||
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.Server
|
||||
|
||||
/**
|
||||
* Собирает freeturn://-ссылку для пользователя.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.domain.ConnectionStats
|
||||
import com.freeturn.app.domain.ProxyState
|
||||
import com.freeturn.app.domain.StartupResult
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.freeturn.app.domain.proxy
|
||||
|
||||
import android.content.Context
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.SplitTunnelMode
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.SplitTunnelMode
|
||||
import com.freeturn.app.data.config.TunnelTransport
|
||||
import com.freeturn.app.proxy.ProxyServiceState
|
||||
import com.wireguard.android.backend.GoBackend
|
||||
import com.wireguard.android.backend.Tunnel
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.freeturn.app.domain.server
|
||||
|
||||
import android.content.Context
|
||||
import com.freeturn.app.domain.ssh.SSHManager
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.freeturn.app.domain.server
|
||||
|
||||
import android.content.Context
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.domain.ssh.SSHManager
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.freeturn.app.domain.share
|
||||
|
||||
import android.content.Context
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.data.share.ShareInfo
|
||||
import com.freeturn.app.data.share.SharedClient
|
||||
import com.freeturn.app.data.share.SharedClientParser
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.freeturn.app.domain.ssh
|
||||
|
||||
import android.content.Context
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.domain.ServerState
|
||||
import com.freeturn.app.domain.SshConnectionState
|
||||
import com.freeturn.app.domain.server.CmdResult
|
||||
|
||||
@@ -27,7 +27,7 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,8 +40,8 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.Provider
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.Provider
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.SettingsContentMaxWidth
|
||||
import com.freeturn.app.ui.theme.Spacing
|
||||
|
||||
@@ -15,7 +15,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.DnsList
|
||||
import com.freeturn.app.data.DnsMode
|
||||
import com.freeturn.app.data.config.DnsMode
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsControlLabel
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.TunnelTransport
|
||||
import com.freeturn.app.domain.ProxyState
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
|
||||
@@ -42,7 +42,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.SplitTunnelMode
|
||||
import com.freeturn.app.data.config.SplitTunnelMode
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.screens.splittunnel.SplitTunnelModal
|
||||
import com.freeturn.app.domain.ProxyState
|
||||
|
||||
@@ -42,8 +42,8 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.Provider
|
||||
import com.freeturn.app.data.ServersSnapshot
|
||||
import com.freeturn.app.data.config.Provider
|
||||
import com.freeturn.app.data.server.ServersSnapshot
|
||||
import com.freeturn.app.ui.components.ServerRow
|
||||
import com.freeturn.app.ui.components.settingsItemShape
|
||||
import com.freeturn.app.ui.util.redact
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.domain.ServerState
|
||||
import com.freeturn.app.domain.SshConnectionState
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
|
||||
@@ -17,7 +17,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsControlLabel
|
||||
@@ -66,11 +66,11 @@ internal fun ServerSyncCard(
|
||||
SettingsFieldSlot {
|
||||
SettingsControlLabel(stringResource(R.string.obf_profile_title))
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
ObfProfile.ALL.forEachIndexed { idx, value ->
|
||||
ObfProfile.VALUES.forEachIndexed { idx, value ->
|
||||
SegmentedButton(
|
||||
selected = obfProfile == value,
|
||||
onClick = { onObfProfile(value) },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.ALL.size)
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.VALUES.size)
|
||||
) { Text(obfProfileLabel(value)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.CoreArgs
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.domain.server.ServerCommand
|
||||
import com.freeturn.app.domain.server.ServerOptions
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
|
||||
@@ -27,7 +27,7 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.ui.components.EmptyServersState
|
||||
import com.freeturn.app.ui.components.ServerRow
|
||||
import com.freeturn.app.ui.components.SettingsBackButton
|
||||
|
||||
@@ -33,7 +33,7 @@ import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.IntSize
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
@@ -261,12 +261,12 @@ fun SetupConfigStep(
|
||||
}
|
||||
}
|
||||
|
||||
// --- Обфускация: сегмент по всем профилям (расширяется вместе с ObfProfile.ALL) ---
|
||||
// --- Обфускация: сегмент по всем профилям (расширяется вместе с ObfProfile.VALUES) ---
|
||||
SectionLabel(stringResource(R.string.obf_profile_title))
|
||||
SettingsCard {
|
||||
SettingsFieldSlot {
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
ObfProfile.ALL.forEachIndexed { idx, value ->
|
||||
ObfProfile.VALUES.forEachIndexed { idx, value ->
|
||||
SegmentedButton(
|
||||
selected = draft.obfProfile == value,
|
||||
onClick = {
|
||||
@@ -275,7 +275,7 @@ fun SetupConfigStep(
|
||||
onDraftChange(draft.copy(obfProfile = value))
|
||||
}
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.ALL.size)
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.VALUES.size)
|
||||
) { Text(obfProfileLabel(value)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.InlineErrorCard
|
||||
import com.freeturn.app.ui.theme.LocalReducedMotion
|
||||
|
||||
@@ -32,7 +32,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.share.FreeturnLink
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsFieldSlot
|
||||
|
||||
@@ -24,7 +24,7 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsRowIcon
|
||||
|
||||
@@ -46,7 +46,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.share.ShareInfo
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.QrCode
|
||||
|
||||
@@ -18,7 +18,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.SplitTunnelMode
|
||||
import com.freeturn.app.data.config.SplitTunnelMode
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
|
||||
/** Выбор режима split-tunnel: include / exclude. */
|
||||
|
||||
@@ -37,7 +37,7 @@ import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.SplitTunnelMode
|
||||
import com.freeturn.app.data.config.SplitTunnelMode
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.data.AppChoice
|
||||
import com.freeturn.app.data.installedInternetApps
|
||||
|
||||
@@ -50,7 +50,7 @@ import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.domain.SshConnectionState
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
import com.freeturn.app.ui.components.InlineErrorCard
|
||||
|
||||
@@ -4,12 +4,12 @@ import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.ServerOpts
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.data.config.TunnelTransport
|
||||
import com.freeturn.app.data.share.FreeturnLink
|
||||
import com.freeturn.app.domain.share.LinkImportBus
|
||||
import com.freeturn.app.ui.util.HapticUtil
|
||||
|
||||
@@ -4,12 +4,12 @@ import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.ServerOpts
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.data.config.TunnelTransport
|
||||
import com.freeturn.app.domain.proxy.ProxyOrchestrator
|
||||
import com.freeturn.app.domain.server.ServerSetupRepository
|
||||
import com.freeturn.app.domain.server.ServerOptions
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.ServerOpts
|
||||
import com.freeturn.app.data.SshConfig
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
import com.freeturn.app.data.config.SshConfig
|
||||
import com.freeturn.app.domain.proxy.ProxyOrchestrator
|
||||
import com.freeturn.app.domain.ServerState
|
||||
import com.freeturn.app.domain.SshConnectionState
|
||||
|
||||
@@ -5,10 +5,10 @@ import android.content.Intent
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.ServersSnapshot
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.ObfProfile
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.server.ServersSnapshot
|
||||
import com.freeturn.app.domain.update.AppUpdater
|
||||
import com.freeturn.app.domain.proxy.LocalProxyManager
|
||||
import com.freeturn.app.domain.proxy.ProxyOrchestrator
|
||||
|
||||
@@ -4,9 +4,9 @@ import android.content.Context
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.freeturn.app.data.AppPreferences
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.ClientId
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.config.ClientId
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.share.ShareInfo
|
||||
import com.freeturn.app.data.share.ShareLinkBuilder
|
||||
import com.freeturn.app.data.share.SharedClient
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.freeturn.app.data.share
|
||||
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.Server
|
||||
import com.freeturn.app.data.ServerOpts
|
||||
import com.freeturn.app.data.config.ClientConfig
|
||||
import com.freeturn.app.data.server.Server
|
||||
import com.freeturn.app.data.server.ServerOpts
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
Reference in new issue
Block a user