config: add ignorecase rule types

Signed-off-by: pengzhile <pengzhile@gmail.com>
pull/1/head
pengzhile 3 years ago
parent f5fff1e0f4
commit 7057cd3394

@ -1,10 +1,10 @@
# ja-netfilter v1.1.5
# ja-netfilter v1.1.6
### A javaagent lib for network filter
## Usage
* download from the [releases page](https://github.com/pengzhile/ja-netfilter/releases)
* download from the [releases page](https://github.com/ja-netfilter/ja-netfilter/releases)
* add `-javaagent:/absolute/path/to/ja-netfilter.jar` argument (**Change to your actual path**)
* add as an argument of the `java` command. eg: `java -javaagent:/absolute/path/to/ja-netfilter.jar -jar executable_jar_file.jar`
* some apps support the `JVM Options file`, you can add as a line of the `JVM Options file`.
@ -36,11 +36,15 @@ EQUAL,https://someurl
[DNS]
EQUAL,somedomain
# EQUAL Use `equals` to compare
# KEYWORD Use `contains` to compare
# PREFIX Use `startsWith` to compare
# SUFFIX Use `endsWith` to compare
# REGEXP Use regular expressions to match
# EQUAL Use `equals` to compare
# EQUAL_IC Use `equals` to compare, ignore case
# KEYWORD Use `contains` to compare
# KEYWORD_IC Use `contains` to compare, ignore case
# PREFIX Use `startsWith` to compare
# PREFIX_IC Use `startsWith` to compare, ignore case
# SUFFIX Use `endsWith` to compare
# SUFFIX_IC Use `endsWith` to compare, ignore case
# REGEXP Use regular expressions to match
```
## Debug info
@ -52,7 +56,7 @@ EQUAL,somedomain
## Plugin system
* for developer:
* view the [scaffold project](https://github.com/pengzhile/ja-netfilter-sample-plugin) written for the plugin system
* view the [scaffold project](https://github.com/ja-netfilter/ja-netfilter-sample-plugin) written for the plugin system
* compile your plugin and publish it
* just use your imagination~

@ -6,7 +6,7 @@
<groupId>io.zhile.research</groupId>
<artifactId>ja-netfilter</artifactId>
<version>1.1.5</version>
<version>1.1.6</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -47,6 +47,7 @@
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries>
<Built-By>neo</Built-By>
<Premain-Class>io.zhile.research.ja.netfilter.Launcher</Premain-Class>
<Main-Class>io.zhile.research.ja.netfilter.Launcher</Main-Class>
<Can-Redefine-Classes>true</Can-Redefine-Classes>

@ -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());
}
}
Loading…
Cancel
Save