You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Trustin Lee (JIRA)" <ji...@apache.org> on 2007/09/28 17:52:50 UTC

[jira] Resolved: (DIRMINA-223) Addition of SocketConnector method to handle socks proxies.

     [ https://issues.apache.org/jira/browse/DIRMINA-223?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee resolved DIRMINA-223.
---------------------------------

    Resolution: Invalid

The patch provided is invalid.  We will take care of the proxy support in DIRMINA-415.

> Addition of SocketConnector method to handle socks proxies.
> -----------------------------------------------------------
>
>                 Key: DIRMINA-223
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-223
>             Project: MINA
>          Issue Type: Improvement
>    Affects Versions: 0.9.4
>         Environment: All platforms
>            Reporter: John Preston
>
> When using MINA to to establish a SocketConnector behind a firewall it is necessary to specify socks proxie to use. The SocketConnector can be ammended as follows: (svn diff)
> Index: core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java
> ===================================================================
> --- core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java	(revision 415629)
> +++ core/src/main/java/org/apache/mina/transport/socket/nio/SocketConnector.java	(working copy)
> @@ -21,6 +21,7 @@
>  import java.io.IOException;
>  import java.net.ConnectException;
>  import java.net.InetSocketAddress;
> +import java.net.Proxy;
>  import java.net.SocketAddress;
>  import java.nio.channels.SelectionKey;
>  import java.nio.channels.Selector;
> @@ -61,6 +62,7 @@
>      private final Set managedSessions = Collections.synchronizedSet( new HashSet() );
>      private final SocketIoProcessor[] ioProcessors;
>      private final int processorCount;
> +    private final Proxy socketProxy;
>  
>      /**
>       * @noinspection FieldAccessedSynchronizedAndUnsynchronized
> @@ -73,9 +75,17 @@
>      /**
>       * Create a connector with a single processing thread
>       */
> +    public SocketConnector(Proxy proxy)
> +    {
> +        this( 1, proxy );
> +    }
> +
> +    /**
> +     * Create a connector with a single processing thread
> +     */
>      public SocketConnector()
>      {
> -        this( 1 );
> +        this( 1, Proxy.NO_PROXY );
>      }
>  
>      /**
> @@ -83,7 +93,7 @@
>       *
>       * @param processorCount Number of processing threads
>       */
> -    public SocketConnector( int processorCount )
> +    public SocketConnector( int processorCount, Proxy proxy )
>      {
>          if( processorCount < 1 )
>          {
> @@ -91,6 +101,7 @@
>          }
>  
>          this.processorCount = processorCount;
> +        this.socketProxy = proxy == null ? Proxy.NO_PROXY : proxy;
>          ioProcessors = new SocketIoProcessor[processorCount];
>  
>          for( int i = 0; i < processorCount; i++ )
> @@ -153,11 +164,12 @@
>          boolean success = false;
>          try
>          {
> -            ch = SocketChannel.open();
> -            ch.socket().setReuseAddress( true );
> +            Socket s = new Socket(socketProxy);
> +            s.setReuseAddress( true );
> +            ch = s.getChannel().open();
>              if( localAddress != null )
>              {
> -                ch.socket().bind( localAddress );
> +                s.bind( localAddress );
>              }
>  
>              ch.configureBlocking( false );
> @@ -475,4 +487,4 @@
>              this.config = config;
>          }
>      }
> -}
> \ No newline at end of file
> +}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.