feat: WireGuard-транспорт, split-tunneling и тоггл логов
Порт фич из netzgiest/turn-proxy-android, адаптированный под текущую кодовую базу (Koin DI, разделённые ViewModels, ProxyOrchestrator, без vless). - WireGuardTunnelManager (GoBackend): поднимает VPN-туннель поверх локального прокси, Endpoint подменяется на localPort, split-tunnel через Included/ExcludedApplications в [Interface]. - ClientConfig: tunnelTransport, wireGuardConfig, wireGuardTunnelName, splitTunnelMode, splitTunnelApps, logsEnabled (+ datastore/JSON). - ProxyService: поднятие WG в ветке hasConnection, остановка в finally и onDestroy. VPN-aware network callback (NET_CAPABILITY_NOT_VPN + physicalNetworkKey), иначе свой WG-интерфейс уводит прокси в рестарт. - UI: секция WireGuard, split-tunnel с пикером приложений, тоггл логов. - build: minSdk 24, Java 17, desugaring, com.wireguard.android:tunnel; манифест — GoBackend$VpnService, QUERY_ALL_PACKAGES, queries.
This commit is contained in:
1 parent
df2e21b648
commit
e28e37816d
12 files changed
+708
-25
No files matched your search
+11
-6
@@ -9,10 +9,11 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "com.freeturn.app"
|
applicationId = "com.freeturn.app"
|
||||||
minSdk = 23
|
// WireGuard GoBackend (com.wireguard.android:tunnel) требует minSdk 24.
|
||||||
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 23
|
versionCode = 24
|
||||||
versionName = "3.0.0-alpha1"
|
versionName = "3.0.0-alpha2"
|
||||||
}
|
}
|
||||||
|
|
||||||
packaging {
|
packaging {
|
||||||
@@ -39,15 +40,17 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
// WireGuard tunnel-либа тянет java.time/desugar-зависимый код — нужно desugaring.
|
||||||
|
isCoreLibraryDesugaringEnabled = true
|
||||||
}
|
}
|
||||||
compileSdkMinor = 1
|
compileSdkMinor = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
compilerOptions {
|
compilerOptions {
|
||||||
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
|
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +60,7 @@ dependencies {
|
|||||||
implementation(libs.bouncycastle)
|
implementation(libs.bouncycastle)
|
||||||
implementation(libs.kotlinx.coroutines.android)
|
implementation(libs.kotlinx.coroutines.android)
|
||||||
implementation(libs.androidx.security.crypto)
|
implementation(libs.androidx.security.crypto)
|
||||||
|
implementation(libs.wireguard.tunnel)
|
||||||
|
|
||||||
implementation(libs.androidx.core.ktx)
|
implementation(libs.androidx.core.ktx)
|
||||||
implementation(libs.androidx.appcompat)
|
implementation(libs.androidx.appcompat)
|
||||||
@@ -75,4 +79,5 @@ dependencies {
|
|||||||
|
|
||||||
debugImplementation(libs.androidx.compose.ui.tooling)
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
implementation(libs.koin.androidx.compose)
|
implementation(libs.koin.androidx.compose)
|
||||||
|
coreLibraryDesugaring(libs.desugar.jdk.libs)
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,17 @@
|
|||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
<!-- Нужно для split-tunnel: показать список установленных приложений в пикере. -->
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||||
|
tools:ignore="QueryAllPackagesPermission" />
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
android:name=".App"
|
||||||
@@ -24,6 +35,7 @@
|
|||||||
android:label="FreeTurn"
|
android:label="FreeTurn"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:extractNativeLibs="true"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:theme="@style/Theme.FreeTurn"
|
android:theme="@style/Theme.FreeTurn"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
@@ -54,6 +66,16 @@
|
|||||||
android:value="Maintains an active local network proxy connection over TURN servers so the user can keep using a working tunnel while the app is in the background." />
|
android:value="Maintains an active local network proxy connection over TURN servers so the user can keep using a working tunnel while the app is in the background." />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<!-- VPN-сервис WireGuard GoBackend: поднимает туннель поверх локального прокси. -->
|
||||||
|
<service
|
||||||
|
android:name="com.wireguard.android.backend.GoBackend$VpnService"
|
||||||
|
android:exported="false"
|
||||||
|
android:permission="android.permission.BIND_VPN_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.net.VpnService" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
android:authorities="${applicationId}.fileprovider"
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.core.app.ServiceCompat
|
|||||||
import com.freeturn.app.data.AppPreferences
|
import com.freeturn.app.data.AppPreferences
|
||||||
import com.freeturn.app.data.DnsMode
|
import com.freeturn.app.data.DnsMode
|
||||||
import com.freeturn.app.data.Provider
|
import com.freeturn.app.data.Provider
|
||||||
|
import com.freeturn.app.domain.WireGuardTunnelManager
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
@@ -38,6 +39,7 @@ import kotlinx.coroutines.SupervisorJob
|
|||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
sealed class StartupResult {
|
sealed class StartupResult {
|
||||||
@@ -74,6 +76,11 @@ class ProxyService : Service() {
|
|||||||
// Новое ядро (tcpfwd.go): "TCP mode: waiting for sessions to connect (total: N)...".
|
// Новое ядро (tcpfwd.go): "TCP mode: waiting for sessions to connect (total: N)...".
|
||||||
private val TCP_TOTAL_REGEX =
|
private val TCP_TOTAL_REGEX =
|
||||||
Pattern.compile("""TCP mode: waiting for sessions to connect \(total: (\d+)\)""")
|
Pattern.compile("""TCP mode: waiting for sessions to connect \(total: (\d+)\)""")
|
||||||
|
// Даём TURN-туннелю «устаканиться» перед поднятием WireGuard поверх него.
|
||||||
|
private const val WIREGUARD_START_DELAY_MS = 2_000L
|
||||||
|
// Игнорируем сетевые события первые секунды после регистрации колбэка —
|
||||||
|
// иначе initial onAvailable/onCapabilitiesChanged триггерят ложный рестарт.
|
||||||
|
private const val NETWORK_CALLBACK_WARMUP_MS = 3_000L
|
||||||
}
|
}
|
||||||
|
|
||||||
private var wakeLock: PowerManager.WakeLock? = null
|
private var wakeLock: PowerManager.WakeLock? = null
|
||||||
@@ -91,11 +98,13 @@ class ProxyService : Service() {
|
|||||||
private var networkCallback: ConnectivityManager.NetworkCallback? = null
|
private var networkCallback: ConnectivityManager.NetworkCallback? = null
|
||||||
@Volatile private var networkInitialized = false
|
@Volatile private var networkInitialized = false
|
||||||
@Volatile private var networkDebounceJob: kotlinx.coroutines.Job? = null
|
@Volatile private var networkDebounceJob: kotlinx.coroutines.Job? = null
|
||||||
|
@Volatile private var lastPhysicalNetworkKey: String? = null
|
||||||
private val restartCount = AtomicInteger(0)
|
private val restartCount = AtomicInteger(0)
|
||||||
@Volatile private var captchaNotificationActive = false
|
@Volatile private var captchaNotificationActive = false
|
||||||
|
|
||||||
private lateinit var prefs: AppPreferences
|
private lateinit var prefs: AppPreferences
|
||||||
private lateinit var serviceScope: CoroutineScope
|
private lateinit var serviceScope: CoroutineScope
|
||||||
|
private lateinit var wireGuard: WireGuardTunnelManager
|
||||||
|
|
||||||
override fun onBind(intent: Intent?): IBinder? = null
|
override fun onBind(intent: Intent?): IBinder? = null
|
||||||
|
|
||||||
@@ -103,6 +112,7 @@ class ProxyService : Service() {
|
|||||||
super.onCreate()
|
super.onCreate()
|
||||||
prefs = AppPreferences(applicationContext)
|
prefs = AppPreferences(applicationContext)
|
||||||
serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
serviceScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
||||||
|
wireGuard = WireGuardTunnelManager(applicationContext)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val nm = getSystemService(NotificationManager::class.java)
|
val nm = getSystemService(NotificationManager::class.java)
|
||||||
nm.createNotificationChannel(
|
nm.createNotificationChannel(
|
||||||
@@ -182,6 +192,7 @@ class ProxyService : Service() {
|
|||||||
if (userStopped.get()) return
|
if (userStopped.get()) return
|
||||||
|
|
||||||
val cfg = prefs.clientConfigFlow.first()
|
val cfg = prefs.clientConfigFlow.first()
|
||||||
|
ProxyServiceState.setLogsEnabled(cfg.logsEnabled)
|
||||||
// Obf-обфускация управляется на серверном экране, но должна передаваться
|
// Obf-обфускация управляется на серверном экране, но должна передаваться
|
||||||
// и клиенту с тем же ключом, иначе DTLS-handshake не сойдётся. Источник
|
// и клиенту с тем же ключом, иначе DTLS-handshake не сойдётся. Источник
|
||||||
// истины — общий serverOpts.
|
// истины — общий serverOpts.
|
||||||
@@ -271,6 +282,7 @@ class ProxyService : Service() {
|
|||||||
val startedAt = System.currentTimeMillis()
|
val startedAt = System.currentTimeMillis()
|
||||||
var startupEmitted = false
|
var startupEmitted = false
|
||||||
var startupFailed = false
|
var startupFailed = false
|
||||||
|
var wireGuardStarted = false
|
||||||
var captchaSessionCounter = 0L
|
var captchaSessionCounter = 0L
|
||||||
|
|
||||||
// --- Трекинг активных соединений для индикации состояния в UI. ---
|
// --- Трекинг активных соединений для индикации состояния в UI. ---
|
||||||
@@ -433,9 +445,37 @@ class ProxyService : Service() {
|
|||||||
startupEmitted = true
|
startupEmitted = true
|
||||||
}
|
}
|
||||||
hasConnection -> {
|
hasConnection -> {
|
||||||
|
try {
|
||||||
|
if (cfg.wireGuardActive) {
|
||||||
|
ProxyServiceState.addLog(
|
||||||
|
"WireGuard: ждём ${WIREGUARD_START_DELAY_MS}мс после поднятия TURN-туннеля"
|
||||||
|
)
|
||||||
|
kotlinx.coroutines.delay(WIREGUARD_START_DELAY_MS)
|
||||||
|
if (userStopped.get() || process.get() !== proc) {
|
||||||
|
ProxyServiceState.addLog(
|
||||||
|
"WireGuard: старт отменён, прокси уже останавливается"
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wireGuard.startAfterProxyReady(cfg)
|
||||||
|
wireGuardStarted = cfg.wireGuardActive
|
||||||
ProxyServiceState.setStartupResult(StartupResult.Success)
|
ProxyServiceState.setStartupResult(StartupResult.Success)
|
||||||
ProxyServiceState.markConnectedIfAbsent(SystemClock.elapsedRealtime())
|
ProxyServiceState.markConnectedIfAbsent(SystemClock.elapsedRealtime())
|
||||||
updateNotification(getString(R.string.proxy_active))
|
updateNotification(
|
||||||
|
if (wireGuardStarted) getString(R.string.proxy_active_wireguard)
|
||||||
|
else getString(R.string.proxy_active)
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
val message = e.message ?: e.javaClass.simpleName
|
||||||
|
ProxyServiceState.addLog("WireGuard: ошибка запуска: $message")
|
||||||
|
ProxyServiceState.setStartupResult(
|
||||||
|
StartupResult.Failed("WireGuard не запустился: $message")
|
||||||
|
)
|
||||||
|
updateNotification("Ошибка WireGuard")
|
||||||
|
startupFailed = true
|
||||||
|
proc.destroyCompat()
|
||||||
|
}
|
||||||
startupEmitted = true
|
startupEmitted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,6 +528,8 @@ class ProxyService : Service() {
|
|||||||
} finally {
|
} finally {
|
||||||
ProxyServiceState.setCaptchaSession(null)
|
ProxyServiceState.setCaptchaSession(null)
|
||||||
cancelCaptchaNotification()
|
cancelCaptchaNotification()
|
||||||
|
// WG-туннель живёт только поверх работающего прокси — гасим вместе с ядром.
|
||||||
|
if (wireGuardStarted) wireGuard.stop()
|
||||||
// Процесс мёртв — активных соединений нет. При watchdog-рестарте
|
// Процесс мёртв — активных соединений нет. При watchdog-рестарте
|
||||||
// publishStats на новом старте снова выставит правильный target.
|
// publishStats на новом старте снова выставит правильный target.
|
||||||
ProxyServiceState.setConnectionStats(ConnectionStats.IDLE)
|
ProxyServiceState.setConnectionStats(ConnectionStats.IDLE)
|
||||||
@@ -544,36 +586,105 @@ class ProxyService : Service() {
|
|||||||
private fun registerNetworkCallback() {
|
private fun registerNetworkCallback() {
|
||||||
networkInitialized = false
|
networkInitialized = false
|
||||||
val cm = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
|
val cm = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
val cb = object : ConnectivityManager.NetworkCallback() {
|
val registeredAt = SystemClock.elapsedRealtime()
|
||||||
override fun onAvailable(network: Network) {
|
lastPhysicalNetworkKey = physicalNetworkKey(cm)
|
||||||
if (!networkInitialized) {
|
|
||||||
networkInitialized = true
|
networkInitialized = true
|
||||||
|
|
||||||
|
// Перезапуск только когда реально меняется ФИЗИЧЕСКАЯ сеть (Wi-Fi↔LTE и т.п.).
|
||||||
|
// WireGuard поднимает свой VPN-интерфейс — без фильтрации NOT_VPN его появление
|
||||||
|
// выглядело бы как смена сети и уводило прокси в бесконечный рестарт.
|
||||||
|
fun schedulePhysicalNetworkCheck(reason: String) {
|
||||||
|
if (SystemClock.elapsedRealtime() - registeredAt < NETWORK_CALLBACK_WARMUP_MS) {
|
||||||
|
ProxyServiceState.addLog("=== СЕТЬ: начальное событие проигнорировано ($reason) ===")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Дебаунс: отменяем предыдущий ждущий перезапуск, если он был
|
|
||||||
networkDebounceJob?.cancel()
|
networkDebounceJob?.cancel()
|
||||||
networkDebounceJob = serviceScope.launch {
|
networkDebounceJob = serviceScope.launch {
|
||||||
kotlinx.coroutines.delay(2000)
|
kotlinx.coroutines.delay(2_000)
|
||||||
|
val oldKey = lastPhysicalNetworkKey
|
||||||
|
val newKey = physicalNetworkKey(cm)
|
||||||
|
if (oldKey == newKey) {
|
||||||
|
ProxyServiceState.addLog("=== СЕТЬ: физическая сеть не изменилась ($reason) ===")
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
|
lastPhysicalNetworkKey = newKey
|
||||||
|
if (newKey == null) {
|
||||||
|
ProxyServiceState.addLog("=== СЕТЬ: физическая сеть недоступна ($reason) ===")
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
if (!userStopped.get() && process.get() != null) {
|
if (!userStopped.get() && process.get() != null) {
|
||||||
ProxyServiceState.addLog("=== СМЕНА СЕТИ — ПЕРЕЗАПУСК ===")
|
ProxyServiceState.addLog("=== СМЕНА СЕТИ — ПЕРЕЗАПУСК ===")
|
||||||
updateNotification("Смена сети, переподключение...")
|
updateNotification("Смена сети, переподключение...")
|
||||||
restartCount.set(0)
|
restartCount.set(0)
|
||||||
val p = process.get()
|
process.get()?.destroyCompat()
|
||||||
p?.destroyCompat()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val cb = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
val caps = cm.getNetworkCapabilities(network)
|
||||||
|
if (caps == null || caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN) ||
|
||||||
|
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
||||||
|
ProxyServiceState.addLog("=== СЕТЬ: VPN-событие проигнорировано ===")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
schedulePhysicalNetworkCheck("available")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
schedulePhysicalNetworkCheck("lost")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCapabilitiesChanged(
|
||||||
|
network: Network,
|
||||||
|
networkCapabilities: NetworkCapabilities
|
||||||
|
) {
|
||||||
|
if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN) ||
|
||||||
|
!networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
schedulePhysicalNetworkCheck("capabilities")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
networkCallback = cb
|
networkCallback = cb
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
||||||
cm.registerDefaultNetworkCallback(cb)
|
|
||||||
} else {
|
|
||||||
val request = NetworkRequest.Builder()
|
val request = NetworkRequest.Builder()
|
||||||
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
|
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
|
||||||
.build()
|
.build()
|
||||||
cm.registerNetworkCallback(request, cb)
|
cm.registerNetworkCallback(request, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Стабильный ключ текущего набора ФИЗИЧЕСКИХ сетей (без VPN): транспорт +
|
||||||
|
* имя интерфейса + отсортированные link-адреса. Меняется при реальном
|
||||||
|
* хендовере сети; не меняется при поднятии/опускании WG-интерфейса.
|
||||||
|
*/
|
||||||
|
private fun physicalNetworkKey(cm: ConnectivityManager): String? {
|
||||||
|
return cm.allNetworks.mapNotNull { network ->
|
||||||
|
val caps = cm.getNetworkCapabilities(network) ?: return@mapNotNull null
|
||||||
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_VPN) ||
|
||||||
|
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) ||
|
||||||
|
!caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)) {
|
||||||
|
return@mapNotNull null
|
||||||
|
}
|
||||||
|
val transports = buildList {
|
||||||
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) add("wifi")
|
||||||
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) add("cellular")
|
||||||
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET)) add("ethernet")
|
||||||
|
if (caps.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH)) add("bluetooth")
|
||||||
|
}
|
||||||
|
if (transports.isEmpty()) return@mapNotNull null
|
||||||
|
val lp = cm.getLinkProperties(network)
|
||||||
|
val iface = lp?.interfaceName.orEmpty()
|
||||||
|
val addresses = lp?.linkAddresses
|
||||||
|
?.map { it.address.hostAddress.orEmpty() }
|
||||||
|
?.filter { it.isNotBlank() }
|
||||||
|
?.sorted()
|
||||||
|
?.joinToString(",")
|
||||||
|
.orEmpty()
|
||||||
|
"${transports.joinToString("+")}|$iface|$addresses"
|
||||||
|
}.sorted().joinToString(";").ifBlank { null }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unregisterNetworkCallback() {
|
private fun unregisterNetworkCallback() {
|
||||||
@@ -725,6 +836,9 @@ class ProxyService : Service() {
|
|||||||
cancelCaptchaNotification()
|
cancelCaptchaNotification()
|
||||||
ProxyServiceState.addLog("=== ОСТАНОВКА ИЗ ИНТЕРФЕЙСА ===")
|
ProxyServiceState.addLog("=== ОСТАНОВКА ИЗ ИНТЕРФЕЙСА ===")
|
||||||
process.get()?.destroyCompat()
|
process.get()?.destroyCompat()
|
||||||
|
// serviceScope отменяется ниже — финальный stop() WG делаем синхронно здесь,
|
||||||
|
// иначе корутинный finally может не успеть выполниться.
|
||||||
|
runBlocking { wireGuard.stop() }
|
||||||
serviceScope.cancel()
|
serviceScope.cancel()
|
||||||
if (wakeLock?.isHeld == true) wakeLock?.release()
|
if (wakeLock?.isHeld == true) wakeLock?.release()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ object ProxyServiceState {
|
|||||||
private val _logs = MutableStateFlow<List<String>>(emptyList())
|
private val _logs = MutableStateFlow<List<String>>(emptyList())
|
||||||
val logs: StateFlow<List<String>> = _logs.asStateFlow()
|
val logs: StateFlow<List<String>> = _logs.asStateFlow()
|
||||||
|
|
||||||
|
private val _logsEnabled = MutableStateFlow(true)
|
||||||
|
val logsEnabled: StateFlow<Boolean> = _logsEnabled.asStateFlow()
|
||||||
|
|
||||||
private val _proxyFailed = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
|
private val _proxyFailed = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
|
||||||
val proxyFailed: SharedFlow<Unit> = _proxyFailed.asSharedFlow()
|
val proxyFailed: SharedFlow<Unit> = _proxyFailed.asSharedFlow()
|
||||||
|
|
||||||
@@ -76,7 +79,12 @@ object ProxyServiceState {
|
|||||||
_proxyFailed.tryEmit(Unit)
|
_proxyFailed.tryEmit(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLogsEnabled(value: Boolean) {
|
||||||
|
_logsEnabled.value = value
|
||||||
|
}
|
||||||
|
|
||||||
fun addLog(msg: String) {
|
fun addLog(msg: String) {
|
||||||
|
if (!_logsEnabled.value) return
|
||||||
_logs.update { current ->
|
_logs.update { current ->
|
||||||
val next = current + msg
|
val next = current + msg
|
||||||
if (next.size > MAX_LOG_LINES) next.drop(next.size - MAX_LOG_LINES) else next
|
if (next.size > MAX_LOG_LINES) next.drop(next.size - MAX_LOG_LINES) else next
|
||||||
|
|||||||
@@ -50,6 +50,27 @@ object ObfProfile {
|
|||||||
val ALL = listOf(NONE, RTPOPUS)
|
val ALL = listOf(NONE, RTPOPUS)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Транспорт «туннельного приложения» поверх локального прокси. Пока единственный —
|
||||||
|
* WireGuard (GoBackend): поднимает VPN-туннель, чей Endpoint указывает на localPort
|
||||||
|
* прокси, так что трафик устройства идёт через TURN-релей.
|
||||||
|
*/
|
||||||
|
object TunnelTransport {
|
||||||
|
const val WIREGUARD = "wireguard"
|
||||||
|
val ALL = listOf(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(
|
data class ClientConfig(
|
||||||
val serverAddress: String = "",
|
val serverAddress: String = "",
|
||||||
val vkLink: String = "",
|
val vkLink: String = "",
|
||||||
@@ -83,8 +104,24 @@ data class ClientConfig(
|
|||||||
val syncServerSwitches: Boolean = true,
|
val syncServerSwitches: Boolean = true,
|
||||||
val magicSwitch: Boolean = false,
|
val magicSwitch: Boolean = false,
|
||||||
/** Адрес для флага -turn ядра, если magicSwitch включён. Пусто = не передавать. */
|
/** Адрес для флага -turn ядра, если magicSwitch включён. Пусто = не передавать. */
|
||||||
val magicTurn: String = ""
|
val magicTurn: String = "",
|
||||||
)
|
/** Транспорт туннельного приложения (пока только WireGuard). */
|
||||||
|
val tunnelTransport: String = TunnelTransport.WIREGUARD,
|
||||||
|
/** Конфиг WireGuard (.conf). Пусто = WG-туннель не поднимается. */
|
||||||
|
val wireGuardConfig: String = "",
|
||||||
|
/** Имя WG-туннеля для GoBackend. */
|
||||||
|
val wireGuardTunnelName: String = "freeturn-wg",
|
||||||
|
/** Режим split-tunneling: all | include | exclude. */
|
||||||
|
val splitTunnelMode: String = SplitTunnelMode.ALL,
|
||||||
|
/** Список package-имён для include/exclude (разделители: запятая/пробел/перенос строки). */
|
||||||
|
val splitTunnelApps: String = "",
|
||||||
|
/** Сбор логов ядра в UI. false = ProxyServiceState.addLog глотает строки. */
|
||||||
|
val logsEnabled: Boolean = true
|
||||||
|
) {
|
||||||
|
/** WG реально активен только если выбран WG-транспорт и задан непустой конфиг. */
|
||||||
|
val wireGuardActive: Boolean
|
||||||
|
get() = tunnelTransport == TunnelTransport.WIREGUARD && wireGuardConfig.isNotBlank()
|
||||||
|
}
|
||||||
|
|
||||||
class AppPreferences(context: Context) {
|
class AppPreferences(context: Context) {
|
||||||
private val context = context.applicationContext
|
private val context = context.applicationContext
|
||||||
@@ -114,6 +151,12 @@ class AppPreferences(context: Context) {
|
|||||||
val CLIENT_SYNC_SERVER = booleanPreferencesKey("client_sync_server")
|
val CLIENT_SYNC_SERVER = booleanPreferencesKey("client_sync_server")
|
||||||
val CLIENT_MAGIC_SWITCH = booleanPreferencesKey("client_magic_switch")
|
val CLIENT_MAGIC_SWITCH = booleanPreferencesKey("client_magic_switch")
|
||||||
val CLIENT_MAGIC_TURN = stringPreferencesKey("client_magic_turn")
|
val CLIENT_MAGIC_TURN = stringPreferencesKey("client_magic_turn")
|
||||||
|
val CLIENT_TUNNEL_TRANSPORT = stringPreferencesKey("client_tunnel_transport")
|
||||||
|
val CLIENT_WG_CONFIG = stringPreferencesKey("client_wg_config")
|
||||||
|
val CLIENT_WG_TUNNEL_NAME = stringPreferencesKey("client_wg_tunnel_name")
|
||||||
|
val CLIENT_SPLIT_TUNNEL_MODE = stringPreferencesKey("client_split_tunnel_mode")
|
||||||
|
val CLIENT_SPLIT_TUNNEL_APPS = stringPreferencesKey("client_split_tunnel_apps")
|
||||||
|
val CLIENT_LOGS_ENABLED = booleanPreferencesKey("client_logs_enabled")
|
||||||
val PROXY_LISTEN = stringPreferencesKey("proxy_listen")
|
val PROXY_LISTEN = stringPreferencesKey("proxy_listen")
|
||||||
val PROXY_CONNECT = stringPreferencesKey("proxy_connect")
|
val PROXY_CONNECT = stringPreferencesKey("proxy_connect")
|
||||||
val SERVER_OBF_PROFILE = stringPreferencesKey("server_obf_profile")
|
val SERVER_OBF_PROFILE = stringPreferencesKey("server_obf_profile")
|
||||||
@@ -181,7 +224,17 @@ class AppPreferences(context: Context) {
|
|||||||
},
|
},
|
||||||
syncServerSwitches = prefs[CLIENT_SYNC_SERVER] ?: true,
|
syncServerSwitches = prefs[CLIENT_SYNC_SERVER] ?: true,
|
||||||
magicSwitch = prefs[CLIENT_MAGIC_SWITCH] ?: false,
|
magicSwitch = prefs[CLIENT_MAGIC_SWITCH] ?: false,
|
||||||
magicTurn = prefs[CLIENT_MAGIC_TURN] ?: ""
|
magicTurn = prefs[CLIENT_MAGIC_TURN] ?: "",
|
||||||
|
tunnelTransport = (prefs[CLIENT_TUNNEL_TRANSPORT] ?: TunnelTransport.WIREGUARD).let {
|
||||||
|
if (it in TunnelTransport.ALL) it else TunnelTransport.WIREGUARD
|
||||||
|
},
|
||||||
|
wireGuardConfig = prefs[CLIENT_WG_CONFIG] ?: "",
|
||||||
|
wireGuardTunnelName = (prefs[CLIENT_WG_TUNNEL_NAME] ?: "freeturn-wg").ifBlank { "freeturn-wg" },
|
||||||
|
splitTunnelMode = (prefs[CLIENT_SPLIT_TUNNEL_MODE] ?: SplitTunnelMode.ALL).let {
|
||||||
|
if (it in SplitTunnelMode.VALUES) it else SplitTunnelMode.ALL
|
||||||
|
},
|
||||||
|
splitTunnelApps = prefs[CLIENT_SPLIT_TUNNEL_APPS] ?: "",
|
||||||
|
logsEnabled = prefs[CLIENT_LOGS_ENABLED] ?: true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +354,16 @@ class AppPreferences(context: Context) {
|
|||||||
prefs[CLIENT_SYNC_SERVER] = config.syncServerSwitches
|
prefs[CLIENT_SYNC_SERVER] = config.syncServerSwitches
|
||||||
prefs[CLIENT_MAGIC_SWITCH] = config.magicSwitch
|
prefs[CLIENT_MAGIC_SWITCH] = config.magicSwitch
|
||||||
prefs[CLIENT_MAGIC_TURN] = config.magicTurn.trim()
|
prefs[CLIENT_MAGIC_TURN] = config.magicTurn.trim()
|
||||||
|
prefs[CLIENT_TUNNEL_TRANSPORT] =
|
||||||
|
if (config.tunnelTransport in TunnelTransport.ALL) config.tunnelTransport
|
||||||
|
else TunnelTransport.WIREGUARD
|
||||||
|
prefs[CLIENT_WG_CONFIG] = config.wireGuardConfig.trim()
|
||||||
|
prefs[CLIENT_WG_TUNNEL_NAME] = config.wireGuardTunnelName.trim().ifBlank { "freeturn-wg" }
|
||||||
|
prefs[CLIENT_SPLIT_TUNNEL_MODE] =
|
||||||
|
if (config.splitTunnelMode in SplitTunnelMode.VALUES) config.splitTunnelMode
|
||||||
|
else SplitTunnelMode.ALL
|
||||||
|
prefs[CLIENT_SPLIT_TUNNEL_APPS] = config.splitTunnelApps.trim()
|
||||||
|
prefs[CLIENT_LOGS_ENABLED] = config.logsEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ internal object ProfileJson {
|
|||||||
put("syncServerSwitches", p.client.syncServerSwitches)
|
put("syncServerSwitches", p.client.syncServerSwitches)
|
||||||
put("magicSwitch", p.client.magicSwitch)
|
put("magicSwitch", p.client.magicSwitch)
|
||||||
put("magicTurn", p.client.magicTurn)
|
put("magicTurn", p.client.magicTurn)
|
||||||
|
put("tunnelTransport", p.client.tunnelTransport)
|
||||||
|
put("wireGuardConfig", p.client.wireGuardConfig)
|
||||||
|
put("wireGuardTunnelName", p.client.wireGuardTunnelName)
|
||||||
|
put("splitTunnelMode", p.client.splitTunnelMode)
|
||||||
|
put("splitTunnelApps", p.client.splitTunnelApps)
|
||||||
|
put("logsEnabled", p.client.logsEnabled)
|
||||||
})
|
})
|
||||||
put("proxyListen", p.proxyListen)
|
put("proxyListen", p.proxyListen)
|
||||||
put("proxyConnect", p.proxyConnect)
|
put("proxyConnect", p.proxyConnect)
|
||||||
@@ -125,7 +131,17 @@ internal object ProfileJson {
|
|||||||
},
|
},
|
||||||
syncServerSwitches = cliO.optBoolean("syncServerSwitches", true),
|
syncServerSwitches = cliO.optBoolean("syncServerSwitches", true),
|
||||||
magicSwitch = cliO.optBoolean("magicSwitch", false),
|
magicSwitch = cliO.optBoolean("magicSwitch", false),
|
||||||
magicTurn = cliO.optString("magicTurn")
|
magicTurn = cliO.optString("magicTurn"),
|
||||||
|
tunnelTransport = cliO.optString("tunnelTransport", TunnelTransport.WIREGUARD).let {
|
||||||
|
if (it in TunnelTransport.ALL) it else TunnelTransport.WIREGUARD
|
||||||
|
},
|
||||||
|
wireGuardConfig = cliO.optString("wireGuardConfig"),
|
||||||
|
wireGuardTunnelName = cliO.optString("wireGuardTunnelName").ifBlank { "freeturn-wg" },
|
||||||
|
splitTunnelMode = cliO.optString("splitTunnelMode", SplitTunnelMode.ALL).let {
|
||||||
|
if (it in SplitTunnelMode.VALUES) it else SplitTunnelMode.ALL
|
||||||
|
},
|
||||||
|
splitTunnelApps = cliO.optString("splitTunnelApps"),
|
||||||
|
logsEnabled = cliO.optBoolean("logsEnabled", true)
|
||||||
),
|
),
|
||||||
proxyListen = o.optString("proxyListen").ifBlank { "0.0.0.0:56000" },
|
proxyListen = o.optString("proxyListen").ifBlank { "0.0.0.0:56000" },
|
||||||
proxyConnect = o.optString("proxyConnect").ifBlank { "127.0.0.1:40537" },
|
proxyConnect = o.optString("proxyConnect").ifBlank { "127.0.0.1:40537" },
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package com.freeturn.app.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.freeturn.app.ProxyServiceState
|
||||||
|
import com.freeturn.app.data.ClientConfig
|
||||||
|
import com.freeturn.app.data.SplitTunnelMode
|
||||||
|
import com.wireguard.android.backend.GoBackend
|
||||||
|
import com.wireguard.android.backend.Tunnel
|
||||||
|
import com.wireguard.config.Config
|
||||||
|
import java.io.ByteArrayInputStream
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Поднимает WireGuard-туннель (GoBackend) поверх уже работающего локального прокси.
|
||||||
|
* Endpoint в конфиге подменяется на localPort прокси, так что трафик устройства
|
||||||
|
* заворачивается в туннель и идёт через TURN-релей. Split-tunnel вставляет в
|
||||||
|
* [Interface] Included/ExcludedApplications в зависимости от режима.
|
||||||
|
*/
|
||||||
|
class WireGuardTunnelManager(context: Context) {
|
||||||
|
|
||||||
|
private val appContext = context.applicationContext
|
||||||
|
private val backend by lazy { GoBackend(appContext) }
|
||||||
|
private val tunnelRef = AtomicReference<NamedTunnel?>(null)
|
||||||
|
|
||||||
|
/** Поднять туннель после того как прокси-ядро установило соединение. No-op без WG-конфига. */
|
||||||
|
suspend fun startAfterProxyReady(cfg: ClientConfig) {
|
||||||
|
if (!cfg.wireGuardActive) return
|
||||||
|
val rawConfig = cfg.wireGuardConfig.trim()
|
||||||
|
if (rawConfig.isBlank()) {
|
||||||
|
ProxyServiceState.addLog("WireGuard: конфиг пуст, запуск пропущен")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val name = cfg.wireGuardTunnelName.trim().ifBlank { "freeturn-wg" }
|
||||||
|
val endpoint = cfg.localPort.trim()
|
||||||
|
val preparedConfig = rawConfig
|
||||||
|
.withLocalEndpoint(endpoint)
|
||||||
|
.withSplitTunnel(
|
||||||
|
appPackage = appContext.packageName,
|
||||||
|
mode = cfg.splitTunnelMode,
|
||||||
|
packages = cfg.splitTunnelApps.toPackageList()
|
||||||
|
)
|
||||||
|
val config = Config.parse(
|
||||||
|
ByteArrayInputStream(preparedConfig.toByteArray(StandardCharsets.UTF_8))
|
||||||
|
)
|
||||||
|
|
||||||
|
stop()
|
||||||
|
val tunnel = NamedTunnel(name)
|
||||||
|
backend.setState(tunnel, Tunnel.State.UP, config)
|
||||||
|
tunnelRef.set(tunnel)
|
||||||
|
ProxyServiceState.addLog("WireGuard: туннель $name поднят через $endpoint")
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun stop() {
|
||||||
|
val tunnel = tunnelRef.getAndSet(null) ?: return
|
||||||
|
try {
|
||||||
|
backend.setState(tunnel, Tunnel.State.DOWN, null)
|
||||||
|
ProxyServiceState.addLog("WireGuard: туннель ${tunnel.name} остановлен")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
ProxyServiceState.addLog("WireGuard: ошибка остановки ${tunnel.name}: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NamedTunnel(private val tunnelName: String) : Tunnel {
|
||||||
|
override fun getName(): String = tunnelName
|
||||||
|
|
||||||
|
override fun onStateChange(newState: Tunnel.State) {
|
||||||
|
ProxyServiceState.addLog("WireGuard: состояние $tunnelName -> $newState")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.withLocalEndpoint(endpoint: String): String {
|
||||||
|
if (endpoint.isBlank()) return this
|
||||||
|
var inPeer = false
|
||||||
|
var replaced = false
|
||||||
|
val lines = lineSequence().map { line ->
|
||||||
|
val section = line.trim()
|
||||||
|
if (section.startsWith("[") && section.endsWith("]")) {
|
||||||
|
inPeer = section.equals("[Peer]", ignoreCase = true)
|
||||||
|
}
|
||||||
|
if (inPeer && section.startsWith("Endpoint", ignoreCase = true) && section.contains("=")) {
|
||||||
|
replaced = true
|
||||||
|
"Endpoint = $endpoint"
|
||||||
|
} else {
|
||||||
|
line
|
||||||
|
}
|
||||||
|
}.toMutableList()
|
||||||
|
if (!replaced) {
|
||||||
|
lines += ""
|
||||||
|
lines += "Endpoint = $endpoint"
|
||||||
|
}
|
||||||
|
return lines.joinToString("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.withSplitTunnel(
|
||||||
|
appPackage: String,
|
||||||
|
mode: String,
|
||||||
|
packages: List<String>
|
||||||
|
): String {
|
||||||
|
var inInterface = false
|
||||||
|
var inserted = false
|
||||||
|
val lines = mutableListOf<String>()
|
||||||
|
lineSequence().forEach { line ->
|
||||||
|
val section = line.trim()
|
||||||
|
if (section.startsWith("[") && section.endsWith("]")) {
|
||||||
|
inInterface = section.equals("[Interface]", ignoreCase = true)
|
||||||
|
}
|
||||||
|
val isSplitLine = inInterface && (
|
||||||
|
section.startsWith("IncludedApplications", ignoreCase = true) ||
|
||||||
|
section.startsWith("ExcludedApplications", ignoreCase = true)
|
||||||
|
)
|
||||||
|
if (!isSplitLine) lines += line
|
||||||
|
}
|
||||||
|
|
||||||
|
val interfaceIndex = lines.indexOfFirst {
|
||||||
|
it.trim().equals("[Interface]", ignoreCase = true)
|
||||||
|
}
|
||||||
|
if (interfaceIndex < 0) return lines.joinToString("\n")
|
||||||
|
|
||||||
|
val splitLines = when (mode) {
|
||||||
|
SplitTunnelMode.INCLUDE -> {
|
||||||
|
val included = packages.filter { it != appPackage }.distinct()
|
||||||
|
if (included.isEmpty()) emptyList()
|
||||||
|
else listOf("IncludedApplications = ${included.joinToString(",")}")
|
||||||
|
}
|
||||||
|
SplitTunnelMode.EXCLUDE -> {
|
||||||
|
val excluded = (packages + appPackage).distinct()
|
||||||
|
listOf("ExcludedApplications = ${excluded.joinToString(",")}")
|
||||||
|
}
|
||||||
|
else -> listOf("ExcludedApplications = $appPackage")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (splitLines.isNotEmpty()) {
|
||||||
|
lines.addAll(interfaceIndex + 1, splitLines)
|
||||||
|
inserted = true
|
||||||
|
}
|
||||||
|
return if (inserted) lines.joinToString("\n") else this
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.toPackageList(): List<String> =
|
||||||
|
split(',', '\n', ' ', ';')
|
||||||
|
.map { it.trim() }
|
||||||
|
.filter { it.isNotEmpty() }
|
||||||
|
.distinct()
|
||||||
@@ -15,12 +15,17 @@ import androidx.compose.foundation.layout.WindowInsets
|
|||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
import androidx.compose.foundation.layout.imePadding
|
import androidx.compose.foundation.layout.imePadding
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.widthIn
|
import androidx.compose.foundation.layout.widthIn
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.DividerDefaults
|
import androidx.compose.material3.DividerDefaults
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -35,6 +40,7 @@ import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
|||||||
import androidx.compose.material3.Slider
|
import androidx.compose.material3.Slider
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.material3.TopAppBar
|
import androidx.compose.material3.TopAppBar
|
||||||
import androidx.compose.material3.TopAppBarDefaults
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -58,6 +64,7 @@ import com.freeturn.app.data.ClientConfig
|
|||||||
import com.freeturn.app.data.DnsMode
|
import com.freeturn.app.data.DnsMode
|
||||||
import com.freeturn.app.data.ObfProfile
|
import com.freeturn.app.data.ObfProfile
|
||||||
import com.freeturn.app.data.Provider
|
import com.freeturn.app.data.Provider
|
||||||
|
import com.freeturn.app.data.SplitTunnelMode
|
||||||
import com.freeturn.app.ui.HapticUtil
|
import com.freeturn.app.ui.HapticUtil
|
||||||
import com.freeturn.app.viewmodel.ServerViewModel
|
import com.freeturn.app.viewmodel.ServerViewModel
|
||||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||||
@@ -103,6 +110,10 @@ fun ClientSetupScreen(
|
|||||||
var streamsPerCred by rememberSaveable(saved.streamsPerCred) { mutableFloatStateOf(saved.streamsPerCred.toFloat()) }
|
var streamsPerCred by rememberSaveable(saved.streamsPerCred) { mutableFloatStateOf(saved.streamsPerCred.toFloat()) }
|
||||||
var localPort by rememberSaveable(saved.localPort) { mutableStateOf(saved.localPort) }
|
var localPort by rememberSaveable(saved.localPort) { mutableStateOf(saved.localPort) }
|
||||||
var magicTurn by rememberSaveable(saved.magicTurn) { mutableStateOf(saved.magicTurn) }
|
var magicTurn by rememberSaveable(saved.magicTurn) { mutableStateOf(saved.magicTurn) }
|
||||||
|
var wireGuardTunnelName by rememberSaveable(saved.wireGuardTunnelName) { mutableStateOf(saved.wireGuardTunnelName) }
|
||||||
|
var wireGuardConfig by rememberSaveable(saved.wireGuardConfig) { mutableStateOf(saved.wireGuardConfig) }
|
||||||
|
var splitTunnelApps by rememberSaveable(saved.splitTunnelApps) { mutableStateOf(saved.splitTunnelApps) }
|
||||||
|
var showSplitAppPicker by rememberSaveable { mutableStateOf(false) }
|
||||||
var lastSliderInt by rememberSaveable { mutableIntStateOf(saved.threads) }
|
var lastSliderInt by rememberSaveable { mutableIntStateOf(saved.threads) }
|
||||||
var lastStreamsInt by rememberSaveable { mutableIntStateOf(saved.streamsPerCred) }
|
var lastStreamsInt by rememberSaveable { mutableIntStateOf(saved.streamsPerCred) }
|
||||||
|
|
||||||
@@ -115,7 +126,10 @@ fun ClientSetupScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Авто-сохранение с дебаунсом 600 мс для текстовых полей и ползунков
|
// Авто-сохранение с дебаунсом 600 мс для текстовых полей и ползунков
|
||||||
LaunchedEffect(serverAddress, vkLink, threads, streamsPerCred, localPort, magicTurn) {
|
LaunchedEffect(
|
||||||
|
serverAddress, vkLink, threads, streamsPerCred, localPort, magicTurn,
|
||||||
|
wireGuardTunnelName, wireGuardConfig, splitTunnelApps
|
||||||
|
) {
|
||||||
delay(600)
|
delay(600)
|
||||||
val current = settingsViewModel.clientConfig.value
|
val current = settingsViewModel.clientConfig.value
|
||||||
settingsViewModel.saveClientConfig(
|
settingsViewModel.saveClientConfig(
|
||||||
@@ -125,7 +139,10 @@ fun ClientSetupScreen(
|
|||||||
threads = threads.roundToInt(),
|
threads = threads.roundToInt(),
|
||||||
streamsPerCred = streamsPerCred.roundToInt(),
|
streamsPerCred = streamsPerCred.roundToInt(),
|
||||||
localPort = localPort.trim(),
|
localPort = localPort.trim(),
|
||||||
magicTurn = magicTurn.trim()
|
magicTurn = magicTurn.trim(),
|
||||||
|
wireGuardTunnelName = wireGuardTunnelName.trim().ifBlank { "freeturn-wg" },
|
||||||
|
wireGuardConfig = wireGuardConfig.trim(),
|
||||||
|
splitTunnelApps = splitTunnelApps.trim()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -404,6 +421,58 @@ fun ClientSetupScreen(
|
|||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
|
// --- Туннельное приложение (WireGuard) ---
|
||||||
|
Text(stringResource(R.string.tunnel_transport_title), style = MaterialTheme.typography.titleMedium)
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.tunnel_transport_desc),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
|
||||||
|
Text(stringResource(R.string.wireguard_section), style = MaterialTheme.typography.bodyMedium)
|
||||||
|
OutlinedTextField(
|
||||||
|
value = wireGuardTunnelName.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) wireGuardTunnelName = it },
|
||||||
|
label = { Text(stringResource(R.string.wireguard_tunnel_name)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
readOnly = privacyMode
|
||||||
|
)
|
||||||
|
OutlinedTextField(
|
||||||
|
value = wireGuardConfig.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) wireGuardConfig = it },
|
||||||
|
label = { Text(stringResource(R.string.wireguard_config_label)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.wireguard_config_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
minLines = 8,
|
||||||
|
readOnly = privacyMode,
|
||||||
|
supportingText = { Text(stringResource(R.string.wireguard_config_support)) }
|
||||||
|
)
|
||||||
|
|
||||||
|
SplitTunnelSettings(
|
||||||
|
mode = saved.splitTunnelMode,
|
||||||
|
apps = splitTunnelApps,
|
||||||
|
privacyMode = privacyMode,
|
||||||
|
onModeChange = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||||
|
settingsViewModel.setSplitTunnelMode(it)
|
||||||
|
},
|
||||||
|
onAppsChange = { splitTunnelApps = it },
|
||||||
|
onPickApps = { showSplitAppPicker = true }
|
||||||
|
)
|
||||||
|
|
||||||
|
SwitchRow(
|
||||||
|
label = stringResource(R.string.logs_enabled),
|
||||||
|
description = stringResource(R.string.logs_enabled_desc),
|
||||||
|
checked = saved.logsEnabled,
|
||||||
|
onCheckedChange = {
|
||||||
|
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
|
settingsViewModel.setLogsEnabled(it)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
stringResource(R.string.server_sync_section),
|
stringResource(R.string.server_sync_section),
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleMedium
|
||||||
@@ -585,8 +654,164 @@ fun ClientSetupScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showSplitAppPicker) {
|
||||||
|
SplitTunnelAppPickerDialog(
|
||||||
|
selected = splitTunnelApps.toPackageSet(),
|
||||||
|
onDismiss = { showSplitAppPicker = false },
|
||||||
|
onApply = { selected ->
|
||||||
|
splitTunnelApps = selected.sorted().joinToString("\n")
|
||||||
|
showSplitAppPicker = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SplitTunnelSettings(
|
||||||
|
mode: String,
|
||||||
|
apps: String,
|
||||||
|
privacyMode: Boolean,
|
||||||
|
onModeChange: (String) -> Unit,
|
||||||
|
onAppsChange: (String) -> Unit,
|
||||||
|
onPickApps: () -> Unit
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
Text(stringResource(R.string.split_tunnel_title), style = MaterialTheme.typography.bodyMedium)
|
||||||
|
Text(
|
||||||
|
stringResource(R.string.split_tunnel_desc),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
val options = listOf(
|
||||||
|
SplitTunnelMode.ALL to stringResource(R.string.split_tunnel_all),
|
||||||
|
SplitTunnelMode.INCLUDE to stringResource(R.string.split_tunnel_include),
|
||||||
|
SplitTunnelMode.EXCLUDE to stringResource(R.string.split_tunnel_exclude)
|
||||||
|
)
|
||||||
|
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
options.forEachIndexed { index, (value, label) ->
|
||||||
|
SegmentedButton(
|
||||||
|
selected = mode == value,
|
||||||
|
onClick = { onModeChange(value) },
|
||||||
|
shape = SegmentedButtonDefaults.itemShape(index = index, count = options.size)
|
||||||
|
) { Text(label) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mode != SplitTunnelMode.ALL) {
|
||||||
|
Button(
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
onPickApps()
|
||||||
|
},
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
enabled = !privacyMode
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.split_tunnel_pick_apps))
|
||||||
|
}
|
||||||
|
OutlinedTextField(
|
||||||
|
value = apps.redact(privacyMode),
|
||||||
|
onValueChange = { if (!privacyMode) onAppsChange(it) },
|
||||||
|
label = { Text(stringResource(R.string.split_tunnel_apps_label)) },
|
||||||
|
placeholder = { Text(stringResource(R.string.split_tunnel_apps_placeholder)) },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
minLines = 3,
|
||||||
|
readOnly = privacyMode,
|
||||||
|
supportingText = { Text(stringResource(R.string.split_tunnel_apps_support)) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SplitTunnelAppPickerDialog(
|
||||||
|
selected: Set<String>,
|
||||||
|
onDismiss: () -> Unit,
|
||||||
|
onApply: (Set<String>) -> Unit
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
var selectedApps by remember(selected) { mutableStateOf(selected) }
|
||||||
|
val apps = remember { context.installedInternetApps() }
|
||||||
|
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismiss,
|
||||||
|
title = { Text(stringResource(R.string.split_tunnel_pick_title)) },
|
||||||
|
text = {
|
||||||
|
LazyColumn(modifier = Modifier.heightIn(max = 420.dp)) {
|
||||||
|
items(apps) { app ->
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
) {
|
||||||
|
Checkbox(
|
||||||
|
checked = app.packageName in selectedApps,
|
||||||
|
onCheckedChange = { checked ->
|
||||||
|
selectedApps = if (checked) selectedApps + app.packageName
|
||||||
|
else selectedApps - app.packageName
|
||||||
|
}
|
||||||
|
)
|
||||||
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
Text(app.label, style = MaterialTheme.typography.bodyMedium)
|
||||||
|
Text(
|
||||||
|
app.packageName,
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = { onApply(selectedApps) }) {
|
||||||
|
Text(stringResource(R.string.split_tunnel_done))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismiss) {
|
||||||
|
Text(stringResource(R.string.cancel))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private data class AppChoice(
|
||||||
|
val label: String,
|
||||||
|
val packageName: String
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun android.content.Context.installedInternetApps(): List<AppChoice> {
|
||||||
|
val pm = packageManager
|
||||||
|
val flags = android.content.pm.PackageManager.GET_PERMISSIONS
|
||||||
|
val packages = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
pm.getInstalledPackages(android.content.pm.PackageManager.PackageInfoFlags.of(flags.toLong()))
|
||||||
|
} else {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
pm.getInstalledPackages(flags)
|
||||||
|
}
|
||||||
|
return packages
|
||||||
|
.asSequence()
|
||||||
|
.filter { info ->
|
||||||
|
info.packageName != packageName &&
|
||||||
|
info.requestedPermissions?.contains(android.Manifest.permission.INTERNET) == true
|
||||||
|
}
|
||||||
|
.map { info ->
|
||||||
|
val appInfo = info.applicationInfo
|
||||||
|
AppChoice(
|
||||||
|
label = appInfo?.loadLabel(pm)?.toString()?.takeIf { it.isNotBlank() }
|
||||||
|
?: info.packageName,
|
||||||
|
packageName = info.packageName
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.distinctBy { it.packageName }
|
||||||
|
.sortedWith(compareBy<AppChoice> { it.label.lowercase() }.thenBy { it.packageName })
|
||||||
|
.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun String.toPackageSet(): Set<String> =
|
||||||
|
split(',', '\n', ' ', ';')
|
||||||
|
.map { it.trim() }
|
||||||
|
.filter { it.isNotEmpty() }
|
||||||
|
.toSet()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SwitchRow(
|
private fun SwitchRow(
|
||||||
label: String,
|
label: String,
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import android.Manifest
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.net.VpnService
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
@@ -163,6 +164,26 @@ fun HomeScreen(
|
|||||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
val profilesSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
val profilesSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
|
// WireGuard-туннелю нужно согласие пользователя на VPN. После выдачи —
|
||||||
|
// запускаем прокси (а ProxyService уже поднимет WG поверх него).
|
||||||
|
val wireGuardPermissionLauncher = rememberLauncherForActivityResult(
|
||||||
|
ActivityResultContracts.StartActivityForResult()
|
||||||
|
) {
|
||||||
|
if (VpnService.prepare(context) == null) {
|
||||||
|
proxyViewModel.startProxy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startProxyWithTunnel() {
|
||||||
|
if (clientConfig.wireGuardActive) {
|
||||||
|
val vpnIntent = VpnService.prepare(context)
|
||||||
|
if (vpnIntent != null) {
|
||||||
|
wireGuardPermissionLauncher.launch(vpnIntent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proxyViewModel.startProxy()
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@@ -203,7 +224,7 @@ fun HomeScreen(
|
|||||||
when (proxyState) {
|
when (proxyState) {
|
||||||
is ProxyState.Idle, is ProxyState.Error -> {
|
is ProxyState.Idle, is ProxyState.Error -> {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||||
proxyViewModel.startProxy()
|
startProxyWithTunnel()
|
||||||
}
|
}
|
||||||
is ProxyState.Running, is ProxyState.Connecting, is ProxyState.Starting -> {
|
is ProxyState.Running, is ProxyState.Connecting, is ProxyState.Starting -> {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_OFF)
|
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_OFF)
|
||||||
@@ -274,6 +295,12 @@ fun HomeScreen(
|
|||||||
else stringResource(R.string.tcp)
|
else stringResource(R.string.tcp)
|
||||||
)
|
)
|
||||||
ConfigRow(stringResource(R.string.local_port), clientConfig.localPort.redact(privacyMode))
|
ConfigRow(stringResource(R.string.local_port), clientConfig.localPort.redact(privacyMode))
|
||||||
|
if (clientConfig.wireGuardActive) {
|
||||||
|
ConfigRow(
|
||||||
|
stringResource(R.string.tunnel_transport_title),
|
||||||
|
stringResource(R.string.transport_wireguard)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ class SettingsViewModel(
|
|||||||
val tgShown = prefs.tgSubscribeShownFlow.first()
|
val tgShown = prefs.tgSubscribeShownFlow.first()
|
||||||
_initialOnboardingDone.value = done
|
_initialOnboardingDone.value = done
|
||||||
_initialTgSubscribeShown.value = tgShown
|
_initialTgSubscribeShown.value = tgShown
|
||||||
|
// Восстанавливаем сохранённое состояние тоггла логов при старте.
|
||||||
|
ProxyServiceState.setLogsEnabled(prefs.clientConfigFlow.first().logsEnabled)
|
||||||
_isInitialized.value = true
|
_isInitialized.value = true
|
||||||
}
|
}
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
@@ -108,6 +110,8 @@ class SettingsViewModel(
|
|||||||
fun saveClientConfig(config: ClientConfig) {
|
fun saveClientConfig(config: ClientConfig) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
profileMutex.withLock { prefs.saveClientConfig(config) }
|
profileMutex.withLock { prefs.saveClientConfig(config) }
|
||||||
|
// Тоггл логов применяем сразу, не дожидаясь рестарта прокси.
|
||||||
|
ProxyServiceState.setLogsEnabled(config.logsEnabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +188,27 @@ class SettingsViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setSplitTunnelMode(value: String) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
profileMutex.withLock {
|
||||||
|
val current = prefs.clientConfigFlow.first()
|
||||||
|
if (current.splitTunnelMode == value) return@withLock
|
||||||
|
prefs.saveClientConfig(current.copy(splitTunnelMode = value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setLogsEnabled(enabled: Boolean) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
profileMutex.withLock {
|
||||||
|
val current = prefs.clientConfigFlow.first()
|
||||||
|
if (current.logsEnabled == enabled) return@withLock
|
||||||
|
prefs.saveClientConfig(current.copy(logsEnabled = enabled))
|
||||||
|
}
|
||||||
|
ProxyServiceState.setLogsEnabled(enabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun saveProxyServerConfig(listen: String, connect: String) {
|
fun saveProxyServerConfig(listen: String, connect: String) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
profileMutex.withLock { prefs.saveProxyConfig(listen, connect) }
|
profileMutex.withLock { prefs.saveProxyConfig(listen, connect) }
|
||||||
|
|||||||
@@ -242,4 +242,32 @@
|
|||||||
<string name="notif_proxy_stop_action">Отключить</string>
|
<string name="notif_proxy_stop_action">Отключить</string>
|
||||||
<string name="notif_proxy_status_format">Потоки: %1$d/%2$d • %3$s</string>
|
<string name="notif_proxy_status_format">Потоки: %1$d/%2$d • %3$s</string>
|
||||||
<string name="tile_service_label">Free Turn</string>
|
<string name="tile_service_label">Free Turn</string>
|
||||||
|
<string name="proxy_active_wireguard">Прокси и WireGuard активны</string>
|
||||||
|
|
||||||
|
<!-- Туннельное приложение (WireGuard) -->
|
||||||
|
<string name="tunnel_transport_title">Туннельное приложение</string>
|
||||||
|
<string name="tunnel_transport_desc">Поднимает VPN-туннель поверх локального прокси: трафик устройства заворачивается через TURN-релей. Оставьте конфиг пустым, чтобы не использовать туннель.</string>
|
||||||
|
<string name="transport_wireguard">WireGuard</string>
|
||||||
|
<string name="wireguard_section">WireGuard</string>
|
||||||
|
<string name="wireguard_tunnel_name">Имя туннеля</string>
|
||||||
|
<string name="wireguard_config_label">Конфигурация WireGuard (.conf)</string>
|
||||||
|
<string name="wireguard_config_placeholder">[Interface]\nPrivateKey = …\nAddress = …\n\n[Peer]\nPublicKey = …\nAllowedIPs = 0.0.0.0/0</string>
|
||||||
|
<string name="wireguard_config_support">Endpoint подменяется на локальный порт прокси автоматически. Пусто = туннель не поднимается.</string>
|
||||||
|
|
||||||
|
<!-- Split tunneling -->
|
||||||
|
<string name="split_tunnel_title">Раздельное туннелирование</string>
|
||||||
|
<string name="split_tunnel_desc">Какие приложения отправлять в туннель.</string>
|
||||||
|
<string name="split_tunnel_all">Все</string>
|
||||||
|
<string name="split_tunnel_include">Только эти</string>
|
||||||
|
<string name="split_tunnel_exclude">Кроме этих</string>
|
||||||
|
<string name="split_tunnel_pick_apps">Выбрать приложения</string>
|
||||||
|
<string name="split_tunnel_apps_label">Пакеты приложений</string>
|
||||||
|
<string name="split_tunnel_apps_placeholder">com.example.app\ncom.other.app</string>
|
||||||
|
<string name="split_tunnel_apps_support">По одному package-имени в строке (или через запятую).</string>
|
||||||
|
<string name="split_tunnel_pick_title">Выберите приложения</string>
|
||||||
|
<string name="split_tunnel_done">Готово</string>
|
||||||
|
|
||||||
|
<!-- Логи -->
|
||||||
|
<string name="logs_enabled">Сбор логов</string>
|
||||||
|
<string name="logs_enabled_desc">Показывать вывод ядра на экране логов. Выключите для экономии памяти.</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -15,6 +15,8 @@ coroutinesAndroid = "1.10.2"
|
|||||||
securityCrypto = "1.1.0"
|
securityCrypto = "1.1.0"
|
||||||
bouncycastle = "1.83"
|
bouncycastle = "1.83"
|
||||||
koin = "3.5.6"
|
koin = "3.5.6"
|
||||||
|
wireguardTunnel = "1.0.20260102"
|
||||||
|
desugarJdkLibs = "2.1.5"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
@@ -40,6 +42,8 @@ jsch = { group = "com.github.mwiede", name = "jsch", version.ref = "jsch" }
|
|||||||
bouncycastle = { group = "org.bouncycastle", name = "bcprov-jdk18on", version.ref = "bouncycastle" }
|
bouncycastle = { group = "org.bouncycastle", name = "bcprov-jdk18on", version.ref = "bouncycastle" }
|
||||||
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutinesAndroid" }
|
kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutinesAndroid" }
|
||||||
koin-androidx-compose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koin" }
|
koin-androidx-compose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koin" }
|
||||||
|
wireguard-tunnel = { group = "com.wireguard.android", name = "tunnel", version.ref = "wireguardTunnel" }
|
||||||
|
desugar-jdk-libs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "desugarJdkLibs" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
Reference in new issue
Block a user