From e4ca04a0969e8a5c94461c4d144293899820f756 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 4 Nov 2024 19:55:01 +0800 Subject: [PATCH] Bug fix https://github.com/2dust/v2rayNG/issues/3851 --- .../src/main/kotlin/com/v2ray/ang/handler/MigrateManager.kt | 2 +- .../main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt | 2 +- V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/MigrateManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/MigrateManager.kt index 3509ac1a0..9437de5a5 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/MigrateManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/handler/MigrateManager.kt @@ -36,7 +36,7 @@ object MigrateManager { //check and remove old decodeServerConfig(guid) ?: continue - serverStorage.remove(guid) + //serverStorage.remove(guid) Log.d(ANG_PACKAGE, "migrateServerConfig2Profile-" + config.remarks) } Log.d(ANG_PACKAGE, "migrateServerConfig2Profile-end") diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt index a0fcf27c1..7518163fc 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/service/V2RayServiceManager.kt @@ -65,7 +65,7 @@ object V2RayServiceManager { if (v2rayPoint.isRunning) return val guid = MmkvManager.getSelectServer() ?: return val config = MmkvManager.decodeServerConfig(guid) ?: return - if (!Utils.isValidUrl(config.server) && !Utils.isValidUrl(config.server)) return + if (!Utils.isValidUrl(config.server) && !Utils.isIpAddress(config.server)) return // val result = V2rayConfigUtil.getV2rayConfig(context, guid) // if (!result.status) return diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt index 25efc675d..aab069639 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt @@ -159,8 +159,11 @@ object Utils { /** * is ip address */ - fun isIpAddress(value: String): Boolean { + fun isIpAddress(value: String?): Boolean { try { + if (value.isNullOrEmpty()) { + return false + } var addr = value if (addr.isEmpty() || addr.isBlank()) { return false