Merge pull request #42 from MYSOREZ/claude/main-bugs-review-nd8dax
This commit is contained in:
3 files changed
+34
-7
No files matched your search
@@ -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", "id.vk.ru", "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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -93,10 +93,16 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
}
|
||||
|
||||
private fun checkForCaptcha(log: String) {
|
||||
val urlPattern = "(https?://(localhost:\\d+|login\\.vk\\.com)\\S*)".toRegex()
|
||||
val match = urlPattern.find(log)
|
||||
if (match != null) {
|
||||
_proxyState.value = ProxyState.CaptchaRequired(match.value)
|
||||
// Kernel emits "CAPTCHA_SOLVE|<mode>|<url>|<token>" for the manual WebView flow.
|
||||
// The url itself never contains "|", so stop the capture there instead of
|
||||
// greedily eating the trailing token with it.
|
||||
val solveMatch = "CAPTCHA_SOLVE\\|[^|]*\\|(https?://[^|\\s]+)".toRegex().find(log)
|
||||
// Fallback for plain URLs in the log (localhost/127.0.0.1 local server,
|
||||
// or VK's own auth domains, which have changed over time: login.vk.com -> id.vk.ru).
|
||||
val fallbackMatch = "(https?://(localhost:\\d+|127\\.0\\.0\\.1:\\d+|id\\.vk\\.ru|login\\.vk\\.com)\\S*)".toRegex().find(log)
|
||||
val captchaUrl = solveMatch?.groupValues?.get(1) ?: fallbackMatch?.value
|
||||
if (captchaUrl != null) {
|
||||
_proxyState.value = ProxyState.CaptchaRequired(captchaUrl)
|
||||
ProxyService.updateNotification("Требуется авторизация", "Нажмите сюда, чтобы пройти капчу!")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user