/** * (<b>Entry point</b>) Demonstrates how to write a very simple tunneling proxy * using MINA. The proxy only logs all data passing through it. This is only * suitable for text based protocols since received data will be converted into * strings before being logged. * <p> * Start a proxy like this:<br/> * <code>org.apache.mina.example.proxy.Main 12345 www.google.com 80</code><br/> * and open <a href="http://localhost:12345">http://localhost:12345</a> in a * browser window. * </p> * * @author The Apache MINA Project (dev@mina.apache.org) * @version $Rev$, $Date$ */ public class Main {
System.out.println("Listening on port " + Integer.parseInt(args[0])); }
}
/** * Handles the server to proxy part of the proxied connection. * * @author The Apache MINA Project (dev@mina.apache.org) * @version $Rev$, $Date$ * */ public class ServerToProxyIoHandler extends AbstractProxyIoHandler { }
/** * Base class of {@link org.apache.mina.core.service.IoHandler} classes which handle * proxied connections. * * @author The Apache MINA Project (dev@mina.apache.org) * @version $Rev$, $Date$ * */ public abstract class AbstractProxyIoHandler extends IoHandlerAdapter { private static final Charset CHARSET = Charset.forName("iso8859-1"); public static final String OTHER_IO_SESSION = AbstractProxyIoHandler.class.getName()+".OtherIoSession";
private final Logger logger = LoggerFactory.getLogger(getClass());
/** * Handles the client to proxy part of the proxied connection. * * @author The Apache MINA Project (dev@mina.apache.org) * @version $Rev$, $Date$ * */ public class ClientToProxyIoHandler extends AbstractProxyIoHandler { private final ServerToProxyIoHandler connectorHandler = new ServerToProxyIoHandler();