mirror of
https://github.com/noviceli/jetbra
synced 2025-02-26 22:31:31 +03:00
ban掉restful-fast-request--api-buddy的验证服务器ip
This commit is contained in:
parent
a8b6a9129e
commit
0714d4a122
3 changed files with 29 additions and 7 deletions
|
@ -21,11 +21,19 @@ public class AgentMain {
|
|||
.visit(Advice.to(HttpClientAdvice.class)
|
||||
.on(ElementMatchers.named("openServer"))))
|
||||
.asTerminalTransformation()
|
||||
|
||||
.type(ElementMatchers.named("java.lang.System"))
|
||||
.transform((builder, typeDescription, classLoader, module, protectionDomain) -> builder
|
||||
.visit(Advice.to(SystemAdvice.class)
|
||||
.on(ElementMatchers.named("getProperty"))))
|
||||
.asTerminalTransformation()
|
||||
|
||||
.type(ElementMatchers.named("java.net.Socket"))
|
||||
.transform((builder, typeDescription, classLoader, module, protectionDomain) -> builder
|
||||
.visit(Advice.to(SocketAdvice.class)
|
||||
.on(ElementMatchers.named("connect"))))
|
||||
.asTerminalTransformation()
|
||||
|
||||
.installOn(inst);
|
||||
|
||||
agentBuilder.installOn(inst);
|
||||
|
|
20
jetbra-agent/src/main/java/win/novice/li/SocketAdvice.java
Normal file
20
jetbra-agent/src/main/java/win/novice/li/SocketAdvice.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package win.novice.li;
|
||||
|
||||
import net.bytebuddy.asm.Advice;
|
||||
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
public class SocketAdvice {
|
||||
@Advice.OnMethodExit
|
||||
public static void intercept(@Advice.Argument(value = 0,readOnly = false) SocketAddress socketAddress) throws Exception {
|
||||
if (socketAddress instanceof InetSocketAddress){
|
||||
InetAddress address = ((InetSocketAddress) socketAddress).getAddress();
|
||||
if (address.getHostAddress().equals("116.62.33.138")){
|
||||
throw new ConnectException("拒绝连接");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue