diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt index b8d64e4d..b1e6dda7 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/handler/SpeedtestManager.kt @@ -6,8 +6,6 @@ import com.v2ray.ang.dto.UrlContentRequest import com.v2ray.ang.util.HttpUtil import com.v2ray.ang.util.JsonUtil import com.v2ray.ang.util.LogUtil -import kotlinx.coroutines.currentCoroutineContext -import kotlinx.coroutines.isActive import java.io.IOException import java.net.InetSocketAddress import java.net.Socket @@ -15,29 +13,6 @@ import java.net.UnknownHostException object SpeedtestManager { - private val tcpTestingSockets = ArrayList() - - /** - * Measures the TCP connection time to a given URL and port. - * - * @param url The URL to connect to. - * @param port The port to connect to. - * @return The connection time in milliseconds, or -1 if the connection failed. - */ - suspend fun tcping(url: String, port: Int): Long { - var time = -1L - for (k in 0 until 2) { - val one = socketConnectTime(url, port) - if (!currentCoroutineContext().isActive) { - break - } - if (one != -1L && (time == -1L || one < time)) { - time = one - } - } - return time - } - /** * Measures the time taken to establish a TCP connection to a given URL and port. * @@ -51,10 +26,6 @@ object SpeedtestManager { try { socket = Socket() - synchronized(this) { - tcpTestingSockets.add(socket) - } - socket.connect(InetSocketAddress(url, port), timeoutMs) return System.currentTimeMillis() - start @@ -66,9 +37,6 @@ object SpeedtestManager { LogUtil.e(AppConfig.TAG, "Failed to establish socket connection to $url:$port", e) } finally { socket?.let { s -> - synchronized(this) { - tcpTestingSockets.remove(s) - } try { if (!s.isClosed) { s.close() @@ -80,18 +48,6 @@ object SpeedtestManager { return -1 } - /** - * Closes all TCP sockets that are currently being tested. - */ - fun closeAllTcpSockets() { - synchronized(this) { - tcpTestingSockets.forEach { - it?.close() - } - tcpTestingSockets.clear() - } - } - fun getRemoteIPInfo(): String? { val url = MmkvManager.decodeSettingsString(AppConfig.PREF_IP_API_URL) .takeIf { !it.isNullOrBlank() } ?: AppConfig.IP_API_URL diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt index f395ba8d..6a367769 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/ui/MainActivity.kt @@ -333,12 +333,6 @@ class MainActivity : HelperBaseActivity(), NavigationView.OnNavigationItemSelect true } - R.id.ping_all -> { - toast(getString(R.string.connection_test_testing_count, mainViewModel.serversCache.count())) - mainViewModel.testAllTcping() - true - } - R.id.real_ping_all -> { toast(getString(R.string.connection_test_testing_count, mainViewModel.serversCache.count())) mainViewModel.testAllRealPing() diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt index 97ec2fb9..d172cd7c 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -25,14 +25,10 @@ import com.v2ray.ang.extension.toastSuccess import com.v2ray.ang.handler.AngConfigManager import com.v2ray.ang.handler.MmkvManager import com.v2ray.ang.handler.SettingsManager -import com.v2ray.ang.handler.SpeedtestManager import com.v2ray.ang.util.LogUtil import com.v2ray.ang.util.MessageUtil import com.v2ray.ang.util.Utils -import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import java.util.Collections @@ -46,7 +42,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { val isRunning by lazy { MutableLiveData() } val updateListAction by lazy { MutableLiveData() } val updateTestResultAction by lazy { MutableLiveData() } - private val tcpingTestScope by lazy { CoroutineScope(Dispatchers.IO) } /** * Refer to the official documentation for [registerReceiver](https://developer.android.com/reference/androidx/core/content/ContextCompat#registerReceiver(android.content.Context,android.content.BroadcastReceiver,android.content.IntentFilter,int): @@ -64,8 +59,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { */ override fun onCleared() { getApplication().unregisterReceiver(mMsgReceiver) - tcpingTestScope.coroutineContext[Job]?.cancelChildren() - SpeedtestManager.closeAllTcpSockets() LogUtil.i(AppConfig.TAG, "Main ViewModel is cleared") super.onCleared() } @@ -178,32 +171,6 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { return ret } - /** - * Tests the TCP ping for all servers. - */ - fun testAllTcping() { - tcpingTestScope.coroutineContext[Job]?.cancelChildren() - SpeedtestManager.closeAllTcpSockets() - MmkvManager.clearAllTestDelayResults(serversCache.map { it.guid }.toList()) - - val serversCopy = serversCache.toList() - for (item in serversCopy) { - item.profile.let { outbound -> - val serverAddress = outbound.server - val serverPort = outbound.serverPort - if (serverAddress != null && serverPort != null) { - tcpingTestScope.launch { - val testResult = SpeedtestManager.tcping(serverAddress, serverPort.toInt()) - launch(Dispatchers.Main) { - MmkvManager.encodeServerTestDelayMillis(item.guid, testResult) - updateListAction.value = getPosition(item.guid) - } - } - } - } - } - } - /** * Tests the real ping for all servers. */ diff --git a/V2rayNG/app/src/main/res/menu/menu_main.xml b/V2rayNG/app/src/main/res/menu/menu_main.xml index 61bfb209..cd1a53df 100644 --- a/V2rayNG/app/src/main/res/menu/menu_main.xml +++ b/V2rayNG/app/src/main/res/menu/menu_main.xml @@ -90,10 +90,6 @@ android:icon="@drawable/ic_share_24dp" android:title="@string/title_export_all" app:showAsAction="never" /> - The configuration remarks exists and is unique فاصل التحديث غير صالح. الحد الأدنى هو 15 دقيقة. تحديث الاشتراك (أول خطوة) - Tcping لجميع الإعدادات اختبر جميع الإعدادات (3) Asset files الفرز حسب نتائج الاختبار (5) diff --git a/V2rayNG/app/src/main/res/values-bn/strings.xml b/V2rayNG/app/src/main/res/values-bn/strings.xml index 63073eb4..d076b0f8 100644 --- a/V2rayNG/app/src/main/res/values-bn/strings.xml +++ b/V2rayNG/app/src/main/res/values-bn/strings.xml @@ -306,7 +306,6 @@ The configuration remarks exists and is unique আপডেটের বিরতি সঠিক নয়। সর্বনিম্ন ১৫ মিনিট। সাবস্ক্রিপশন আপডেট - সব কনফিগারেশন TCPing সব কনফিগারেশন প্রকৃত বিলম্ব Asset files টেস্ট ফলাফল দ্বারা সাজানো diff --git a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml index a9f3e1b0..f442cb5c 100644 --- a/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml +++ b/V2rayNG/app/src/main/res/values-bqi-rIR/strings.xml @@ -306,7 +306,6 @@ موتمعن بۊ ک نوم موستعار هڌس وو جۊرس نی فاسله ورۊ کردن نا موئتبر هڌ. هدقل مقدار 15 دؽقه هڌ. ورۊ کردن اشتراک بونکۊ سکویی - Tcping کانفیگا بونکۊ سکویی تئخیر واقعی کانفیگا بونکۊ سکویی فایلا بونچک جوقرافیایی ترتیب و ری نتیجه یل آزمایش diff --git a/V2rayNG/app/src/main/res/values-fa/strings.xml b/V2rayNG/app/src/main/res/values-fa/strings.xml index d26d99a6..53e53791 100644 --- a/V2rayNG/app/src/main/res/values-fa/strings.xml +++ b/V2rayNG/app/src/main/res/values-fa/strings.xml @@ -303,7 +303,6 @@ لطفاً مطمئن شوید که نام مستعار وجود دارد و منحصر به فرد است بازه بروزرسانی نامعتبر است. حداقل مقدار 15 دقیقه است. به‌روزرسانی گروه فعلی اشتراک - TCPING کانفیگ های گروه فعلی تاخیر واقعی کانفیگ های گروه فعلی فایل های منبع جغرافیایی مرتب‌ سازی بر اساس نتایج آزمایش diff --git a/V2rayNG/app/src/main/res/values-ru/strings.xml b/V2rayNG/app/src/main/res/values-ru/strings.xml index ecb57436..ad488efb 100644 --- a/V2rayNG/app/src/main/res/values-ru/strings.xml +++ b/V2rayNG/app/src/main/res/values-ru/strings.xml @@ -312,7 +312,6 @@ Профиль должен быть уникальным Неправильный интервал обновления. Минимум 15 минут. Обновить подписку - Проверить профили Проверить задержку профилей Файлы ресурсов Сортировать по результатам теста diff --git a/V2rayNG/app/src/main/res/values-vi/strings.xml b/V2rayNG/app/src/main/res/values-vi/strings.xml index 8224f78e..789f7bea 100644 --- a/V2rayNG/app/src/main/res/values-vi/strings.xml +++ b/V2rayNG/app/src/main/res/values-vi/strings.xml @@ -306,7 +306,6 @@ The configuration remarks exists and is unique Khoảng thời gian cập nhật không hợp lệ. Giá trị tối thiểu là 15 phút. Cập nhật các gói đăng ký - Ping tất cả máy chủ Kiểm tra HTTP tất cả máy chủ Asset files Sắp xếp lại theo lần kiểm tra cuối cùng diff --git a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml index 05fd7422..d914f84c 100644 --- a/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rCN/strings.xml @@ -307,7 +307,6 @@ 请确保配置别名存在并唯一 更新间隔无效,最小值为 15 分钟。 更新订阅 - 测试配置 Tcping 测试配置真连接 资源文件 按测试结果排序 diff --git a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml index 07942c3c..0d776372 100644 --- a/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml +++ b/V2rayNG/app/src/main/res/values-zh-rTW/strings.xml @@ -306,7 +306,6 @@ 请确保設定檔别名存在并唯一 更新間隔無效,最小值為 15 分鐘。 更新訂閱 - 偵測設定 Tcping 偵測設定真延遲 資源檔案 依偵測結果排序 diff --git a/V2rayNG/app/src/main/res/values/strings.xml b/V2rayNG/app/src/main/res/values/strings.xml index 1d84783e..293aac12 100644 --- a/V2rayNG/app/src/main/res/values/strings.xml +++ b/V2rayNG/app/src/main/res/values/strings.xml @@ -314,7 +314,6 @@ The config remarks exist and are unique Invalid update interval. Minimum is 15 minutes. Update subscription - Tcping config Real delay config Asset files Sorting by test results