mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniele guiducci (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRMINA-963) Socks5 and ProxyConnector don't work with InetSocketAddress.createUnresolved
Date Sat, 14 Sep 2013 18:47:51 GMT

    [ https://issues.apache.org/jira/browse/DIRMINA-963?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13767541#comment-13767541
] 

Daniele guiducci commented on DIRMINA-963:
------------------------------------------

Inside file Socks5LogicHandler
Replace line 129
from:             host = request.getHost() != null ? request.getHost().getBytes("ASCII") :
null;
to:             host = adr != null ? adr.getHostName().getBytes("ASCII") : null;
                
> Socks5 and ProxyConnector don't work with InetSocketAddress.createUnresolved
> ----------------------------------------------------------------------------
>
>                 Key: DIRMINA-963
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-963
>             Project: MINA
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.7
>            Reporter: Daniele guiducci
>              Labels: InetSocketAddress, bug, proxy, socks
>
> I'm tring to use Tor to connect using proxy (SOCKS5).
> InetSocketAddress resolve dns without use Tor, so i can not use in production.
> To use tor to resolve dns i must use   InetSocketAddress.createUnresolved.
> java.net.Socket work perfectly also with .onion url.
>  public static void main(String[] args) throws Exception{
>         NioSocketConnector nioConnector=new NioSocketConnector();
>         nioConnector.setConnectTimeoutMillis(60000);
>         SocksProxyRequest pr = new SocksProxyRequest(
>                 SocksProxyConstants.SOCKS_VERSION_5,
>                 SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
>                 new InetSocketAddress("www.google.com", 80), ""); 
>         ProxyIoSession ps=new ProxyIoSession(new InetSocketAddress("127.0.0.1", 9050),
pr);
>         ProxyConnector connector=new ProxyConnector(nioConnector);
>         connector.getFilterChain().addLast("logger", new LoggingFilter());
>         connector.setProxyIoSession(ps);
>         connector.setHandler(new MyHandler());
>         ConnectFuture cf=connector.connect();
>         IoSession session=cf.getSession();
>         session.getCloseFuture().awaitUninterruptibly();
>         cf.awaitUninterruptibly();
>        Thread.sleep(40000);
>     }
>     private static class MyHandler extends AbstractProxyIoHandler {
>         @Override
>         public void proxySessionOpened(IoSession session) {
>             System.out.println("ProxySession aperta");
>             session.write(IoBuffer.wrap("GET / HTTP/1.0\n\n".getBytes()));
>         }
>         @Override
>         public void  messageReceived(IoSession session, Object msg) {
>             System.out.println("Data:"+new String(((IoBuffer)msg).array()));
>         }
>         @Override
>         public void exceptionCaught(IoSession session, Throwable cause)   throws Exception
{
>             System.out.println("Error: "+cause);
>         }
>     }
> =======================================================
>   public static void main(String[] args) throws Exception{
>         NioSocketConnector nioConnector=new NioSocketConnector();
>         nioConnector.setConnectTimeoutMillis(60000);
>         SocksProxyRequest pr = new SocksProxyRequest(
>                 SocksProxyConstants.SOCKS_VERSION_5,
>                 SocksProxyConstants.ESTABLISH_TCPIP_STREAM,
>                  InetSocketAddress.createUnresolved("www.google.com", 80), ""); 
>         ProxyIoSession ps=new ProxyIoSession(new InetSocketAddress("127.0.0.1", 9050),
pr);
>         ProxyConnector connector=new ProxyConnector(nioConnector);
>         connector.getFilterChain().addLast("logger", new LoggingFilter());
>         connector.setProxyIoSession(ps);
>         connector.setHandler(new MyHandler());
>         ConnectFuture cf=connector.connect();
>         IoSession session=cf.getSession();
>         session.getCloseFuture().awaitUninterruptibly();
>         cf.awaitUninterruptibly();
>        Thread.sleep(40000);
>     }
>     private static class MyHandler extends AbstractProxyIoHandler {
>         @Override
>         public void proxySessionOpened(IoSession session) {
>             System.out.println("ProxySession aperta");
>             session.write(IoBuffer.wrap("GET / HTTP/1.0\n\n".getBytes()));
>         }
>         @Override
>         public void  messageReceived(IoSession session, Object msg) {
>             System.out.println("Data:"+new String(((IoBuffer)msg).array()));
>         }
>         @Override
>         public void exceptionCaught(IoSession session, Throwable cause)   throws Exception
{
>             System.out.println("Error: "+cause);
>         }
>     }
> =========================
> java.net.Socket example working with tor.
> Socket socket=new Socket(new Proxy(Proxy.Type.SOCKS,new InetSocketAddress("127.0.0.1",
9050)));
>         System.out.println("Tryng connect ");
>         socket.connect(InetSocketAddress.createUnresolved("kpvz7ki2v5agwT35.onion", 80),200000);
>         System.out.println("Connected.");
>         OutputStream os=socket.getOutputStream();
>         os.write("GET /wiki/index.php/Main_Page HTTP/1.0\n\n".getBytes());
>         os.flush();
>         System.out.println("Waiting answer.");
>         System.out.println("Output:"+IOUtils.toString(socket.getInputStream()));
> Tell me for other information.
> Thank you.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message