From 6a255cdfa48b93fe0ced0c7ad80e0922d6ece474 Mon Sep 17 00:00:00 2001 From: y67h41 Date: Thu, 24 Aug 2023 17:36:49 +0800 Subject: [PATCH 1/2] Make /0 CIDR be parsed as IP --- V2rayNG/app/src/main/kotlin/com/v2ray/ang/util/Utils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 69a92210..cb764a0f 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 @@ -178,7 +178,7 @@ object Utils { //CIDR if (addr.indexOf("/") > 0) { val arr = addr.split("/") - if (arr.count() == 2 && Integer.parseInt(arr[1]) > 0) { + if (arr.count() == 2 && Integer.parseInt(arr[1]) > -1) { addr = arr[0] } } From ff667546b89a2d19898ea383b4430ad4853ee4bf Mon Sep 17 00:00:00 2001 From: y67h41 Date: Thu, 24 Aug 2023 17:55:12 +0800 Subject: [PATCH 2/2] Update ExampleUnitTest.kt --- V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt b/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt index dd21d55a..8e7961ff 100644 --- a/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt +++ b/V2rayNG/app/src/test/kotlin/com/v2ray/ang/ExampleUnitTest.kt @@ -20,6 +20,7 @@ class UtilTest { assertTrue(Utils.isIpAddress("127.0.0.1" )) assertTrue(Utils.isIpAddress("127.0.0.1:80" )) + assertTrue(Utils.isIpAddress("0.0.0.0/0" )) assertTrue(Utils.isIpAddress("::1" )) assertTrue(Utils.isIpAddress("[::1]:80" )) assertTrue(Utils.isIpAddress("2605:2700:0:3::4713:93e3" )) @@ -28,6 +29,7 @@ class UtilTest { assertTrue(Utils.isIpAddress("[::ffff:192.168.173.22]:80" )) assertTrue(Utils.isIpAddress("1::" )) assertTrue(Utils.isIpAddress("::" )) + assertTrue(Utils.isIpAddress("::/0" )) assertTrue(Utils.isIpAddress("10.24.56.0/24" )) assertTrue(Utils.isIpAddress("2001:4321::1" )) assertTrue(Utils.isIpAddress("240e:1234:abcd:12::6666" ))