From 1063bf71d6d9c1afa5c26ad13def7f3bd90434d4 Mon Sep 17 00:00:00 2001 From: NetworkKeeper Date: Thu, 11 Apr 2024 19:32:03 +0300 Subject: [PATCH] Retry downloading geo assets without proxy --- .../com/v2ray/ang/ui/UserAssetActivity.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt index dfdbfcf1..f33bdc62 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/ui/UserAssetActivity.kt @@ -177,7 +177,10 @@ class UserAssetActivity : BaseActivity() { assets.forEach { //toast(getString(R.string.msg_downloading_content) + it) lifecycleScope.launch(Dispatchers.IO) { - val result = downloadGeo(it.second, 60000, httpPort) + var result = downloadGeo(it.second, 60000, httpPort) + if (!result) { + result = downloadGeo(it.second, 60000, 0) + } launch(Dispatchers.Main) { if (result) { toast(getString(R.string.toast_success) + " " + it.second.remarks) @@ -197,12 +200,16 @@ class UserAssetActivity : BaseActivity() { //Log.d(AppConfig.ANG_PACKAGE, url) try { - conn = URL(item.url).openConnection( - Proxy( - Proxy.Type.HTTP, - InetSocketAddress("127.0.0.1", httpPort) - ) - ) as HttpURLConnection + conn = if (httpPort == 0) { + URL(item.url).openConnection() as HttpURLConnection + } else { + URL(item.url).openConnection( + Proxy( + Proxy.Type.HTTP, + InetSocketAddress("127.0.0.1", httpPort) + ) + ) as HttpURLConnection + } conn.connectTimeout = timeout conn.readTimeout = timeout val inputStream = conn.inputStream