mirror of
https://gitee.com/ja-netfilter/ja-netfilter.git
synced 2024-11-16 23:49:38 +08:00
new feature: disable plugins
Signed-off-by: pengzhile <pengzhile@gmail.com>
This commit is contained in:
parent
3f1d63e02e
commit
7d8b08d5b3
@ -1,4 +1,4 @@
|
||||
# ja-netfilter v2.2.1
|
||||
# ja-netfilter v2.2.2
|
||||
|
||||
### A javaagent framework
|
||||
|
||||
@ -62,4 +62,5 @@ EQUAL,somedomain
|
||||
* download the jar file of the plugin
|
||||
* put it in the subdirectory called `plugins` where the ja-netfilter.jar file is located
|
||||
* enjoy the new capabilities brought by the plugin
|
||||
* if the file suffix is `.disabled.jar`, the plugin will be disabled
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.ja-netfilter</groupId>
|
||||
<artifactId>ja-netfilter</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>2.2.2</version>
|
||||
|
||||
<name>ja-netfilter</name>
|
||||
<description>A javaagent framework</description>
|
||||
|
@ -15,6 +15,7 @@ public final class Environment {
|
||||
private final File pluginsDir;
|
||||
private final File logsDir;
|
||||
private final String nativePrefix;
|
||||
private final String disabledPluginSuffix;
|
||||
|
||||
public Environment(File agentFile) {
|
||||
this(agentFile, null);
|
||||
@ -39,6 +40,7 @@ public final class Environment {
|
||||
pid = ProcessUtils.currentId();
|
||||
version = Launcher.VERSION;
|
||||
nativePrefix = StringUtils.randomMethodName(15) + "_";
|
||||
disabledPluginSuffix = ".disabled.jar";
|
||||
}
|
||||
|
||||
public String getPid() {
|
||||
@ -77,6 +79,10 @@ public final class Environment {
|
||||
return nativePrefix;
|
||||
}
|
||||
|
||||
public String getDisabledPluginSuffix() {
|
||||
return disabledPluginSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Environment: {" +
|
||||
@ -89,6 +95,7 @@ public final class Environment {
|
||||
", \n\tpluginsDir = " + pluginsDir +
|
||||
", \n\tlogsDir = " + logsDir +
|
||||
", \n\tnativePrefix = " + nativePrefix +
|
||||
", \n\tdisabledPluginSuffix = " + disabledPluginSuffix +
|
||||
"\n}";
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.jar.JarFile;
|
||||
|
||||
public class Launcher {
|
||||
public static final String ATTACH_ARG = "--attach";
|
||||
public static final String VERSION = "v2.2.1";
|
||||
public static final String VERSION = "v2.2.2";
|
||||
|
||||
private static boolean loaded = false;
|
||||
|
||||
|
@ -68,6 +68,11 @@ public final class PluginManager {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (pluginFile.getName().endsWith(environment.getDisabledPluginSuffix())) {
|
||||
DebugInfo.debug("Disabled plugin: " + pluginFile + ", ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
JarFile jarFile = new JarFile(pluginFile);
|
||||
Manifest manifest = jarFile.getManifest();
|
||||
String entryClass = manifest.getMainAttributes().getValue(ENTRY_NAME);
|
||||
|
Loading…
Reference in New Issue
Block a user