ban掉restful-fast-request--api-buddy的验证服务器ip

This commit is contained in:
novice.li
2024-01-16 23:11:24 +08:00
parent a8b6a9129e
commit 0714d4a122
3 changed files with 29 additions and 7 deletions

View 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("拒绝连接");
}
}
}
}