Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
34b902fe
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
34b902fe
编写于
11月 08, 2019
作者:
H
Heng Du
提交者:
GitHub
11月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1563 from duhenglucky/ipv6_fix
[ISSUE #1564]Fix the ip filter logic in ipv6/ipv4 coexist environment
上级
920fcac1
dee6c7ba
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
15 addition
and
19 deletion
+15
-19
common/src/main/java/org/apache/rocketmq/common/UtilAll.java
common/src/main/java/org/apache/rocketmq/common/UtilAll.java
+6
-11
common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
...src/test/java/org/apache/rocketmq/common/UtilAllTest.java
+8
-6
common/src/test/java/org/apache/rocketmq/common/message/MessageClientIDSetterTest.java
...he/rocketmq/common/message/MessageClientIDSetterTest.java
+1
-2
未找到文件。
common/src/main/java/org/apache/rocketmq/common/UtilAll.java
浏览文件 @
34b902fe
...
...
@@ -440,13 +440,11 @@ public class UtilAll {
return
false
;
}
public
static
boolean
isInternalV6IP
(
byte
[]
ip
)
{
if
(
ip
.
length
!=
16
)
{
throw
new
RuntimeException
(
"illegal ipv6 bytes"
);
}
//FEC0:0000:0000:0000:0000:0000:0000:0000/10
if
(
ip
[
0
]
==
(
byte
)
254
&&
ip
[
1
]
>=
(
byte
)
192
)
{
public
static
boolean
isInternalV6IP
(
InetAddress
inetAddr
)
{
if
(
inetAddr
.
isAnyLocalAddress
()
// Wild card ipv6
||
inetAddr
.
isLinkLocalAddress
()
// Single broadcast ipv6 address: fe80:xx:xx...
||
inetAddr
.
isLoopbackAddress
()
//Loopback ipv6 address
||
inetAddr
.
isSiteLocalAddress
())
{
// Site local ipv6 address: fec0:xx:xx...
return
true
;
}
return
false
;
...
...
@@ -457,9 +455,6 @@ public class UtilAll {
throw
new
RuntimeException
(
"illegal ipv4 bytes"
);
}
// if (ip[0] == (byte)30 && ip[1] == (byte)10 && ip[2] == (byte)163 && ip[3] == (byte)120) {
// }
if
(
ip
[
0
]
>=
(
byte
)
1
&&
ip
[
0
]
<=
(
byte
)
126
)
{
if
(
ip
[
1
]
==
(
byte
)
1
&&
ip
[
2
]
==
(
byte
)
1
&&
ip
[
3
]
==
(
byte
)
1
)
{
return
false
;
...
...
@@ -550,7 +545,7 @@ public class UtilAll {
byte
[]
ipByte
=
ip
.
getAddress
();
if
(
ipByte
.
length
==
16
)
{
if
(
ipV6Check
(
ipByte
))
{
if
(!
isInternalV6IP
(
ip
Byte
))
{
if
(!
isInternalV6IP
(
ip
))
{
return
ipByte
;
}
else
if
(
internalIP
==
null
)
{
internalIP
=
ipByte
;
...
...
common/src/test/java/org/apache/rocketmq/common/UtilAllTest.java
浏览文件 @
34b902fe
...
...
@@ -17,6 +17,8 @@
package
org.apache.rocketmq.common
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Properties
;
import
org.junit.Test
;
...
...
@@ -99,12 +101,12 @@ public class UtilAllTest {
}
@Test
public
void
testIPv6Check
()
{
byte
[]
nonInternalIp
=
UtilAll
.
string2bytes
(
"24084004018081003FAA1DDE2B3F
898A"
);
byte
[]
internalIp
=
UtilAll
.
string2bytes
(
"FEC0000000000000000000000000
FFFF"
);
assertThat
(
UtilAll
.
isInternalV6IP
(
nonInternal
Ip
)).
isFalse
();
assertThat
(
UtilAll
.
isInternalV6IP
(
internal
Ip
)).
isTrue
();
assertThat
(
UtilAll
.
ipToIPv6Str
(
nonInternal
Ip
).
toUpperCase
()).
isEqualTo
(
"2408:4004:0180:8100:3FAA:1DDE:2B3F:898A"
);
public
void
testIPv6Check
()
throws
UnknownHostException
{
InetAddress
nonInternal
=
InetAddress
.
getByName
(
"2408:4004:0180:8100:3FAA:1DDE:2B3F:
898A"
);
InetAddress
internal
=
InetAddress
.
getByName
(
"FE80:0000:0000:0000:0000:0000:0000:
FFFF"
);
assertThat
(
UtilAll
.
isInternalV6IP
(
nonInternal
)).
isFalse
();
assertThat
(
UtilAll
.
isInternalV6IP
(
internal
)).
isTrue
();
assertThat
(
UtilAll
.
ipToIPv6Str
(
nonInternal
.
getAddress
()
).
toUpperCase
()).
isEqualTo
(
"2408:4004:0180:8100:3FAA:1DDE:2B3F:898A"
);
}
static
class
DemoConfig
{
...
...
common/src/test/java/org/apache/rocketmq/common/message/MessageClientIDSetterTest.java
浏览文件 @
34b902fe
...
...
@@ -17,9 +17,8 @@
package
org.apache.rocketmq.common.message
;
import
java.util.Calendar
;
import
java.util.Date
;
import
org.junit.Test
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
public
class
MessageClientIDSetterTest
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录