From fc58923586940786e80461bf4375b5808ca116f6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Jul 2026 08:19:21 +0000 Subject: [PATCH] fix: captcha manual-pass link not opening and flags not persisting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Captcha URL regex only matched login.vk.com/localhost:PORT, so when the local kernel logs the auth URL on 127.0.0.1:PORT instead, the captcha dialog never triggered. Regex and WebView domain whitelist now accept 127.0.0.1 as well. - Flag switches (VLESS, UDP, DTLS, etc.) only updated in-memory state and were lost on restart unless the user pressed "СОХРАНИТЬ ИЗМЕНЕНИЯ" afterwards. Toggling now saves the config immediately. --- .../vkturn/proxy/ui/CaptchaWebViewDialog.kt | 2 +- .../com/vkturn/proxy/ui/SettingsScreen.kt | 25 +++++++++++++++++-- .../vkturn/proxy/viewmodel/MainViewModel.kt | 3 ++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/vkturn/proxy/ui/CaptchaWebViewDialog.kt b/app/src/main/java/com/vkturn/proxy/ui/CaptchaWebViewDialog.kt index 6401d65..b37a53c 100644 --- a/app/src/main/java/com/vkturn/proxy/ui/CaptchaWebViewDialog.kt +++ b/app/src/main/java/com/vkturn/proxy/ui/CaptchaWebViewDialog.kt @@ -55,7 +55,7 @@ fun CaptchaWebViewDialog(captchaUrl: String, onDismiss: () -> Unit) { override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { val url = request.url.toString() // Allow all captcha-related domains to load inside WebView - val allowedDomains = listOf("localhost", "fapi.vk.com", "login.vk.com", "api.vk.com", "captcha.vk.com", "vk.com", "vk.ru") + val allowedDomains = listOf("localhost", "127.0.0.1", "fapi.vk.com", "login.vk.com", "api.vk.com", "captcha.vk.com", "vk.com", "vk.ru") val isAllowed = allowedDomains.any { url.contains(it) } // Only dismiss if navigating to a completely unrelated page if (!isAllowed) { diff --git a/app/src/main/java/com/vkturn/proxy/ui/SettingsScreen.kt b/app/src/main/java/com/vkturn/proxy/ui/SettingsScreen.kt index a5d3f13..28bf8ec 100644 --- a/app/src/main/java/com/vkturn/proxy/ui/SettingsScreen.kt +++ b/app/src/main/java/com/vkturn/proxy/ui/SettingsScreen.kt @@ -351,9 +351,20 @@ fun SettingsScreen(viewModel: MainViewModel) { text = { Text("Отключение DTLS с большой вероятностью приведет к блокировке со стороны сервиса. Вы уверены?") }, confirmButton = { TextButton(onClick = { - currentFlags = currentFlags.map { - if (it.argument == "-no-dtls") it.copy(enabled = true) else it + val newFlags = currentFlags.map { + if (it.argument == "-no-dtls") it.copy(enabled = true) else it } + currentFlags = newFlags + viewModel.saveClientConfig(clientConfig.copy( + serverAddress = peer, + vkLink = link, + linkArgument = linkArg, + threads = threads.toInt(), + localPort = listen, + isRawMode = false, + rawCommand = rawCommand, + customFlags = newFlags + )) showDtlsWarning = false }) { Text("Продолжить", color = MaterialTheme.colorScheme.error) @@ -395,6 +406,16 @@ fun SettingsScreen(viewModel: MainViewModel) { } currentFlags = newFlags + viewModel.saveClientConfig(clientConfig.copy( + serverAddress = peer, + vkLink = link, + linkArgument = linkArg, + threads = threads.toInt(), + localPort = listen, + isRawMode = false, + rawCommand = rawCommand, + customFlags = newFlags + )) } }, modifier = Modifier.scale(0.8f) diff --git a/app/src/main/java/com/vkturn/proxy/viewmodel/MainViewModel.kt b/app/src/main/java/com/vkturn/proxy/viewmodel/MainViewModel.kt index aa57929..c99186d 100644 --- a/app/src/main/java/com/vkturn/proxy/viewmodel/MainViewModel.kt +++ b/app/src/main/java/com/vkturn/proxy/viewmodel/MainViewModel.kt @@ -93,7 +93,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { } private fun checkForCaptcha(log: String) { - val urlPattern = "(https?://(localhost:\\d+|login\\.vk\\.com)\\S*)".toRegex() + // Match URLs on localhost or 127.0.0.1 (local kernel server) as well as login.vk.com + val urlPattern = "(https?://(localhost:\\d+|127\\.0\\.0\\.1:\\d+|login\\.vk\\.com)\\S*)".toRegex() val match = urlPattern.find(log) if (match != null) { _proxyState.value = ProxyState.CaptchaRequired(match.value)