SocketHook.starthook();
//开启hook之后,socket都会走hook逻辑
//after SocketHook.startHook()
//the socket operation will be hooked
...
socket request
...
SocketHook.stopHook();
//关闭hook,socket 逻辑还原恢复
//after SocketHook.stopHook()
//the socket operation hook will cancel
@Override
protected void connect(SocketAddress address, int timeout) throws IOException {
Logger.getLogger(SocketHookImpl.class.getName()).log(Level.INFO, "SocketAddr=" + address.toString() + ",port=" + port );
/*
YOU CAN HOOK socket.connect() AT HERE
YOU CAN HOOK socket.connect() AT HERE
*/
try
{
this.connectSocketAddressIMPL.invoke( this.socketImpl, address, timeout);
}
catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex)
{
Logger.getLogger(SocketHookImpl.class.getName()).log(Level.SEVERE, null, ex);
}
}
#Author liergou
Welcome to contribute for the project.