This is an automated email from the ASF dual-hosted git repository. xingfudeshi pushed a commit to branch 2.x in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push: new dd94d71709 bugfix: remove the condition that IPv6 must start with fe80: (#7112) dd94d71709 is described below commit dd94d71709f7c60da9bd5c918f1bd4556ef6c15f Author: xiaoxiangyeyu0 <525718...@qq.com> AuthorDate: Thu Jan 16 11:22:50 2025 +0800 bugfix: remove the condition that IPv6 must start with fe80: (#7112) --- changes/en-us/2.x.md | 2 ++ changes/zh-cn/2.x.md | 2 ++ .../seata/common/util/NetAddressValidatorUtil.java | 16 +++++----------- .../seata/common/util/NetAddressValidatorUtilTest.java | 6 ++++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md index e3945b4b97..e8541f0476 100644 --- a/changes/en-us/2.x.md +++ b/changes/en-us/2.x.md @@ -11,6 +11,7 @@ Add changes here for all PR submitted to the 2.x branch. ### bugfix: - [[#7104](https://github.com/apache/incubator-seata/pull/7104)] fix impl of supportsSourceType is not defined +- [[#7112](https://github.com/apache/incubator-seata/pull/7112)] bugfix: remove the condition that IPv6 must start with fe80 ### optimize: @@ -45,6 +46,7 @@ Thanks to these contributors for their code commits. Please report an unintended - [PeppaO](https://github.com/PeppaO) - [funky-eyes](https://github.com/funky-eyes) - [psxjoy](https://github.com/psxjoy) +- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0) Also, we receive many valuable issues, questions and advices from our community. Thanks for you all. \ No newline at end of file diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md index 5ef696ff1f..e6f2d549c1 100644 --- a/changes/zh-cn/2.x.md +++ b/changes/zh-cn/2.x.md @@ -11,6 +11,7 @@ ### bugfix: - [[#7104](https://github.com/apache/incubator-seata/pull/7104)] 修复SeataApplicationListener在低版本springboot未实现supportsSourceType方法的问题 +- [[#7112](https://github.com/apache/incubator-seata/pull/7112)] 校验是否IPv6网络ip取消必须以fe80开始的条件 ### optimize: @@ -44,5 +45,6 @@ - [PeppaO](https://github.com/PeppaO) - [funky-eyes](https://github.com/funky-eyes) - [psxjoy](https://github.com/psxjoy) +- [xiaoxiangyeyu0](https://github.com/xiaoxiangyeyu0) 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 \ No newline at end of file diff --git a/common/src/main/java/org/apache/seata/common/util/NetAddressValidatorUtil.java b/common/src/main/java/org/apache/seata/common/util/NetAddressValidatorUtil.java index 8b6c8399d3..d1ddfa73d7 100644 --- a/common/src/main/java/org/apache/seata/common/util/NetAddressValidatorUtil.java +++ b/common/src/main/java/org/apache/seata/common/util/NetAddressValidatorUtil.java @@ -30,14 +30,10 @@ public class NetAddressValidatorUtil { private static final String DOUBLE_COLON_FFFF = "::ffff:"; - private static final String FE80 = "fe80:"; - private static final int ZERO = 0; private static final int SEVEN = 7; - private static final int FIVE = 5; - private static final Pattern IPV4_PATTERN = Pattern .compile("^" + "(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)" + "(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}" + "$"); @@ -133,19 +129,17 @@ public class NetAddressValidatorUtil { } /** - * Check if <code>input</code> is a link local IPv6 address starting with "fe80:" and containing + * Check if <code>input</code> is a link local IPv6 address containing * a zone index with "%xxx". The zone index will not be checked. * * @param input ip-address to check * @return true if address part of <code>input</code> is in correct IPv6 notation. */ public static boolean isLinkLocalIPv6WithZoneIndex(String input) { - if (input.length() > FIVE && input.substring(ZERO, FIVE).equalsIgnoreCase(FE80)) { - int lastIndex = input.lastIndexOf(PERCENT); - if (lastIndex > ZERO && lastIndex < (input.length() - 1)) { - String ipPart = input.substring(ZERO, lastIndex); - return isIPv6StdAddress(ipPart) || isIPv6HexCompressedAddress(ipPart); - } + int lastIndex = input.lastIndexOf(PERCENT); + if (lastIndex > ZERO && lastIndex < (input.length() - 1)) { + String ipPart = input.substring(ZERO, lastIndex); + return isIPv6StdAddress(ipPart) || isIPv6HexCompressedAddress(ipPart); } return false; } diff --git a/common/src/test/java/org/apache/seata/common/util/NetAddressValidatorUtilTest.java b/common/src/test/java/org/apache/seata/common/util/NetAddressValidatorUtilTest.java index 6c39ff6062..c23e197368 100644 --- a/common/src/test/java/org/apache/seata/common/util/NetAddressValidatorUtilTest.java +++ b/common/src/test/java/org/apache/seata/common/util/NetAddressValidatorUtilTest.java @@ -53,4 +53,10 @@ public class NetAddressValidatorUtilTest { assertThat(NetAddressValidatorUtil.isIPv4Address("127.0.0.1")).isTrue(); assertThat(NetAddressValidatorUtil.isIPv4Address("999.999.999.999")).isFalse(); } + + @Test + public void isLinkLocalIPv6WithZoneIndex() { + assertThat(NetAddressValidatorUtil.isLinkLocalIPv6WithZoneIndex("2409:8a5c:6730:4490:f0e8:b9ad:3b3d:e739%br0")).isTrue(); + assertThat(NetAddressValidatorUtil.isLinkLocalIPv6WithZoneIndex("2409:8a5c:6730:4490:f0e8:b9ad:3b3d:e739%")).isFalse(); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org