Skip to content

Commit 240c977

Browse files
committed
修复一些 PBH-BTN#160 中提到的问题
1 parent a24971e commit 240c977

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/main/java/com/ghostchu/peerbanhelper/util/rule/matcher/IPMatcher.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,17 @@ public void setData(String ruleName, List<IPAddress> ruleData) {
6464
// 先用bloom过滤器查一下
6565
if (bloomFilter.mightContain(content)) {
6666
// 如果查到了,那么进一步验证到底是不是在黑名单中(bloom filter存在误报的可能性)
67-
if (ips.stream().anyMatch(ele -> ele.isIPv4Convertible() == ip.isIPv4Convertible() && ele.equals(ip))) {
68-
return MatchResult.TRUE;
67+
for (IPAddress ele : ips) {
68+
if (ele.isIPv4Convertible() == ip.isIPv4Convertible() && ele.equals(ip)) {
69+
return MatchResult.TRUE;
70+
}
6971
}
7072
}
7173
// 最后subnet表查一下
72-
if (subnets.stream().anyMatch(subnet -> subnet.contains(ip))) {
73-
return MatchResult.TRUE;
74+
for (IPAddress subnet : subnets) {
75+
if (subnet.contains(ip)) {
76+
return MatchResult.TRUE;
77+
}
7478
}
7579
return MatchResult.DEFAULT;
7680
}

src/main/java/com/ghostchu/peerbanhelper/util/rule/matcher/PrefixMatcher.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public void setData(String ruleName, List<String> ruleData) {
3232

3333
@Override
3434
public @NotNull MatchResult match0(@NotNull String content) {
35-
if (prefixes.stream().anyMatch(content::startsWith)) {
36-
return MatchResult.TRUE;
35+
for (String prefix : prefixes) {
36+
if (content.startsWith(prefix)) {
37+
return MatchResult.TRUE;
38+
}
3739
}
3840
return MatchResult.DEFAULT;
3941
}

src/main/java/com/ghostchu/peerbanhelper/util/rule/matcher/SubStrMatcher.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ public void setData(String ruleName, List<String> ruleData) {
3232

3333
@Override
3434
public @NotNull MatchResult match0(@NotNull String content) {
35-
if (subs.stream().anyMatch(content::contains)) {
36-
return MatchResult.TRUE;
35+
for (String sub : subs) {
36+
if (content.contains(sub)) {
37+
return MatchResult.TRUE;
38+
}
3739
}
3840
return MatchResult.DEFAULT;
3941
}

0 commit comments

Comments
 (0)