Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Ip2region
提交
01529b88
I
Ip2region
项目概览
int
/
Ip2region
上一次同步 大约 1 年
通知
21
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Ip2region
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
01529b88
编写于
7月 15, 2022
作者:
L
Lion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the bug of segment splits and tested
上级
71404d8c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
1 deletion
+76
-1
maker/java/src/main/java/org/lionsoul/ip2region/UtilTest.java
...r/java/src/main/java/org/lionsoul/ip2region/UtilTest.java
+75
-0
maker/java/src/main/java/org/lionsoul/ip2region/xdb/Segment.java
...ava/src/main/java/org/lionsoul/ip2region/xdb/Segment.java
+1
-1
未找到文件。
maker/java/src/main/java/org/lionsoul/ip2region/UtilTest.java
0 → 100644
浏览文件 @
01529b88
// Copyright 2022 The Ip2Region Authors. All rights reserved.
// Use of this source code is governed by a Apache2.0-style
// license that can be found in the LICENSE file.
//
// @Author Lion <chenxin619315@gmail.com>
// @Date 2022/07/15
package
org.lionsoul.ip2region
;
import
org.lionsoul.ip2region.xdb.IndexPolicy
;
import
org.lionsoul.ip2region.xdb.Log
;
import
org.lionsoul.ip2region.xdb.Segment
;
import
org.lionsoul.ip2region.xdb.Util
;
public
class
UtilTest
{
public
static
final
Log
log
=
Log
.
getLogger
(
UtilTest
.
class
);
public
static
void
testIndexPolicy
()
{
final
String
[]
inputs
=
{
"vector"
,
"btree"
,
"VecTor"
,
"BTree"
,
"abc"
};
for
(
String
str
:
inputs
)
{
try
{
int
policy
=
IndexPolicy
.
parse
(
str
);
log
.
infof
(
"parse(%s)=%d"
,
str
,
policy
);
}
catch
(
Exception
e
)
{
log
.
errorf
(
"parse index policy `%s`: %s"
,
str
,
e
.
getMessage
());
}
}
}
public
static
void
testIPUtil
()
{
final
String
ipStr
=
"1.2.3.4"
;
try
{
long
ip
=
Util
.
checkIP
(
ipStr
);
log
.
infof
(
"checkIP(%s)=%d, validate: %s, long2ip(%d)=%s"
,
ipStr
,
ip
,
ip
==
16909060
?
"true"
:
"false"
,
ip
,
Util
.
long2ip
(
ip
));
}
catch
(
Exception
e
)
{
log
.
errorf
(
"failed to check ip `%s`: %s"
,
ipStr
,
e
.
getMessage
());
}
}
public
static
void
testSegment
()
{
final
String
[]
t_segs
=
{
"1.1.0.0|1.3.3.24|中国|广东|深圳|电信"
,
"0.0.0.0|1.255.225.254|0|0|0|内网IP|内网IP"
,
"28.201.224.0|29.34.191.255|美国|0|0|0|0"
};
for
(
String
str
:
t_segs
)
{
try
{
final
Segment
seg
=
Segment
.
parse
(
str
);
log
.
infof
(
"segment(%s)=%s, split: "
,
str
,
seg
.
toString
());
for
(
Segment
s
:
seg
.
split
())
{
log
.
debugf
(
s
.
toString
());
}
}
catch
(
Exception
e
)
{
log
.
errorf
(
"failed to parse segment `%s`: %s"
,
str
,
e
.
getMessage
());
}
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"+-- testing index policy"
);
testIndexPolicy
();
System
.
out
.
println
();
System
.
out
.
println
(
"+-- testing ip util"
);
testIPUtil
();
System
.
out
.
println
();
System
.
out
.
println
(
"+-- testing segments"
);
testSegment
();
System
.
out
.
println
();
}
}
maker/java/src/main/java/org/lionsoul/ip2region/xdb/Segment.java
浏览文件 @
01529b88
...
...
@@ -72,7 +72,7 @@ public class Segment {
eip
=
seg
.
endIP
;
}
segList
.
add
(
new
Segment
(
sip
,
eip
,
seg
.
region
));
segList
.
add
(
new
Segment
(
sip
,
eip
,
region
));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录