Исправить запуск VPN из быстрых настроек
This commit is contained in:
1 parent
efabc7e61a
commit
ab1246525f
6 files changed
+98
-104
No files matched your search
@@ -40,6 +40,7 @@
|
|||||||
- В «Инфо → О проекте» добавлена ссылка на историю изменений.
|
- В «Инфо → О проекте» добавлена ссылка на историю изменений.
|
||||||
- Обновление приложения можно скачать внутри WDTT Plus: приложение выбирает подходящий APK, проверяет скачанный файл и открывает системную установку Android.
|
- Обновление приложения можно скачать внутри WDTT Plus: приложение выбирает подходящий APK, проверяет скачанный файл и открывает системную установку Android.
|
||||||
- Доработана навигация в диалогах и блоке «Клиенты»: закрытие возвращает пользователя к предыдущему меню, а список клиентов, поиск и позиция во вкладке «Деплой» сохраняются при переключении между вкладками.
|
- Доработана навигация в диалогах и блоке «Клиенты»: закрытие возвращает пользователя к предыдущему меню, а список клиентов, поиск и позиция во вкладке «Деплой» сохраняются при переключении между вкладками.
|
||||||
|
- Исправлен запуск VPN из плитки быстрых настроек в режиме ссылки.
|
||||||
|
|
||||||
## v1 — 01.07.2026
|
## v1 — 01.07.2026
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
## Возможности Android-версии
|
## Возможности Android-версии
|
||||||
|
|
||||||
- **Полноценный VPN-режим:** приложение использует `VpnService` и WireGuard GoBackend, поэтому трафик выбранных приложений проходит через системный VPN-интерфейс без ручного импорта конфигов.
|
- **Полноценный VPN-режим:** приложение использует `VpnService` и WireGuard GoBackend, поэтому трафик выбранных приложений проходит через системный VPN-интерфейс без ручного импорта конфигов.
|
||||||
- **Корректная передача VPN-слота:** если Android отключает WDTT Plus VPN или другой VPN забирает системный VPN-слот, WDTT Plus останавливает транспорт и переводит плитку/виджет в неактивное состояние.
|
- **Корректная передача VPN-слота:** если Android отключает WDTT Plus VPN или другой VPN забирает системный VPN-слот, WDTT Plus останавливает транспорт и переводит плитку/виджет в неактивное состояние. Плитка запускает VPN как с обычными настройками, так и в режиме ссылки.
|
||||||
- **TURN/DTLS-транспорт:** нативный Go-клиент получает временные TURN-учётные данные VK-звонка и поднимает DTLS-соединения к relay-серверу, через который передаётся трафик до вашего сервера.
|
- **TURN/DTLS-транспорт:** нативный Go-клиент получает временные TURN-учётные данные VK-звонка и поднимает DTLS-соединения к relay-серверу, через который передаётся трафик до вашего сервера.
|
||||||
- **Импорт VK-ссылок через «Поделиться»:** ссылку VK-звонка можно отправить прямо в WDTT Plus. Приложение извлечёт хеш после `/call/join/`, заполнит следующий слот VK-хеша и покажет, какой номер был обновлён.
|
- **Импорт VK-ссылок через «Поделиться»:** ссылку VK-звонка можно отправить прямо в WDTT Plus. Приложение извлечёт хеш после `/call/join/`, заполнит следующий слот VK-хеша и покажет, какой номер был обновлён.
|
||||||
- **Передача между устройствами:** текущий VPN-профиль отправляется как `wdtt://`-ссылка, файл или QR-код. Приложение принимает эти данные через Android, камеру, галерею и выбор файла, сохраняя совместимость со старыми ссылками.
|
- **Передача между устройствами:** текущий VPN-профиль отправляется как `wdtt://`-ссылка, файл или QR-код. Приложение принимает эти данные через Android, камеру, галерею и выбор файла, сохраняя совместимость со старыми ссылками.
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class QuickToggleTileService : TileService() {
|
class QuickToggleTileService : TileService() {
|
||||||
@@ -63,7 +62,7 @@ class QuickToggleTileService : TileService() {
|
|||||||
// Запускаем старт туннеля в фоне
|
// Запускаем старт туннеля в фоне
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
val intent = buildStartIntent()
|
val intent = buildTunnelStartIntentFromSettings(this@QuickToggleTileService)
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
Toast.makeText(this@QuickToggleTileService, "Заполните настройки подключения в WDTT Plus", Toast.LENGTH_LONG).show()
|
Toast.makeText(this@QuickToggleTileService, "Заполните настройки подключения в WDTT Plus", Toast.LENGTH_LONG).show()
|
||||||
openMainActivity()
|
openMainActivity()
|
||||||
@@ -90,38 +89,6 @@ class QuickToggleTileService : TileService() {
|
|||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildStartIntent(): Intent? {
|
|
||||||
return runCatching {
|
|
||||||
val store = SettingsStore(applicationContext)
|
|
||||||
val basePeer = store.peer.first()
|
|
||||||
val hashes = store.vkHashes.first()
|
|
||||||
val password = store.connectionPassword.first()
|
|
||||||
if (basePeer.isBlank() || hashes.isBlank() || password.isBlank()) return null
|
|
||||||
|
|
||||||
val manualPortsEnabled = store.manualPortsEnabled.first()
|
|
||||||
val serverDtlsPort = if (manualPortsEnabled) store.serverDtlsPort.first() else 56000
|
|
||||||
val localPort = if (manualPortsEnabled) store.listenPort.first() else 9000
|
|
||||||
val peerWithPort = if (basePeer.contains(":")) basePeer else "$basePeer:$serverDtlsPort"
|
|
||||||
|
|
||||||
Intent(this, TunnelService::class.java).apply {
|
|
||||||
action = "START"
|
|
||||||
putExtra("peer", peerWithPort)
|
|
||||||
putExtra("vk_hashes", hashes)
|
|
||||||
putExtra("secondary_vk_hash", store.secondaryVkHash.first())
|
|
||||||
putExtra("workers_per_hash", store.workersPerHash.first())
|
|
||||||
putExtra("port", localPort)
|
|
||||||
putExtra("sni", store.sni.first())
|
|
||||||
putExtra("connection_password", store.connectionPassword.first())
|
|
||||||
putExtra("protocol", store.protocol.first())
|
|
||||||
putExtra("vkcalls_preflight", store.vkCallsPreflight.first())
|
|
||||||
putExtra("captcha_mode", store.captchaMode.first())
|
|
||||||
putExtra("captcha_solve_method", store.captchaSolveMethod.first())
|
|
||||||
putExtra("fingerprint", store.selectedFingerprint.first())
|
|
||||||
putExtra("client_ids", store.activeClientIds.first())
|
|
||||||
}
|
|
||||||
}.getOrNull()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateTile(running: Boolean) {
|
private fun updateTile(running: Boolean) {
|
||||||
runCatching {
|
runCatching {
|
||||||
qsTile?.apply {
|
qsTile?.apply {
|
||||||
@@ -160,12 +127,4 @@ class QuickToggleTileService : TileService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sanitizeCaptchaMode(mode: String?): String {
|
|
||||||
return when (mode?.lowercase()) {
|
|
||||||
"auto" -> "auto"
|
|
||||||
"rjs" -> "rjs"
|
|
||||||
"wv" -> "wv"
|
|
||||||
else -> "auto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,6 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@@ -126,26 +125,8 @@ class TunnelService : Service() {
|
|||||||
val appContext = applicationContext
|
val appContext = applicationContext
|
||||||
TunnelManager.scope.launch {
|
TunnelManager.scope.launch {
|
||||||
try {
|
try {
|
||||||
val store = SettingsStore(appContext)
|
val params = buildTunnelParamsFromSettings(appContext)
|
||||||
val basePeer = store.peer.first()
|
if (params != null) {
|
||||||
val manualPortsEnabled = store.manualPortsEnabled.first()
|
|
||||||
val serverDtlsPort = if (manualPortsEnabled) store.serverDtlsPort.first() else 56000
|
|
||||||
val peerWithPort = if (basePeer.isBlank() || basePeer.contains(":")) basePeer else "$basePeer:$serverDtlsPort"
|
|
||||||
val params = TunnelParams(
|
|
||||||
peer = peerWithPort,
|
|
||||||
vkHashes = store.vkHashes.first(),
|
|
||||||
secondaryVkHash = store.secondaryVkHash.first(),
|
|
||||||
workersPerHash = store.workersPerHash.first(),
|
|
||||||
port = store.listenPort.first(),
|
|
||||||
sni = store.sni.first(),
|
|
||||||
connectionPassword = store.connectionPassword.first(),
|
|
||||||
vkCallsPreflight = store.vkCallsPreflight.first(),
|
|
||||||
captchaMode = sanitizeCaptchaMode(store.captchaMode.first()),
|
|
||||||
captchaSolveMethod = store.captchaSolveMethod.first(),
|
|
||||||
fingerprint = store.selectedFingerprint.first(),
|
|
||||||
clientIds = store.activeClientIds.first()
|
|
||||||
)
|
|
||||||
if (params.peer.isNotEmpty() && params.vkHashes.isNotEmpty()) {
|
|
||||||
launch(Dispatchers.Main) {
|
launch(Dispatchers.Main) {
|
||||||
startTunnel(params)
|
startTunnel(params)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.wdtt.plus
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import kotlinx.coroutines.flow.first
|
||||||
|
|
||||||
|
suspend fun buildTunnelParamsFromSettings(context: Context): TunnelParams? {
|
||||||
|
val store = SettingsStore(context.applicationContext)
|
||||||
|
val linkMode = store.wdttLinkMode.first()
|
||||||
|
val workersPerHash = store.workersPerHash.first()
|
||||||
|
val sni = store.sni.first()
|
||||||
|
val protocol = store.protocol.first()
|
||||||
|
val vkCallsPreflight = store.vkCallsPreflight.first()
|
||||||
|
val captchaMode = sanitizeTunnelCaptchaMode(store.captchaMode.first())
|
||||||
|
val captchaSolveMethod = store.captchaSolveMethod.first()
|
||||||
|
val fingerprint = store.selectedFingerprint.first()
|
||||||
|
val clientIds = store.activeClientIds.first()
|
||||||
|
|
||||||
|
return if (linkMode) {
|
||||||
|
val parts = WdttDeepLink.validate(store.wdttLink.first()).parts ?: return null
|
||||||
|
TunnelParams(
|
||||||
|
peer = "${parts.host}:${parts.dtlsPort}",
|
||||||
|
vkHashes = parts.hashes,
|
||||||
|
secondaryVkHash = "",
|
||||||
|
workersPerHash = workersPerHash,
|
||||||
|
port = parts.localPort,
|
||||||
|
sni = sni,
|
||||||
|
connectionPassword = parts.password,
|
||||||
|
protocol = protocol,
|
||||||
|
vkCallsPreflight = vkCallsPreflight,
|
||||||
|
captchaMode = captchaMode,
|
||||||
|
captchaSolveMethod = captchaSolveMethod,
|
||||||
|
fingerprint = fingerprint,
|
||||||
|
clientIds = clientIds
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
val basePeer = store.peer.first().trim()
|
||||||
|
val hashes = store.vkHashes.first().trim()
|
||||||
|
val password = store.connectionPassword.first()
|
||||||
|
if (basePeer.isBlank() || hashes.isBlank() || password.isBlank()) return null
|
||||||
|
|
||||||
|
val manualPortsEnabled = store.manualPortsEnabled.first()
|
||||||
|
val serverDtlsPort = if (manualPortsEnabled) store.serverDtlsPort.first() else 56000
|
||||||
|
val localPort = if (manualPortsEnabled) store.listenPort.first() else 9000
|
||||||
|
val peerWithPort = if (basePeer.contains(":")) basePeer else "$basePeer:$serverDtlsPort"
|
||||||
|
|
||||||
|
TunnelParams(
|
||||||
|
peer = peerWithPort,
|
||||||
|
vkHashes = hashes,
|
||||||
|
secondaryVkHash = store.secondaryVkHash.first(),
|
||||||
|
workersPerHash = workersPerHash,
|
||||||
|
port = localPort,
|
||||||
|
sni = sni,
|
||||||
|
connectionPassword = password,
|
||||||
|
protocol = protocol,
|
||||||
|
vkCallsPreflight = vkCallsPreflight,
|
||||||
|
captchaMode = captchaMode,
|
||||||
|
captchaSolveMethod = captchaSolveMethod,
|
||||||
|
fingerprint = fingerprint,
|
||||||
|
clientIds = clientIds
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun buildTunnelStartIntentFromSettings(context: Context): Intent? {
|
||||||
|
val params = buildTunnelParamsFromSettings(context) ?: return null
|
||||||
|
return Intent(context, TunnelService::class.java).apply {
|
||||||
|
action = "START"
|
||||||
|
putExtra("peer", params.peer)
|
||||||
|
putExtra("vk_hashes", params.vkHashes)
|
||||||
|
putExtra("secondary_vk_hash", params.secondaryVkHash)
|
||||||
|
putExtra("workers_per_hash", params.workersPerHash)
|
||||||
|
putExtra("port", params.port)
|
||||||
|
putExtra("sni", params.sni)
|
||||||
|
putExtra("connection_password", params.connectionPassword)
|
||||||
|
putExtra("protocol", params.protocol)
|
||||||
|
putExtra("vkcalls_preflight", params.vkCallsPreflight)
|
||||||
|
putExtra("captcha_mode", params.captchaMode)
|
||||||
|
putExtra("captcha_solve_method", params.captchaSolveMethod)
|
||||||
|
putExtra("fingerprint", params.fingerprint)
|
||||||
|
putExtra("client_ids", params.clientIds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sanitizeTunnelCaptchaMode(mode: String?): String {
|
||||||
|
return when (mode?.lowercase()) {
|
||||||
|
"auto" -> "auto"
|
||||||
|
"rjs" -> "rjs"
|
||||||
|
"wv" -> "wv"
|
||||||
|
else -> "auto"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,6 @@ import android.widget.Toast
|
|||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.flow.first
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class VpnWidgetProvider : AppWidgetProvider() {
|
class VpnWidgetProvider : AppWidgetProvider() {
|
||||||
@@ -67,7 +66,7 @@ class VpnWidgetProvider : AppWidgetProvider() {
|
|||||||
// Запуск туннеля в фоне
|
// Запуск туннеля в фоне
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
val startIntent = buildStartIntent(context)
|
val startIntent = buildTunnelStartIntentFromSettings(context)
|
||||||
if (startIntent == null) {
|
if (startIntent == null) {
|
||||||
Toast.makeText(context, "Заполните настройки подключения в WDTT Plus", Toast.LENGTH_LONG).show()
|
Toast.makeText(context, "Заполните настройки подключения в WDTT Plus", Toast.LENGTH_LONG).show()
|
||||||
openMainActivity(context)
|
openMainActivity(context)
|
||||||
@@ -136,36 +135,6 @@ class VpnWidgetProvider : AppWidgetProvider() {
|
|||||||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun buildStartIntent(context: Context): Intent? {
|
|
||||||
val store = SettingsStore(context.applicationContext)
|
|
||||||
val basePeer = store.peer.first()
|
|
||||||
val hashes = store.vkHashes.first()
|
|
||||||
val password = store.connectionPassword.first()
|
|
||||||
if (basePeer.isBlank() || hashes.isBlank() || password.isBlank()) return null
|
|
||||||
|
|
||||||
val manualPortsEnabled = store.manualPortsEnabled.first()
|
|
||||||
val serverDtlsPort = if (manualPortsEnabled) store.serverDtlsPort.first() else 56000
|
|
||||||
val localPort = if (manualPortsEnabled) store.listenPort.first() else 9000
|
|
||||||
val peerWithPort = if (basePeer.contains(":")) basePeer else "$basePeer:$serverDtlsPort"
|
|
||||||
|
|
||||||
return Intent(context, TunnelService::class.java).apply {
|
|
||||||
action = "START"
|
|
||||||
putExtra("peer", peerWithPort)
|
|
||||||
putExtra("vk_hashes", hashes)
|
|
||||||
putExtra("secondary_vk_hash", store.secondaryVkHash.first())
|
|
||||||
putExtra("workers_per_hash", store.workersPerHash.first())
|
|
||||||
putExtra("port", localPort)
|
|
||||||
putExtra("sni", store.sni.first())
|
|
||||||
putExtra("connection_password", store.connectionPassword.first())
|
|
||||||
putExtra("protocol", store.protocol.first())
|
|
||||||
putExtra("vkcalls_preflight", store.vkCallsPreflight.first())
|
|
||||||
putExtra("captcha_mode", store.captchaMode.first())
|
|
||||||
putExtra("captcha_solve_method", store.captchaSolveMethod.first())
|
|
||||||
putExtra("fingerprint", store.selectedFingerprint.first())
|
|
||||||
putExtra("client_ids", store.activeClientIds.first())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun openMainActivity(context: Context) {
|
private fun openMainActivity(context: Context) {
|
||||||
val intent = Intent(context, MainActivity::class.java).apply {
|
val intent = Intent(context, MainActivity::class.java).apply {
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@@ -183,12 +152,4 @@ class VpnWidgetProvider : AppWidgetProvider() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sanitizeCaptchaMode(mode: String?): String {
|
|
||||||
return when (mode?.lowercase()) {
|
|
||||||
"auto" -> "auto"
|
|
||||||
"rjs" -> "rjs"
|
|
||||||
"wv" -> "wv"
|
|
||||||
else -> "auto"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user