mirror of
https://gitee.com/ja-netfilter/ja-netfilter.git
synced 2026-09-23 15:31:55 +08:00
config: add ignorecase rule types
Signed-off-by: pengzhile <[email protected]>
This commit is contained in:
@@ -9,7 +9,7 @@ import java.net.URL;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class Launcher {
|
||||
private static final String VERSION = "v1.1.5";
|
||||
private static final String VERSION = "v1.1.6";
|
||||
|
||||
public static void main(String[] args) {
|
||||
printUsage();
|
||||
|
||||
@@ -44,11 +44,7 @@ public class ConfigParser {
|
||||
throw new Exception("Empty section name! Line: " + lineNumber);
|
||||
}
|
||||
|
||||
lastSection = section;
|
||||
if (null == map.get(lastSection)) {
|
||||
// do NOT override existing sections
|
||||
map.put(lastSection, new ArrayList<>());
|
||||
}
|
||||
map.computeIfAbsent(lastSection = section, k -> new ArrayList<>());
|
||||
break;
|
||||
case '#':
|
||||
case ';':
|
||||
|
||||
@@ -4,10 +4,14 @@ import io.zhile.research.ja.netfilter.rulers.*;
|
||||
|
||||
public enum RuleType {
|
||||
PREFIX(new PrefixRuler()),
|
||||
PREFIX_IC(new PrefixICRuler()),
|
||||
SUFFIX(new SuffixRuler()),
|
||||
SUFFIX_IC(new SuffixICRuler()),
|
||||
KEYWORD(new KeywordRuler()),
|
||||
REGEXP(new RegExpRuler()),
|
||||
EQUAL(new EqualRuler());
|
||||
KEYWORD_IC(new KeywordICRuler()),
|
||||
EQUAL(new EqualRuler()),
|
||||
EQUAL_IC(new EqualICRuler()),
|
||||
REGEXP(new RegExpRuler());
|
||||
|
||||
private final Ruler ruler;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.zhile.research.ja.netfilter.rulers;
|
||||
|
||||
public class EqualICRuler implements Ruler {
|
||||
@Override
|
||||
public boolean test(String rule, String content) {
|
||||
return content.equalsIgnoreCase(rule);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.zhile.research.ja.netfilter.rulers;
|
||||
|
||||
public class KeywordICRuler implements Ruler {
|
||||
@Override
|
||||
public boolean test(String rule, String content) {
|
||||
return content.toLowerCase().contains(rule.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.zhile.research.ja.netfilter.rulers;
|
||||
|
||||
public class PrefixICRuler implements Ruler {
|
||||
@Override
|
||||
public boolean test(String rule, String content) {
|
||||
return content.toLowerCase().startsWith(rule.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package io.zhile.research.ja.netfilter.rulers;
|
||||
|
||||
public class SuffixICRuler implements Ruler {
|
||||
@Override
|
||||
public boolean test(String rule, String content) {
|
||||
return content.toLowerCase().endsWith(rule.toLowerCase());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user